conduit r1905 - in trunk: . conduit/gtkui conduit/modules conduit/modules/RhythmboxModule



Author: arosenfeld
Date: Tue Feb 24 05:35:44 2009
New Revision: 1905
URL: http://svn.gnome.org/viewvc/conduit?rev=1905&view=rev

Log:
2009-02-24  Alexandre Rosenfeld  <airmind gmail com>

	* conduit/gtkui/ConfigItems.py:
	Fixed a bug in list where instead of values, the labels
	were being returned as the values
	* conduit/modules/TestModule.py:
	Reflect list item changes
	
	* conduit/modules/RhythmboxModule/RhythmboxModule.py:
	Removed comment


Modified:
   trunk/ChangeLog
   trunk/conduit/gtkui/ConfigItems.py
   trunk/conduit/modules/RhythmboxModule/RhythmboxModule.py
   trunk/conduit/modules/TestModule.py

Modified: trunk/conduit/gtkui/ConfigItems.py
==============================================================================
--- trunk/conduit/gtkui/ConfigItems.py	(original)
+++ trunk/conduit/gtkui/ConfigItems.py	Tue Feb 24 05:35:44 2009
@@ -626,27 +626,30 @@
 class ConfigList(ItemBase):
     __item_name__ = 'list'
     
+    CHECKED_COLUMN, LABEL_COLUMN, VALUE_COLUMN = range(3)
+    
     def __init__(self, *args, **kwargs):
         ItemBase.__init__(self, *args, **kwargs)
         self.needs_label = kwargs.get('needs_label', False)
         if self.initial_value:
-            #FIXME: Sorted should be optional
             try:
                 self.initial_value = sorted(self.initial_value)
             except TypeError:
                 raise Error("List only supports iterables as value (%s is not)" % (self.initial_value))
         self.fill = kwargs.get('fill', True)
         self._checked_items = None
-        self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
+        self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, object)
     
     def _cellcheck_cb(self, cell, path, model):
-        model[path][1] = not cell.get_active()
+        model[path][self.CHECKED_COLUMN] = not cell.get_active()
+        #FIXME: Use _checked_items here too, so it's faster to get the values
+        #But we should take care that this list must be always sorted
         self._checked_items = None        
         self._value_changed()
     
     def _build_choices(self):
-        for label in self._get_choices_labels():
-            self.model.append((str(label), False))
+        for value, label in self._get_choices_all():
+            self.model.append((False, str(label), value))
 
     def _clear_choices(self):
         self.model.clear()
@@ -673,8 +676,8 @@
         #FIXME: We could probably support more columns, maybe by automatically
         # detecting if choices include tuples, and which types are inside the 
         # tuple.
-        self.list.append_column(gtk.TreeViewColumn("Enabled", check_renderer, active = 1))
-        self.list.append_column(gtk.TreeViewColumn("Label", gtk.CellRendererText(), text = 0))
+        self.list.append_column(gtk.TreeViewColumn("Enabled", check_renderer, active = self.CHECKED_COLUMN))
+        self.list.append_column(gtk.TreeViewColumn("Label", gtk.CellRendererText(), text = self.LABEL_COLUMN))
         self._clear_choices()  
         self._build_choices()
         self.scrolled_window.add(self.list)
@@ -686,17 +689,17 @@
     
     def _get_value(self):
         if not self._checked_items:
-            self._checked_items = sorted([row[0] for row in self.model if row[1]])
-            self._update_total()
+            self._checked_items = sorted([row[self.VALUE_COLUMN] for row in self.model if row[self.CHECKED_COLUMN]])
+            #self._update_total()
         return self._checked_items
     
     def _set_value(self, value):
         self._checked_items = []
         try:
             for row in self.model:
-                row[1] = (row[0] in value)
-                if row[1]:
-                    self._checked_items.append(row[0])
+                row[self.CHECKED_COLUMN] = (row[self.VALUE_COLUMN] in value)
+                if row[self.CHECKED_COLUMN]:
+                    self._checked_items.append(row[self.VALUE_COLUMN])
         except:
             log.warn("Value %s could not be added to list %s" % (value, repr(self.title)))
         self._update_total()

Modified: trunk/conduit/modules/RhythmboxModule/RhythmboxModule.py
==============================================================================
--- trunk/conduit/modules/RhythmboxModule/RhythmboxModule.py	(original)
+++ trunk/conduit/modules/RhythmboxModule/RhythmboxModule.py	Tue Feb 24 05:35:44 2009
@@ -86,11 +86,9 @@
                             temp_name = value
 
                 if is_static: # new playlist found
-                    #print name,value,temp_name
                     playlist_name = temp_name
                     songs = []
                     playlists.append( [playlist_name, songs] )
-                    
 
             #Text that precedes all child elements (may be None)
             if element.text:

Modified: trunk/conduit/modules/TestModule.py
==============================================================================
--- trunk/conduit/modules/TestModule.py	(original)
+++ trunk/conduit/modules/TestModule.py	Tue Feb 24 05:35:44 2009
@@ -168,7 +168,7 @@
             config_name = "items",
             # The actual value returned from this list would be either True or
             # False, but their text would be tst and tst2 respectively
-            choices = [(True,"tst"), (False,"tst2")],
+            choices = [(1, "Item with value 1"), (2,"Item with value 2"), 3],
         )
         config.add_item("Password", "text",
             config_name = "password",



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