diff options
author | Simon Schampijer <simon@schampijer.de> | 2012-04-18 20:29:15 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2012-04-19 16:37:15 (GMT) |
commit | 7a07bb10015e80fd34164da0d66ec54700df96df (patch) | |
tree | b91d97ead80a02b2bc0308bcb916580b3d5f7e42 | |
parent | 16040b2f30b266c4b1e6833b1563e58096745fed (diff) |
Draw accelerator in Palette SL #3459
The accelerator in the primary information in the Palette
has not been drawn because there was not enough space
reserved for it. The preferred size we get back for the
Palette window does not include the accelerator of the
Gtk.AccelLabel. We need to include that in our calculation for
the Palette size.
In order to make that information available which is part
of the Palette class we need to pass the instance to the
PaletteWindowWidget instance.
Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Daniel Drake <dsd@laptop.org>
-rw-r--r-- | src/sugar3/graphics/palette.py | 15 | ||||
-rw-r--r-- | src/sugar3/graphics/palettewindow.py | 14 |
2 files changed, 13 insertions, 16 deletions
diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py index 1f95c11..4bb72ce 100644 --- a/src/sugar3/graphics/palette.py +++ b/src/sugar3/graphics/palette.py @@ -301,7 +301,7 @@ class Palette(PaletteWindow): or isinstance(self._widget, _PaletteWindowWidget) if self._widget is None: - self._widget = _PaletteWindowWidget() + self._widget = _PaletteWindowWidget(self) self._setup_widget() self._palette_box = Gtk.VBox() @@ -327,16 +327,11 @@ class Palette(PaletteWindow): self._update_accept_focus() self._update_separators() - def do_get_preferred_width(self): - minimum, natural = PaletteWindow.do_get_preferred_width(self) - + def get_label_width(self): # Gtk.AccelLabel request doesn't include the accelerator. - label_width = self._label_alignment.size_request()[0] + \ - self._label.get_accel_width() + \ - 2 * self.get_border_width() - - width = max(minimum, label_width, self._full_request[0]) - return width, width + label_width = self._label_alignment.get_preferred_width()[1] + \ + self._label.get_accel_width() + return label_width def _update_separators(self): visible = self._content.get_children() diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py index 47236ef..449f550 100644 --- a/src/sugar3/graphics/palettewindow.py +++ b/src/sugar3/graphics/palettewindow.py @@ -239,9 +239,10 @@ class _PaletteWindowWidget(Gtk.Window): 'leave-notify': (GObject.SignalFlags.RUN_FIRST, None, ([])), } - def __init__(self): + def __init__(self, palette=None): Gtk.Window.__init__(self) + self._palette = palette self.set_decorated(False) self.set_resizable(False) self.set_position(Gtk.WindowPosition.NONE) @@ -270,11 +271,12 @@ class _PaletteWindowWidget(Gtk.Window): self.set_type_hint(Gdk.WindowTypeHint.DIALOG) def do_get_preferred_width(self): - size = 0 - child = self.get_child() - if child: - minimum_size, natural_size = child.get_preferred_width() - size = max(minimum_size, natural_size, style.GRID_CELL_SIZE * 2) + minimum, natural = Gtk.Window.do_get_preferred_width(self) + label_width = 0 + if self._palette is not None: + label_width = self._palette.get_label_width() + size = max(natural, label_width + 2 * self.get_border_width(), + style.GRID_CELL_SIZE * 2) return size, size def do_size_allocate(self, allocation): |