Support for ellipsis in palette texts, #4562/#5765
This commit is contained in:
parent
986420ddf0
commit
6760357423
@ -18,11 +18,16 @@
|
|||||||
import gtk
|
import gtk
|
||||||
from sugar.graphics.icon import Icon
|
from sugar.graphics.icon import Icon
|
||||||
|
|
||||||
|
import pango
|
||||||
|
|
||||||
class MenuItem(gtk.ImageMenuItem):
|
class MenuItem(gtk.ImageMenuItem):
|
||||||
def __init__(self, text_label=None, icon_name=None):
|
def __init__(self, text_label=None, icon_name=None, text_maxlen=0):
|
||||||
gtk.ImageMenuItem.__init__(self, text_label)
|
gtk.ImageMenuItem.__init__(self, text_label)
|
||||||
if icon_name:
|
if icon_name:
|
||||||
icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_MENU)
|
icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_MENU)
|
||||||
self.set_image(icon)
|
self.set_image(icon)
|
||||||
icon.show()
|
icon.show()
|
||||||
|
|
||||||
|
if text_maxlen > 0:
|
||||||
|
self.child.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
|
||||||
|
self.child.set_max_width_chars(text_maxlen)
|
||||||
|
@ -21,6 +21,7 @@ import gtk
|
|||||||
import gobject
|
import gobject
|
||||||
import time
|
import time
|
||||||
import hippo
|
import hippo
|
||||||
|
import pango
|
||||||
|
|
||||||
from sugar.graphics import palettegroup
|
from sugar.graphics import palettegroup
|
||||||
from sugar.graphics import animator
|
from sugar.graphics import animator
|
||||||
@ -140,7 +141,8 @@ class Palette(gtk.Window):
|
|||||||
gobject.TYPE_NONE, ([]))
|
gobject.TYPE_NONE, ([]))
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, label, accel_path=None, menu_after_content=False):
|
def __init__(self, label, accel_path=None, menu_after_content=False,
|
||||||
|
text_maxlen=0):
|
||||||
gtk.Window.__init__(self)
|
gtk.Window.__init__(self)
|
||||||
|
|
||||||
self.set_decorated(False)
|
self.set_decorated(False)
|
||||||
@ -178,6 +180,11 @@ class Palette(gtk.Window):
|
|||||||
- 2*self.get_border_width())
|
- 2*self.get_border_width())
|
||||||
self._label.set_alignment(0, 0.5)
|
self._label.set_alignment(0, 0.5)
|
||||||
self._label.set_padding(style.DEFAULT_SPACING, 0)
|
self._label.set_padding(style.DEFAULT_SPACING, 0)
|
||||||
|
|
||||||
|
if text_maxlen > 0:
|
||||||
|
self._label.set_max_width_chars(text_maxlen)
|
||||||
|
self._label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
|
||||||
|
|
||||||
vbox.pack_start(self._label, False)
|
vbox.pack_start(self._label, False)
|
||||||
|
|
||||||
self._secondary_box = gtk.VBox()
|
self._secondary_box = gtk.VBox()
|
||||||
|
Loading…
Reference in New Issue
Block a user