From e642160ae1e44bfd22eb19fdb39e421bd38fecdc Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Jul 13 2015 08:57:34 +0000 Subject: Fix bugs in loading application icon and searching Resolves: #1242080 --- diff --git a/0003-Fix-loading-applicaton-icons.patch b/0003-Fix-loading-applicaton-icons.patch new file mode 100644 index 0000000..39f00bc --- /dev/null +++ b/0003-Fix-loading-applicaton-icons.patch @@ -0,0 +1,120 @@ +From 796ac63aa1eb75c8558faa6d21721b331297b4a6 Mon Sep 17 00:00:00 2001 +From: Matej Habrnal +Date: Wed, 24 Jun 2015 09:33:19 +0200 +Subject: [PATCH] Fix loading applicaton icons + +Without this patch gnome-abrt raises an exception in the case the +application icon should exists but doesn't. + +Related to rhbz#1234732 + +v2: jfilak@redhat.com +- added a new function load_icon() + +Signed-off-by: Matej Habrnal +Signed-off-by: Jakub Filak +--- + src/gnome_abrt/tools.py | 37 +++++++++++++++++++++++++++++++++++++ + src/gnome_abrt/views.py | 26 +++++++++----------------- + 2 files changed, 46 insertions(+), 17 deletions(-) + +diff --git a/src/gnome_abrt/tools.py b/src/gnome_abrt/tools.py +index 7e440a3..a7361a0 100644 +--- a/src/gnome_abrt/tools.py ++++ b/src/gnome_abrt/tools.py +@@ -17,6 +17,12 @@ + + import datetime + import calendar ++import logging ++ ++#pylint: disable=E0611 ++from gi.repository import GLib ++#pylint: disable=E0611 ++from gi.repository import Gtk + + from gnome_abrt.l10n import _ + from gnome_abrt.l10n import ngettext +@@ -61,3 +67,34 @@ def smart_truncate(content, length=100, suffix='...'): + return content + else: + return content[:length].rsplit(' ', 1)[0] + suffix ++ ++ ++def load_icon(name=None, gicon=None): ++ theme = Gtk.IconTheme.get_default() ++ ++ icon = None ++ if not gicon is None and name is None: ++ name = gicon.to_string() ++ icon = theme.lookup_by_gicon(gicon, 128, ++ Gtk.IconLookupFlags.FORCE_SIZE) ++ elif not name is None and gicon is None: ++ icon = theme.lookup_icon(name, 128, ++ Gtk.IconLookupFlags.FORCE_SIZE ++ | Gtk.IconLookupFlags.FORCE_SYMBOLIC) ++ else: ++ logging.error("BUG: invalid arguments in load_icon():" \ ++ "name={0}, gicon={1}".format(str(name), str(gicon))) ++ return None ++ ++ if icon is None: ++ logging.warning(_("Failed to find icon '{0}'").format(name)) ++ return None ++ ++ try: ++ return icon.load_icon() ++ #pylint: disable=E0712 ++ except GLib.Error as ex: ++ logging.warning(_("Failed to load icon '{0}': {1}") ++ .format(name, str(ex))) ++ ++ return None +diff --git a/src/gnome_abrt/views.py b/src/gnome_abrt/views.py +index 95c9639..a1e684b 100644 +--- a/src/gnome_abrt/views.py ++++ b/src/gnome_abrt/views.py +@@ -40,7 +40,7 @@ import gnome_abrt.wrappers as wrappers + import gnome_abrt.errors as errors + import gnome_abrt.desktop as desktop + from gnome_abrt import GNOME_ABRT_UI_DIR +-from gnome_abrt.tools import fancydate, smart_truncate ++from gnome_abrt.tools import fancydate, smart_truncate, load_icon + from gnome_abrt.l10n import _, GETTEXT_PROGNAME + + +@@ -833,23 +833,15 @@ class OopsWindow(Gtk.ApplicationWindow): + self._builder.lbl_detected_value.set_tooltip_text( + problem['date'].strftime(config.get_configuration()['D_T_FMT'])) + ++ icon_buf = None + if app.icon: +- self._builder.img_app_icon.set_from_pixbuf( +- Gtk.IconTheme +- .get_default() +- .lookup_by_gicon(app.icon, +- 128, +- Gtk.IconLookupFlags.FORCE_SIZE) +- .load_icon()) +- else: +- self._builder.img_app_icon.set_from_pixbuf( +- Gtk.IconTheme +- .get_default() +- .lookup_icon("system-run-symbolic", +- 128, +- Gtk.IconLookupFlags.FORCE_SIZE | +- Gtk.IconLookupFlags.FORCE_SYMBOLIC) +- .load_icon()) ++ icon_buf = load_icon(gicon=app.icon) ++ ++ if icon_buf is None: ++ icon_buf = load_icon(name="system-run-symbolic") ++ ++ # icon_buf can be None and if it is None, no icon will be displayed ++ self._builder.img_app_icon.set_from_pixbuf(icon_buf) + + self._builder.lbl_reported_value.show() + self._builder.lbl_reported.set_text(_("Reported")) +-- +2.4.5 + diff --git a/0004-Fix-an-exception-when-searching-for-a-bug-ID.patch b/0004-Fix-an-exception-when-searching-for-a-bug-ID.patch new file mode 100644 index 0000000..324a60d --- /dev/null +++ b/0004-Fix-an-exception-when-searching-for-a-bug-ID.patch @@ -0,0 +1,35 @@ +From 9ed78be49ce54a69b72af1bcd54f093218570e20 Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Mon, 13 Jul 2015 10:35:29 +0200 +Subject: [PATCH] Fix an exception when searching for a bug ID + +The encode() function returns 'bytes' but that is useless and wrong in +our case, because we just need to get 'str' from 'DBus.String' to be +able to call the 'in' operator (the operator does not work for 'str' in +'DBus.String'). + +Related: rhbz#1211083, rhbz#1242080 + +Signed-off-by: Jakub Filak +--- + src/gnome_abrt/views.py | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/gnome_abrt/views.py b/src/gnome_abrt/views.py +index a1e684b..fb4c6e0 100644 +--- a/src/gnome_abrt/views.py ++++ b/src/gnome_abrt/views.py +@@ -105,7 +105,9 @@ class ProblemsFilter(object): + if problems.Problem.Submission.URL != sbm.rtype: + continue + +- rid = sbm.data.encode('utf-8') ++ # _pattern is 'str' and sbm.data is 'dbus.String', so we need ++ # to convert sbm.data to a regular 'str' ++ rid = str(sbm.data) + rid = rid.rstrip('/').split('/')[-1].split('=')[-1] + if self._pattern in rid: + return True +-- +2.4.5 + diff --git a/gnome-abrt.spec b/gnome-abrt.spec index ce53689..fd7e002 100644 --- a/gnome-abrt.spec +++ b/gnome-abrt.spec @@ -6,7 +6,7 @@ Name: gnome-abrt Version: 1.2.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A utility for viewing problems that have occurred with the system Group: User Interface/Desktops @@ -18,6 +18,8 @@ Source0: https://fedorahosted.org/released/abrt/%{name}-%{version}.tar.gz # i=1; for p in `ls 0*.patch`; do printf "Patch%04d: %s\n" $i $p; ((i++)); done Patch0001: 0001-Remove-the-Details-button-from-the-top-bar-in-non-GN.patch Patch0002: 0002-Use-UTF-8-encoding-when-working-with-user-files.patch +Patch0003: 0003-Fix-loading-applicaton-icons.patch +Patch0004: 0004-Fix-an-exception-when-searching-for-a-bug-ID.patch # git is need for '%%autosetup -S git' which automatically applies all the # patches above. Please, be aware that the patches must be generated @@ -122,6 +124,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %changelog +* Mon Jul 13 2015 Jakub Filak - 1.2.0-4 +- Fix loading applicaton icons +- Fix an exception when searching for a bug ID +- Resolves: #1242080 + * Thu Jun 18 2015 Matej Habrnal - 1.2.0-3 - Use UTF-8 encoding when working with user files - Remove the Details button from the top bar in non-GNOME desktops