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>
This commit is contained in:
Simon Schampijer 2012-04-18 22:29:15 +02:00
parent 16040b2f30
commit 7a07bb1001
2 changed files with 13 additions and 16 deletions

View File

@ -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()

View File

@ -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):