From c0a95e45a515927d14ee10547045e52c1c62df85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Thu, 1 Nov 2012 17:45:37 -0300
Subject: [PATCH toolkit-gtk3 2/2] Set correct padding and size for the
palette, window implementation - SL #4144
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
Palette width: make it a minimun size of 4 Sugar grid cells.
Padding of content, secondary box: we need top and bottom padding,
which can be set when packing the items container inside the secondary
box.
Padding of menu items: needs to be just for left and right, so move
the padding to a new horizontal box.
Padding of separators: unlike GtkSeparatorMenuItem, GtkSeparator
doesn't support padding. But we can wrap it in a GtkEventBox and
force the height of the widget there.
Add PaletteMenuItemCustom class for usage in Palette implementations.
Instead of adding widgets to the content directly, pack them inside
this and get the correct padding.
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
src/sugar3/graphics/palette.py | 4 ++--
src/sugar3/graphics/palettemenuitem.py | 27 ++++++++++++++++++++++-----
src/sugar3/graphics/palettewindow.py | 2 +-
3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
index efdc9fd..0e49e35 100644
a
|
b
|
class Palette(PaletteWindow): |
230 | 230 | def _add_content(self): |
231 | 231 | # The content is not shown until a widget is added |
232 | 232 | self._content = Gtk.VBox() |
233 | | self._content.set_border_width(style.DEFAULT_SPACING) |
234 | | self._secondary_box.pack_start(self._content, True, True, 0) |
| 233 | self._secondary_box.pack_start(self._content, True, True, |
| 234 | style.DEFAULT_SPACING) |
235 | 235 | |
236 | 236 | def _update_accel_widget(self): |
237 | 237 | assert self.props.invoker is not None |
diff --git a/src/sugar3/graphics/palettemenuitem.py b/src/sugar3/graphics/palettemenuitem.py
index 7861a0b..e6e3d5b 100644
a
|
b
|
from sugar3.graphics.icon import Icon |
23 | 23 | from sugar3.graphics import style |
24 | 24 | |
25 | 25 | |
26 | | class PaletteMenuItemSeparator(Gtk.HSeparator): |
27 | | """A HSeparator that can be styled in the theme""" |
| 26 | class PaletteMenuItemSeparator(Gtk.EventBox): |
| 27 | """Contains a HSeparator and has the proper height for the menu.""" |
28 | 28 | |
29 | 29 | __gtype_name__ = 'SugarPaletteMenuItemSeparator' |
30 | 30 | |
31 | 31 | def __init__(self): |
32 | | Gtk.HSeparator.__init__(self) |
| 32 | Gtk.EventBox.__init__(self) |
| 33 | separator = Gtk.HSeparator() |
| 34 | self.add(separator) |
| 35 | separator.show() |
| 36 | self.set_size_request(-1, style.DEFAULT_SPACING * 2) |
| 37 | |
| 38 | |
| 39 | class PaletteMenuItemCustom(Gtk.HBox): |
| 40 | def __init__(self): |
| 41 | Gtk.HBox.__init__(self) |
| 42 | |
| 43 | def add(self, widget): |
| 44 | self.pack_start(widget, True, True, style.DEFAULT_SPACING) |
33 | 45 | |
34 | 46 | |
35 | 47 | class PaletteMenuItem(Gtk.EventBox): |
… |
… |
class PaletteMenuItem(Gtk.EventBox): |
47 | 59 | self.icon = None |
48 | 60 | |
49 | 61 | vbox = Gtk.VBox() |
50 | | vbox.set_border_width(style.DEFAULT_PADDING) |
51 | 62 | self._hbox = Gtk.HBox() |
52 | 63 | if icon_name is not None: |
53 | 64 | self.icon = Icon(icon_name=icon_name, |
… |
… |
class PaletteMenuItem(Gtk.EventBox): |
69 | 80 | align.add(self.label) |
70 | 81 | self._hbox.pack_start(align, expand=True, fill=True, |
71 | 82 | padding=style.DEFAULT_PADDING) |
72 | | vbox.pack_start(self._hbox, expand=False, fill=False, |
| 83 | |
| 84 | # This box is just for setting left and right padding. |
| 85 | inner_hbox = Gtk.HBox() |
| 86 | inner_hbox.pack_start(self._hbox, False, False, |
| 87 | padding=style.DEFAULT_PADDING) |
| 88 | |
| 89 | vbox.pack_start(inner_hbox, expand=False, fill=False, |
73 | 90 | padding=style.DEFAULT_PADDING) |
74 | 91 | self.add(vbox) |
75 | 92 | |
diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
index 6e33efe..d9bb517 100644
a
|
b
|
class _PaletteWindowWidget(Gtk.Window): |
282 | 282 | if self._palette is not None: |
283 | 283 | label_width = self._palette.get_label_width() |
284 | 284 | size = max(natural, label_width + 2 * self.get_border_width(), |
285 | | style.GRID_CELL_SIZE * 2) |
| 285 | style.GRID_CELL_SIZE * 4) |
286 | 286 | return size, size |
287 | 287 | |
288 | 288 | def do_size_allocate(self, allocation): |