[kupfer] preferences: Use a maximum label width



commit 0175791f869472233d9c7b48a03709233576e4f8
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Apr 1 15:47:43 2010 +0200

    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).

 data/preferences.ui      |    1 +
 kupfer/ui/preferences.py |   15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/data/preferences.ui b/data/preferences.ui
index 846973a..5ef7da2 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -441,6 +441,7 @@
                     </child>
                     <child>
                       <object class="GtkScrolledWindow" id="plugin_about_parent">
+                        <property name="width_request">320</property>
                         <property name="can_focus">True</property>
                         <property name="hscrollbar_policy">never</property>
                         <property name="vscrollbar_policy">never</property>
diff --git a/kupfer/ui/preferences.py b/kupfer/ui/preferences.py
index 7b798ec..5d423b9 100644
--- a/kupfer/ui/preferences.py
+++ b/kupfer/ui/preferences.py
@@ -18,13 +18,16 @@ from kupfer.ui import getkey_dialog
 
 # A major HACK
 # http://tadeboro.blogspot.com/2009/05/wrapping-adn-resizing-gtklabel.html
-def _cb_allocate(label, allocation):
-	label.set_size_request(allocation.width, -1)
+def _cb_allocate(label, allocation, maxwid):
+	if maxwid == -1:
+		maxwid = 300
+	label.set_size_request(min(maxwid, allocation.width), -1)
+	pass
 
-def wrapped_label(text=None):
+def wrapped_label(text=None, maxwid=-1):
 	label = gtk.Label(text)
 	label.set_line_wrap(True)
-	label.connect("size-allocate", _cb_allocate)
+	label.connect("size-allocate", _cb_allocate, maxwid)
 	return label
 
 class PreferencesWindowController (pretty.OutputMixin):
@@ -568,7 +571,7 @@ class PreferencesWindowController (pretty.OutputMixin):
 				vbox.pack_start(hbox, False)
 				continue
 
-			label_wid = wrapped_label(label)
+			label_wid = wrapped_label(label, maxwid=200)
 			if issubclass(typ, basestring):
 				if alternatives:
 					wid = gtk.combo_box_new_text()
@@ -604,7 +607,7 @@ class PreferencesWindowController (pretty.OutputMixin):
 				wid.set_increments(1, 1)
 				wid.set_range(0, 1000)
 				wid.set_value(plugin_settings[setting])
-				hbox.pack_start(label_wid, False, True)
+				hbox.pack_start(label_wid, False)
 				hbox.pack_start(wid, False)
 				wid.connect("changed", self._get_plugin_change_callback(
 					plugin_id, setting, typ, "get_text", no_false_values=True))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]