From b7296805684b1ae8a5f43f0b9076e7d113d237ee Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 18 Dec 2012 12:18:16 -0300 Subject: [PATCH] Truncate labels on Palettes SL #4164 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was lost when PaletteMenuItem was added in 2d0ac2a95219992ac5be003816fdb97ff5f6af6f 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 Acked-by: Manuel QuiƱones --- src/sugar3/graphics/palettemenu.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sugar3/graphics/palettemenu.py b/src/sugar3/graphics/palettemenu.py index 2bf72278..a1af7b19 100644 --- a/src/sugar3/graphics/palettemenu.py +++ b/src/sugar3/graphics/palettemenu.py @@ -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)