Hi,
I found out what one of my problems was. For the SugarIcon I tried to
set a pixel_size.
http://www.pygtk.org/pygtk2reference/class-gtkimage.html#method-gtkimage--set-pixel-size
Giving a pixel_size works when handing it directly to the constructor
but not when changing the properties of an existing object
(icon.props.pixel_size = style.XLARGE_ICON_SIZE).
The attached patch does fix this. I think the _update_buffer_size()
method is not used anywhere so we can remove it I guess. Marco, Tomeu
what do you think?
Simon
Simon Schampijer wrote:
Hi,
the Icon class (derived from gtk.Image) is using gtk-icon-size-lookup[1]
to determine the icon's size. The size must therefore be an enum like
gtk.ICON_SIZE_MENU.
How do we best handle our custom sizes (like style.LARGE_ICON_SIZE)?
You can registers a new icon size [2] but I am not sure this is the
right approach.
Best,
Simon
[1]
http://www.pygtk.org/pygtk2reference/class-gtkiconsource.html#function-gtk--icon-size-lookup
[2]
http://www.pygtk.org/pygtk2reference/class-gtkiconsource.html#function-gtk--icon-size-register
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar
diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py
index 81a8232..9a96fa0 100644
--- a/sugar/graphics/icon.py
+++ b/sugar/graphics/icon.py
@@ -309,7 +309,10 @@ class Icon(gtk.Image):
if self._buffer.file_name != self.props.file:
self._buffer.file_name = self.props.file
- width, height = gtk.icon_size_lookup(self.props.icon_size)
+ if self.props.pixel_size == -1:
+ width, height = gtk.icon_size_lookup(self.props.icon_size)
+ else:
+ width = height = self.props.pixel_size
if self._buffer.width != width or self._buffer.height != height:
self._buffer.width = width
self._buffer.height = height
@@ -323,12 +326,6 @@ class Icon(gtk.Image):
def _file_changed_cb(self, image, pspec):
self._buffer.file_name = self.props.file
- def _update_buffer_size(self):
- width, height = gtk.icon_size_lookup(self.props.icon_size)
-
- self._buffer.width = width
- self._buffer.height = height
-
def do_size_request(self, requisition):
self._sync_image_properties()
surface = self._buffer.get_surface()
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar