Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Berg <benjamin@sipsolutions.net>2011-10-30 11:20:41 (GMT)
committer Sascha Silbe <silbe@activitycentral.com>2011-11-22 12:28:56 (GMT)
commit6dc96bb7b4aafd3ef13e9eca4d433a1bc2e0e82b (patch)
tree5e9a5f668715e4d54e9d61be9dce02d0791f7f23
parentbe2fcc9a5529f72a992e239e506b08fac40ae7bc (diff)
Icon: port to new Height-for-width Geometry Management
GTK3 has replaced [1] the GTK2 geometry management with Height-for-width Geometry Management [2]. This means we need to replace size_request() methods with get_preferred_{width,height}(). [1] http://developer.gnome.org/gtk3/3.0/ch25s02.html#id1525688 [2] http://developer.gnome.org/gtk3/3.0/GtkWidget.html#geometry-management [assembled from several patches; fixed up left-over plus sign; added description] Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
-rw-r--r--src/sugar3/graphics/icon.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
index 76af718..2a56523 100644
--- a/src/sugar3/graphics/icon.py
+++ b/src/sugar3/graphics/icon.py
@@ -362,27 +362,27 @@ class Icon(Gtk.Image):
def _file_changed_cb(self, image, pspec):
self._buffer.file_name = self.props.file
- def do_size_request(self, requisition):
- """
- Parameters
- ----------
- requisition :
-
- Returns
- -------
- None
+ def do_get_preferred_height(self):
+ self._sync_image_properties()
+ surface = self._buffer.get_surface()
+ if surface:
+ height = surface.get_height()
+ elif self._buffer.height:
+ height = self._buffer.height
+ else:
+ height = 0
+ return (height, height)
- """
+ def do_get_preferred_width(self):
self._sync_image_properties()
surface = self._buffer.get_surface()
if surface:
- requisition[0] = surface.get_width()
- requisition[1] = surface.get_height()
- elif self._buffer.width and self._buffer.height:
- requisition[0] = self._buffer.width
- requisition[1] = self._buffer.width
+ width = surface.get_width()
+ elif self._buffer.width:
+ width = self._buffer.width
else:
- requisition[0] = requisition[1] = 0
+ width = 0
+ return (width, width)
def do_expose_event(self, event):
"""
@@ -408,9 +408,9 @@ class Icon(Gtk.Image):
xalign = 1.0 - xalign
allocation = self.get_allocation()
- x = math.floor(allocation.x + xpad +
+ x = math.floor(xpad +
(allocation.width - requisition.width) * xalign)
- y = math.floor(allocation.y + ypad +
+ y = math.floor(ypad +
(allocation.height - requisition.height) * yalign)
cr = self.get_window().cairo_create()