~vcs-imports/kupfer/master-new

« back to all changes in this revision

Viewing changes to kupfer/ui/preferences.py

  • Committer: Ulrik Sverdrup
  • Date: 2010-04-01 13:52:46 UTC
  • Revision ID: git-v1:0175791f869472233d9c7b48a03709233576e4f8
preferences: Use a maximum label width

We try to get rid of the constant resizing of the window when browsing
the plugin list. However GtkLabel's wrapping supports seems rather
mediocre, and it does not work perfectly yet (but much better).

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
# A major HACK
20
20
# http://tadeboro.blogspot.com/2009/05/wrapping-adn-resizing-gtklabel.html
21
 
def _cb_allocate(label, allocation):
22
 
        label.set_size_request(allocation.width, -1)
 
21
def _cb_allocate(label, allocation, maxwid):
 
22
        if maxwid == -1:
 
23
                maxwid = 300
 
24
        label.set_size_request(min(maxwid, allocation.width), -1)
 
25
        pass
23
26
 
24
 
def wrapped_label(text=None):
 
27
def wrapped_label(text=None, maxwid=-1):
25
28
        label = gtk.Label(text)
26
29
        label.set_line_wrap(True)
27
 
        label.connect("size-allocate", _cb_allocate)
 
30
        label.connect("size-allocate", _cb_allocate, maxwid)
28
31
        return label
29
32
 
30
33
class PreferencesWindowController (pretty.OutputMixin):
568
571
                                vbox.pack_start(hbox, False)
569
572
                                continue
570
573
 
571
 
                        label_wid = wrapped_label(label)
 
574
                        label_wid = wrapped_label(label, maxwid=200)
572
575
                        if issubclass(typ, basestring):
573
576
                                if alternatives:
574
577
                                        wid = gtk.combo_box_new_text()
604
607
                                wid.set_increments(1, 1)
605
608
                                wid.set_range(0, 1000)
606
609
                                wid.set_value(plugin_settings[setting])
607
 
                                hbox.pack_start(label_wid, False, True)
 
610
                                hbox.pack_start(label_wid, False)
608
611
                                hbox.pack_start(wid, False)
609
612
                                wid.connect("changed", self._get_plugin_change_callback(
610
613
                                        plugin_id, setting, typ, "get_text", no_false_values=True))