Ticket #4164: 0001-Truncate-labels-on-Palettes-SL-4164.patch

File 0001-Truncate-labels-on-Palettes-SL-4164.patch, 1.7 KB (added by humitos, 11 years ago)
  • src/sugar3/graphics/palettemenu.py

    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 
    1818
    1919from gi.repository import GObject
    2020from gi.repository import Gtk
     21from gi.repository import Pango
    2122
    2223from sugar3.graphics.icon import Icon
    2324from sugar3.graphics import style
    class PaletteMenuItem(Gtk.EventBox): 
    114115
    115116        align = Gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
    116117        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)
    117121        align.add(self.label)
    118122        self._hbox.pack_start(align, expand=True, fill=True,
    119123                        padding=style.DEFAULT_PADDING)