Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-08-24 18:15:30 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-08-24 18:15:30 (GMT)
commit628fe7b5da46b7618c391b91c9e130b30d4b6623 (patch)
treea851f646190ab6bb589ef5a2570332e7a93f70be /sugar
parentebe2b4765e4c17327dc00c4d38ec0c3fc5a468a5 (diff)
Restore Icon's ability to load absolute file paths.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/graphics/icon.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py
index e324d45..ff4e09a 100644
--- a/sugar/graphics/icon.py
+++ b/sugar/graphics/icon.py
@@ -66,15 +66,25 @@ class Icon(gtk.Image):
icon_theme = gtk.icon_theme_get_for_screen(self.get_screen())
icon_set = gtk.IconSet()
- if icon_theme.has_icon(self._icon_name):
+ if icon_theme.has_icon(self._icon_name) or os.path.exists(self._icon_name):
source = gtk.IconSource()
- source.set_icon_name(self._icon_name)
+
+ if os.path.exists(self._icon_name):
+ source.set_filename(self._icon_name)
+ else:
+ source.set_icon_name(self._icon_name)
+
icon_set.add_source(source)
inactive_name = self._icon_name + '-inactive'
- if icon_theme.has_icon(inactive_name):
+ if icon_theme.has_icon(inactive_name) or os.path.exists(inactive_name):
source = gtk.IconSource()
- source.set_icon_name(inactive_name)
+
+ if os.path.exists(inactive_name):
+ source.set_filename(inactive_name)
+ else:
+ source.set_icon_name(inactive_name)
+
source.set_state(gtk.STATE_INSENSITIVE)
icon_set.add_source(source)
@@ -109,6 +119,9 @@ class Icon(gtk.Image):
self.set_from_pixbuf(pixbuf)
def _get_real_name(self, name):
+ if os.path.exists(name):
+ return name
+
info = self._theme.lookup_icon(name, self.props.icon_size, 0)
if not info:
raise ValueError("Icon '" + name + "' not found.")