From be99aa6dcf91aa5daedd3d7067f3b3ece02256f8 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 26 Aug 2007 16:14:29 +0200 Subject: [PATCH 1/6] Fix typos in activitiesdonut.py --- shell/view/home/activitiesdonut.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/view/home/activitiesdonut.py b/shell/view/home/activitiesdonut.py index 950afbd0..de3f8bd7 100644 --- a/shell/view/home/activitiesdonut.py +++ b/shell/view/home/activitiesdonut.py @@ -317,7 +317,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): try: smaps = ProcSmaps(pid) - _subtract_mappings(smaps, shell_mappings) + self._subtract_mappings(smaps, shell_mappings) for mapping in smaps.mappings: if mapping.shared_clean > 0 or mapping.shared_dirty > 0: if num_mappings.has_key(mapping.name): @@ -408,7 +408,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): if icon.size > _MIN_WEDGE_SIZE: icon.size -= (icon.size - _MIN_WEDGE_SIZE) * reduction - def _subtract_mappings(smaps, mappings_to_remove): + def _subtract_mappings(self, smaps, mappings_to_remove): for mapping in smaps.mappings: if mappings_to_remove.has_key(mapping.name): mapping.shared_clean = 0 From 5b1db87cec9b159ffad84a465b871b27b75fad82 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 26 Aug 2007 19:00:08 +0200 Subject: [PATCH 2/6] Add some warnings to the new icon stuff. --- sugar/graphics/icon.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py index cee7dec2..f4b466c8 100644 --- a/sugar/graphics/icon.py +++ b/sugar/graphics/icon.py @@ -182,6 +182,8 @@ class _IconBuffer(object): icon_info.file_name = info.get_filename() icon_info.attach_x = attach_x icon_info.attach_y = attach_y + else: + logging.warning('No icon with the name %s was found in the theme.' % self.icon_name) return icon_info @@ -413,9 +415,13 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): self.props.fill_color = value.get_fill_color() self.props.stroke_color = value.get_stroke_color() elif pspec.name == 'fill-color': + if not isinstance(value, str): + raise TypeError('fill-color must be a string') self._buffer.fill_color = value self.emit_paint_needed(0, 0, -1, -1) elif pspec.name == 'stroke-color': + if not isinstance(value, str): + raise TypeError('stroke-color must be a string') self._buffer.stroke_color = value self.emit_paint_needed(0, 0, -1, -1) elif pspec.name == 'size': From db02d6b54c0d7bd6beee0d8f91378432440aefa4 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 26 Aug 2007 19:23:14 +0200 Subject: [PATCH 3/6] Correct latest commit. --- sugar/graphics/icon.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py index f4b466c8..7912208d 100644 --- a/sugar/graphics/icon.py +++ b/sugar/graphics/icon.py @@ -415,13 +415,13 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): self.props.fill_color = value.get_fill_color() self.props.stroke_color = value.get_stroke_color() elif pspec.name == 'fill-color': - if not isinstance(value, str): - raise TypeError('fill-color must be a string') + if not isinstance(value, basestring): + raise TypeError('fill-color must be a string, not %r' % type(value)) self._buffer.fill_color = value self.emit_paint_needed(0, 0, -1, -1) elif pspec.name == 'stroke-color': - if not isinstance(value, str): - raise TypeError('stroke-color must be a string') + if not isinstance(value, basestring): + raise TypeError('stroke-color must be a string, not %r' % type(value)) self._buffer.stroke_color = value self.emit_paint_needed(0, 0, -1, -1) elif pspec.name == 'size': From cf7ff39c5ad7750f71baeded213f04a89470e658 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 26 Aug 2007 20:21:49 +0200 Subject: [PATCH 4/6] Allow for None values in fill-color and stroke-color. --- sugar/graphics/icon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py index 7912208d..8e36e14b 100644 --- a/sugar/graphics/icon.py +++ b/sugar/graphics/icon.py @@ -415,12 +415,12 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): self.props.fill_color = value.get_fill_color() self.props.stroke_color = value.get_stroke_color() elif pspec.name == 'fill-color': - if not isinstance(value, basestring): + if not isinstance(value, basestring) and value is not None: raise TypeError('fill-color must be a string, not %r' % type(value)) self._buffer.fill_color = value self.emit_paint_needed(0, 0, -1, -1) elif pspec.name == 'stroke-color': - if not isinstance(value, basestring): + if not isinstance(value, basestring) and value is not None: raise TypeError('stroke-color must be a string, not %r' % type(value)) self._buffer.stroke_color = value self.emit_paint_needed(0, 0, -1, -1) From 405dafc90850807bb478e3a00a031e07f602f0ff Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 26 Aug 2007 20:44:51 +0200 Subject: [PATCH 5/6] Adapt to changes in the icon API. --- services/shell/objecttypeservice.py | 12 ++++++------ shell/model/homeactivity.py | 2 +- shell/view/frame/overlaybox.py | 2 +- sugar/activity/activity.py | 4 ++-- sugar/graphics/combobox.py | 15 ++++++++------- sugar/graphics/objectchooser.py | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/services/shell/objecttypeservice.py b/services/shell/objecttypeservice.py index cfaac33c..8a04d61f 100644 --- a/services/shell/objecttypeservice.py +++ b/services/shell/objecttypeservice.py @@ -30,27 +30,27 @@ class ObjectTypeRegistry(dbus.service.Object): self._types = {} - self._add_primitive('Text', _('Text'), 'theme:text-x-generic', + self._add_primitive('Text', _('Text'), 'text-x-generic', ['text/plain', 'text/rtf', 'application/pdf', 'application/x-pdf', 'text/html', 'application/vnd.oasis.opendocument.text', 'application/rtf', 'text/rtf']) - self._add_primitive('Image', _('Image'), 'theme:image-x-generic', + self._add_primitive('Image', _('Image'), 'image-x-generic', ['image/png', 'image/gif', 'image/jpeg']) - self._add_primitive('Audio', _('Audio'), 'theme:audio-x-generic', + self._add_primitive('Audio', _('Audio'), 'audio-x-generic', ['audio/ogg']) - self._add_primitive('Video', _('Video'), 'theme:video-x-generic', + self._add_primitive('Video', _('Video'), 'video-x-generic', ['video/ogg', 'application/ogg']) self._add_primitive('Etoys project', _('Etoys project'), - 'theme:application-x-squeak-project', + 'application-x-squeak-project', ['application/x-squeak-project']) self._add_primitive('Link', _('Link'), - 'theme:text-uri-list', + 'text-uri-list', ['text/x-moz-url', 'text/uri-list']) def _add_primitive(self, type_id, name, icon, mime_types): diff --git a/shell/model/homeactivity.py b/shell/model/homeactivity.py index 434a3a68..1d29be23 100644 --- a/shell/model/homeactivity.py +++ b/shell/model/homeactivity.py @@ -103,7 +103,7 @@ class HomeActivity(gobject.GObject): if self._activity_info: return self._activity_info.icon else: - return 'theme:image-missing' + return 'image-missing' def get_icon_color(self): """Retrieve the appropriate icon colour for this activity diff --git a/shell/view/frame/overlaybox.py b/shell/view/frame/overlaybox.py index f9726e8e..bb74f187 100644 --- a/shell/view/frame/overlaybox.py +++ b/shell/view/frame/overlaybox.py @@ -24,7 +24,7 @@ class OverlayBox(hippo.CanvasBox): self._shell = shell - icon = IconButton(icon_name='theme:stock-chat') + icon = IconButton(icon_name='stock-chat') icon.connect('activated', self._overlay_clicked_cb) self.append(icon) diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py index 3f782b51..6655b243 100644 --- a/sugar/activity/activity.py +++ b/sugar/activity/activity.py @@ -75,9 +75,9 @@ class ActivityToolbar(gtk.Toolbar): self.share = ToolComboBox(label_text='Share with:') self.share.combo.connect('changed', self._share_changed_cb) self.share.combo.append_item(None, _('Private'), - 'theme:zoom-home-mini') + 'zoom-home-mini') self.share.combo.append_item(None, _('My Neighborhood'), - 'theme:zoom-neighborhood-mini') + 'zoom-neighborhood-mini') self.insert(self.share, -1) self.share.show() diff --git a/sugar/graphics/combobox.py b/sugar/graphics/combobox.py index 3251dc2c..75573f0a 100644 --- a/sugar/graphics/combobox.py +++ b/sugar/graphics/combobox.py @@ -61,8 +61,8 @@ class ComboBox(gtk.ComboBox): del info return fname - def append_item(self, action_id, text, icon_name=None): - if not self._icon_renderer and icon_name: + def append_item(self, action_id, text, icon_name=None, file_name=None): + if not self._icon_renderer and (icon_name or file_name): self._icon_renderer = gtk.CellRendererPixbuf() settings = self.get_settings() @@ -77,16 +77,17 @@ class ComboBox(gtk.ComboBox): self.pack_end(self._text_renderer, True) self.add_attribute(self._text_renderer, 'text', 1) - if icon_name: + if icon_name or file_name: if text: size = gtk.ICON_SIZE_MENU else: size = gtk.ICON_SIZE_LARGE_TOOLBAR - width, height = gtk.icon_size_lookup(size) - if icon_name[0:6] == "theme:": - icon_name = self._get_real_name_from_theme(icon_name[6:], size) - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_name, width, height) + + if icon_name: + file_name = self._get_real_name_from_theme(icon_name[6:], size) + + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_name, width, height) else: pixbuf = None diff --git a/sugar/graphics/objectchooser.py b/sugar/graphics/objectchooser.py index 56a5a31b..4128cf31 100644 --- a/sugar/graphics/objectchooser.py +++ b/sugar/graphics/objectchooser.py @@ -150,7 +150,7 @@ class CollapsedEntry(CanvasRoundBox): self._icon_name = type.icon if not self._icon_name: - self._icon_name = 'theme:image-missing' + self._icon_name = 'image-missing' return self._icon_name From 8c288d7deeda09cf9d98b9ce57186bed5c808f3e Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sun, 26 Aug 2007 16:49:55 -0400 Subject: [PATCH 6/6] Adapt Button() to new icon API --- sugar/graphics/button.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sugar/graphics/button.py b/sugar/graphics/button.py index fc869f99..647f36df 100644 --- a/sugar/graphics/button.py +++ b/sugar/graphics/button.py @@ -25,7 +25,7 @@ class CanvasButton(hippo.CanvasButton): hippo.CanvasButton.__init__(self, text=label) if icon_name: - icon = Icon(icon_name,icon_size=gtk.ICON_SIZE_BUTTON) + icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_BUTTON) self.props.widget.set_image(icon) icon.show()