diff options
author | Dan Williams <dcbw@localhost.localdomain> | 2006-09-25 19:20:08 (GMT) |
---|---|---|
committer | Dan Williams <dcbw@localhost.localdomain> | 2006-09-25 19:20:08 (GMT) |
commit | d585a251bdf11f5cd5af8a694f5790adf7f3cc48 (patch) | |
tree | 0711c96088d411a8f96193cd87b2ee61c225794f | |
parent | a8322a76eb4857bb8fd376e7f898d641c41d4ede (diff) |
Do simple height-flow layout on menu items, and add an add_image() function
-rw-r--r-- | sugar/canvas/Menu.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/sugar/canvas/Menu.py b/sugar/canvas/Menu.py index c4cb7c5..854d59a 100644 --- a/sugar/canvas/Menu.py +++ b/sugar/canvas/Menu.py @@ -16,6 +16,7 @@ class Menu(gtk.Window): gtk.Window.__init__(self, gtk.WINDOW_POPUP) self._width = 15 + self._height = 0 self._grid = grid self._action_box = None @@ -31,10 +32,10 @@ class Menu(gtk.Window): text = goocanvas.Text(text=title, font="Sans bold 18", fill_color='white', anchor=gtk.ANCHOR_SW) - self._grid.set_constraints(text, 1, 3, self._width, 2) + self._grid.set_constraints(text, 1, 3, self._width, self._height) self._root.add_child(text) + self._height += 1 - self._height = 4 self._update_constraints() self._canvas.set_model(model) @@ -42,23 +43,36 @@ class Menu(gtk.Window): def _create_action_box(self): separator = goocanvas.Path(data='M 15 0 L 215 0', line_width=3, stroke_color='white') - self._grid.set_constraints(separator, 0, 4) + self._grid.set_constraints(separator, 0, self._height) self._root.add_child(separator) + self._height += 1 box = CanvasBox(self._grid, CanvasBox.HORIZONTAL) - self._grid.set_constraints(box, 0, 5) + self._grid.set_constraints(box, 0, self._height) + self._height += 5 return box def get_grid(self): return self._grid + def add_image(self, image_item, width, height): + """width & height in grid units""" + separator = goocanvas.Path(data='M 15 0 L 215 0', line_width=3, + stroke_color='white') + self._grid.set_constraints(separator, 0, self._height) + self._root.add_child(separator) + self._height += 1 + + self._grid.set_constraints(image_item, x=5, y=self._height, width=width, height=height) + self._root.add_child(image_item) + self._height += height + self._update_constraints() + def add_action(self, icon, action_id): if self._action_box == None: self._action_box = self._create_action_box() self._root.add_child(self._action_box) - - self._height = 10 self._update_constraints() icon.connect('clicked', self._action_clicked_cb, action_id) |