From e46adf159eb482a22f5d6280b624020e13ba072f Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Tue, 18 Dec 2012 12:18:16 -0300
Subject: [PATCH sugar] 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>
---
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 2bf7227..a1af7b1 100644
a
|
b
|
import logging |
18 | 18 | |
19 | 19 | from gi.repository import GObject |
20 | 20 | from gi.repository import Gtk |
| 21 | from gi.repository import Pango |
21 | 22 | |
22 | 23 | from sugar3.graphics.icon import Icon |
23 | 24 | from sugar3.graphics import style |
… |
… |
class PaletteMenuItem(Gtk.EventBox): |
114 | 115 | |
115 | 116 | align = Gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0) |
116 | 117 | self.label = Gtk.Label(text_label) |
| 118 | if text_maxlen > 0: |
| 119 | self.label.set_max_width_chars(text_maxlen) |
| 120 | self.label.set_ellipsize(Pango.EllipsizeMode.MIDDLE) |
117 | 121 | align.add(self.label) |
118 | 122 | self._hbox.pack_start(align, expand=True, fill=True, |
119 | 123 | padding=style.DEFAULT_PADDING) |