Ticket #610: palette-width.patch

File palette-width.patch, 1.6 KB (added by benzea, 12 years ago)

patch implementing the suggestion

  • src/sugar/graphics/palette.py

    diff --git a/src/sugar/graphics/palette.py b/src/sugar/graphics/palette.py
    index 919721b..41c4d28 100644
    a b class Palette(gtk.Window): 
    145145    # DEPRECATED: label is passed with the primary-text property, accel_path
    146146    # is set via the invoker property, and menu_after_content is not used
    147147    def __init__(self, label=None, accel_path=None, menu_after_content=False,
    148                  text_maxlen=0, **kwargs):
     148                 text_maxlen=999, **kwargs):
    149149
    150150        self.palette_state = self.PRIMARY
    151151
    class Palette(gtk.Window): 
    178178        self._label = gtk.AccelLabel('')
    179179        self._label.set_alignment(0, 0.5)
    180180
     181        # The text_maxlen parameter defaults to 999. The reason for this is
     182        # that the label will then request the correct size, while at the same
     183        # time being able tel ellipsize correctly. Not setting maxlen would
     184        # mean that the label requests a very small area, and the palette would
     185        # not be wide enough.
     186        # The size of the palette is clamped in do_size_request.
    181187        if text_maxlen > 0:
    182188            self._label.set_max_width_chars(text_maxlen)
    183189            self._label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
    class Palette(gtk.Window): 
    467473                                label_width,
    468474                                self._full_request[0])
    469475
     476        screen = self.get_screen()
     477        screen_width = screen.get_width()
     478        # Maximum width is two third of the screens width
     479        requisition.width = min(requisition.width, screen_width * 2 / 3)
     480
    470481    def do_size_allocate(self, allocation):
    471482        gtk.Window.do_size_allocate(self, allocation)
    472483