Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2012-12-18 15:18:16 (GMT)
committer Manuel QuiƱones <manuq@laptop.org>2013-01-03 16:37:11 (GMT)
commitb7296805684b1ae8a5f43f0b9076e7d113d237ee (patch)
tree83da8f721de2569710b8ba8f57ceca6d76054a10
parent8357ccc4eac4c18aa838abbcbe85459bf6725b00 (diff)
Truncate labels on Palettes SL #4164
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 <humitos@gmail.com> Acked-by: Manuel QuiƱones <manuq@laptop.org>
-rw-r--r--src/sugar3/graphics/palettemenu.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/sugar3/graphics/palettemenu.py b/src/sugar3/graphics/palettemenu.py
index 2bf7227..a1af7b1 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)