From 4960ddae252c6b6a41a510b8963d026d9e9b13bc Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 14 Mar 2007 02:19:24 +0000 Subject: Adapt to the new hippo canvas sizing API --- (limited to 'sugar') diff --git a/sugar/graphics/canvasicon.py b/sugar/graphics/canvasicon.py index 26b2357..03b0d2b 100644 --- a/sugar/graphics/canvasicon.py +++ b/sugar/graphics/canvasicon.py @@ -327,11 +327,11 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): def do_get_content_width_request(self): [width, height] = self._get_icon_size() - return width + return (width, width) def do_get_content_height_request(self, for_width): [width, height] = self._get_icon_size() - return height + return (height, height) def do_button_press_event(self, event): self.emit_activated() @@ -373,8 +373,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): [x, y] = context.translate_to_screen(self) # TODO: Any better place to do this? - popup.props.box_width = max(popup.get_width_request(), - self.get_width_request()) + [min_width, natural_width] = self.get_width_request() + popup.props.box_width = max(popup.get_width_request(), min_width) [width, height] = self.get_allocation() y += height diff --git a/sugar/graphics/optionmenu.py b/sugar/graphics/optionmenu.py index 3ffaf4a..197669f 100644 --- a/sugar/graphics/optionmenu.py +++ b/sugar/graphics/optionmenu.py @@ -104,16 +104,6 @@ class OptionMenu(hippo.CanvasBox, hippo.CanvasItem): self._menu.add_item(menu_item) - def do_get_width_request(self): - max_width = max(self._canvas_text.do_get_content_width_request(self._canvas_text), - self._menu.do_get_content_width_request(self._menu)) - - self._canvas_text.props.box_width = max_width - - current_width = hippo.CanvasBox.do_get_width_request(self) - self._menu.props.box_width = current_width - return current_width - def add_separator(self): self._menu.add_separator() diff --git a/sugar/graphics/snowflakebox.py b/sugar/graphics/snowflakebox.py index f0d446c..540b8b0 100644 --- a/sugar/graphics/snowflakebox.py +++ b/sugar/graphics/snowflakebox.py @@ -72,17 +72,15 @@ class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem): max_child_size = 0 for child in self.get_children(): - width = child.get_width_request() - height = child.get_height_request(width) - max_child_size = max (max_child_size, width) - max_child_size = max (max_child_size, height) + [min_w, natural_w] = child.get_width_request() + [min_h, natural_h] = child.get_height_request(width) + max_child_size = max (max_child_size, min_w) + max_child_size = max (max_child_size, min_h) - return self._get_radius() * 2 + \ - max_child_size + _FLAKE_DISTANCE * 2 + width = self._get_radius() * 2 + \ + max_child_size + _FLAKE_DISTANCE * 2 - def do_get_height_request(self, width): - hippo.CanvasBox.do_get_height_request(self, width) - return width + return [width, width] def do_allocate(self, width, height, origin_changed): hippo.CanvasBox.do_allocate(self, width, height, origin_changed) -- cgit v0.9.1