diff options
author | Benjamin Berg <benjamin@sipsolutions.net> | 2011-10-30 11:20:41 (GMT) |
---|---|---|
committer | Sascha Silbe <silbe@activitycentral.com> | 2011-12-05 23:03:29 (GMT) |
commit | 06692ed23d4063371347a7b70c21a7c91cfb8161 (patch) | |
tree | bd2f8fe3d5855df5fce2cfbec55955658fd326d9 | |
parent | 4096858700118478109a29ef60c6d48fb2bd656f (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.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py index 01ed7cf..3d12290 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() |