[pitivi: 21/41] Properly attach the label to checkbuttons for dynamic ToggleWidgets



commit be03c3e432cdc99fe436525204c813d4992ef908
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Sun Jul 24 23:36:42 2011 -0400

    Properly attach the label to checkbuttons for dynamic ToggleWidgets

 pitivi/ui/prefs.py |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/ui/prefs.py b/pitivi/ui/prefs.py
index 17b1f44..49c05ea 100644
--- a/pitivi/ui/prefs.py
+++ b/pitivi/ui/prefs.py
@@ -261,12 +261,16 @@ class PreferencesDialog():
             prefs = {}
             for attrname in options:
                 label, description, klass, args = options[attrname]
-                label_widget = gtk.Label(_(label) + ":")
                 widget = klass(**args)
                 widget.setWidgetValue(getattr(self.settings, attrname))
                 widget.connectValueChanged(self._valueChanged, widget,
                     attrname)
                 self.widgets[attrname] = widget
+                if isinstance(widget, dynamic.ToggleWidget):
+                    # Don't add a semicolon for checkbuttons
+                    label_widget = gtk.Label(_(label))
+                else:
+                    label_widget = gtk.Label(_(label) + ":")
                 icon = gtk.Image()
                 icon.set_from_stock('gtk-clear', gtk.ICON_SIZE_MENU)
                 revert = gtk.Button()
@@ -284,11 +288,17 @@ class PreferencesDialog():
 
             for y, unlocalized in enumerate(sorted(prefs)):
                 label, widget, revert = prefs[unlocalized]
-                label.set_alignment(1.0, 0.5)
-                widgets.attach(label, 0, 1, y, y + 1, xoptions=gtk.FILL, yoptions=0)
-                widgets.attach(widget, 1, 2, y, y + 1, yoptions=0)
-                widgets.attach(revert, 2, 3, y, y + 1, xoptions=0, yoptions=0)
-                label.show()
+                if isinstance(widget, dynamic.ToggleWidget):
+                    # Avoid the separating the label from the checkbox
+                    widget.set_label(label.get_text())
+                    widgets.attach(widget, 0, 2, y, y + 1, yoptions=0)
+                    widgets.attach(revert, 2, 3, y, y + 1, xoptions=0, yoptions=0)
+                else:
+                    label.set_alignment(1.0, 0.5)
+                    widgets.attach(label, 0, 1, y, y + 1, xoptions=gtk.FILL, yoptions=0)
+                    widgets.attach(widget, 1, 2, y, y + 1, yoptions=0)
+                    widgets.attach(revert, 2, 3, y, y + 1, xoptions=0, yoptions=0)
+                    label.show()
                 widget.show()
                 revert.show()
 



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