[Sugar-devel] [PATCH sugar] Journal detail view copy-palette: fallback to more generic icon when needed, part of OLPC #10805

Simon Schampijer simon at schampijer.de
Mon Apr 4 15:27:22 EDT 2011


The list of icon names we get in Fedora is: ['drive-removable-media-usb', 'drive-removable-media',
'drive-removable', 'drive']. Of this list our artwork only has 'drive' which is the
usb icon. This adds the fallback code to make it more robust and display the icon.

Signed-off-by: Simon Schampijer <simon at laptop.org>
---
 src/jarabe/journal/journaltoolbox.py |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/jarabe/journal/journaltoolbox.py b/src/jarabe/journal/journaltoolbox.py
index cdf998d..d825bc9 100644
--- a/src/jarabe/journal/journaltoolbox.py
+++ b/src/jarabe/journal/journaltoolbox.py
@@ -469,9 +469,12 @@ class EntryToolbar(gtk.Toolbar):
                 continue
             menu_item = MenuItem(mount.get_name())
 
-            # TODO: fallback to the more generic icons when needed
-            menu_item.set_image(Icon(icon_name=mount.get_icon().props.names[0],
-                                     icon_size=gtk.ICON_SIZE_MENU))
+            icon_theme = gtk.icon_theme_get_default()
+            for name in mount.get_icon().props.names:
+                if icon_theme.has_icon(name):
+                    menu_item.set_image(Icon(icon_name=name,
+                                             icon_size=gtk.ICON_SIZE_MENU))
+                    break
 
             menu_item.connect('activate',
                               self._copy_menu_item_activate_cb,
-- 
1.7.4



More information about the Sugar-devel mailing list