[pitivi] ui/dynamic.py: add method to change choices in a ChoiceWidget



commit 0ef54fe1c6458f8f300f0aec62a0f5a519bc40c6
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Tue Apr 13 11:31:42 2010 -0700

    ui/dynamic.py: add method to change choices in a ChoiceWidget

 pitivi/ui/dynamic.py |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/ui/dynamic.py b/pitivi/ui/dynamic.py
index b02e3d1..f2a8454 100644
--- a/pitivi/ui/dynamic.py
+++ b/pitivi/ui/dynamic.py
@@ -289,11 +289,8 @@ class ChoiceWidget(gtk.HBox):
         self.choices = [choice[0] for choice in choices]
         self.values = [choice[1] for choice in choices]
         self.contents = gtk.combo_box_new_text()
-        for choice, value in choices:
-            self.contents.append_text(_(choice))
-        if len(choices) <= 1:
-            self.contents.set_sensitive(False)
         self.pack_start(self.contents)
+        self.setChoices(choices)
         self.contents.show()
         cell = self.contents.get_cells()[0]
         cell.props.ellipsize = pango.ELLIPSIZE_END
@@ -307,6 +304,16 @@ class ChoiceWidget(gtk.HBox):
     def getWidgetValue(self):
         return self.values[self.contents.get_active()]
 
+    def setChoices(self, choices):
+        m = gtk.ListStore(str)
+        self.contents.set_model(m)
+        for choice, value in choices:
+            self.contents.append_text(_(choice))
+        if len(choices) <= 1:
+            self.contents.set_sensitive(False)
+        else:
+            self.contents.set_sensitive(True)
+
 class PresetChoiceWidget(gtk.HBox):
 
     """A popup which manages preset settings on a group of widgets supporting



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