Truncate labels on Palettes SL #4164

This was lost when PaletteMenuItem was added in
2d0ac2a952 of sugar source code.

That class does not handle the text_maxlen argument (default to 60). I
used this argument to set the Gtk.Label's size:
label.set_max_width_chars and use MIDDLE for its EllipSizeMode as
sugar3.graphics.palette.Palette does for its title and subtitle.

With these settings, the title of the palette and its items share the
same behaviour and are rendered with the same width.

Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Acked-by: Manuel Quiñones <manuq@laptop.org>
master
Manuel Kaufmann 12 years ago committed by Manuel Quiñones
parent 8357ccc4ea
commit b729680568

@ -18,6 +18,7 @@ import logging
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Pango
from sugar3.graphics.icon import Icon
from sugar3.graphics import style
@ -114,6 +115,9 @@ class PaletteMenuItem(Gtk.EventBox):
align = Gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
self.label = Gtk.Label(text_label)
if text_maxlen > 0:
self.label.set_max_width_chars(text_maxlen)
self.label.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
align.add(self.label)
self._hbox.pack_start(align, expand=True, fill=True,
padding=style.DEFAULT_PADDING)

Loading…
Cancel
Save