[pygobject] Make row optional in Gtk.TreeStore/ListStore.append override



commit f01a7d9e8222663ce52100e061033f2745a5e7af
Author: Vincent Untz <vuntz gnome org>
Date:   Thu Oct 7 09:42:24 2010 +0200

    Make row optional in Gtk.TreeStore/ListStore.append override
    
    https://bugzilla.gnome.org/show_bug.cgi?id=631548

 gi/overrides/Gtk.py |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 1f6901c..026940d 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -366,16 +366,20 @@ class ListStore(Gtk.ListStore, TreeModel):
         Gtk.ListStore.__init__(self)
         self.set_column_types(column_types)
 
-    def append(self, row):
+    def append(self, row=None):
         treeiter = Gtk.ListStore.append(self)
 
-        n_columns = self.get_n_columns();
-        if len(row) != n_columns:
-            raise ValueError('row sequence has the incorrect number of elements')
+        # TODO: Accept a dictionary for row
+        # model.append(None,{COLUMN_ICON: icon, COLUMN_NAME: name})
 
-        for i in range(n_columns):
-            if row[i] is not None:
-                self.set_value(treeiter, i, row[i])
+        if row is not None:
+            n_columns = self.get_n_columns();
+            if len(row) != n_columns:
+                raise ValueError('row sequence has the incorrect number of elements')
+
+            for i in range(n_columns):
+                if row[i] is not None:
+                    self.set_value(treeiter, i, row[i])
 
         return treeiter
 
@@ -388,17 +392,21 @@ class TreeStore(Gtk.TreeStore, TreeModel):
         Gtk.TreeStore.__init__(self)
         self.set_column_types(column_types)
 
-    def append(self, parent, row):
+    def append(self, parent, row=None):
 
         treeiter = Gtk.TreeStore.append(self, parent)
 
-        n_columns = self.get_n_columns();
-        if len(row) != n_columns:
-            raise ValueError('row sequence has the incorrect number of elements')
+        # TODO: Accept a dictionary for row
+        # model.append(None,{COLUMN_ICON: icon, COLUMN_NAME: name})
+
+        if row is not None:
+            n_columns = self.get_n_columns();
+            if len(row) != n_columns:
+                raise ValueError('row sequence has the incorrect number of elements')
 
-        for i in range(n_columns):
-            if row[i] is not None:
-                self.set_value(treeiter, i, row[i])
+            for i in range(n_columns):
+                if row[i] is not None:
+                    self.set_value(treeiter, i, row[i])
 
         return treeiter
 



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