From af82f994e39c60ee3c770ce8a724d5132161d24f Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 21 Jun 2010 23:18:41 +0200 Subject: GUI: don't show the placehondler icon rhbz#605693 - the generic executable icon seems to be a better choice if we have it and the placeholder is used really as a last resort - the logic in get_icon_for_package has been improved to not try so hard as it usually picked the wrong icon and might be more confusing for users then just not showing it at all --- src/Gui/CCMainWindow.py | 2 +- src/Gui/CC_gui_functions.py | 35 +++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'src/Gui') diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 658fdcaa..2bc5db7b 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -231,7 +231,7 @@ class MainWindow(): if icon: i_package_icon.set_from_pixbuf(icon) else: - i_package_icon.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_DIALOG) + i_package_icon.set_from_icon_name("application-x-executable", gtk.ICON_SIZE_DIALOG) l_heading = self.wTree.get_widget("l_detail_heading") l_heading.set_markup(_("%s Crash\n%s") % (dump.getPackageName().title(),dump.getPackage())) diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py index e0d68db3..56abae1b 100644 --- a/src/Gui/CC_gui_functions.py +++ b/src/Gui/CC_gui_functions.py @@ -180,8 +180,9 @@ def gui_question_dialog ( message, parent_dialog=None, def get_icon_for_package(theme, package): log2("get_icon_for_package('%s')", package) + package_icon = None try: - return theme.load_icon(package, 48, gtk.ICON_LOOKUP_USE_BUILTIN) + package_icon = theme.load_icon(package, 48, gtk.ICON_LOOKUP_USE_BUILTIN) except: # try to find icon filename by manually if not rpm: @@ -190,6 +191,7 @@ def get_icon_for_package(theme, package): mi = ts.dbMatch('name', package) possible_icons = [] icon_filename = "" + icon_name = "" filenames = "" for h in mi: filenames = h['filenames'] @@ -204,29 +206,26 @@ def get_icon_for_package(theme, package): for line in lines: if line.find("Icon=") != -1: log2("Icon='%s'", line[5:-1]) - icon_filename = line[5:-1] + icon_name = line[5:-1] break desktop_file.close() - # .dektop file found + # .desktop file found + if icon_name: + try: + package_icon = theme.load_icon(icon_name, 48, gtk.ICON_LOOKUP_USE_BUILTIN) + except: + # we should get here only if the .desktop file is wrong.. for filename in h['filenames']: - if filename.rfind("%s.png" % icon_filename) != -1: - log2("png file:'%s'", filename) + if filename.rfind("%s.png" % icon_name) != -1: icon_filename = filename - break - #we didn't find the .desktop file - else: - for filename in possible_icons: - if filename.rfind("%s.png" % package): - # return the first possible filename - icon_filename = filename - break - if icon_filename: - break + # if we found size 48x48 we don't need to continue + if "48x48" in icon_filename: + log2("png file:'%s'", filename) + break if icon_filename: log1("icon created from %s", icon_filename) - return gtk.gdk.pixbuf_new_from_file_at_size(icon_filename, 48, 48) - else: - return None + package_icon = gtk.gdk.pixbuf_new_from_file_at_size(icon_filename, 48, 48) + return package_icon def show_log(message_log, parent=None): builder = gtk.Builder() -- cgit