[POS-commit] r5322 - in kiwi/trunk: .

Johan Dahlin jdahlin at async.com.br
Thu Nov 2 21:15:46 BRT 2006


Author: jdahlin
Date: Thu Nov  2 21:15:45 2006
New Revision: 5322

Modified:
   kiwi/trunk/ChangeLog
   kiwi/trunk/kiwi/ui/objectlist.py

Log:
	* kiwi/ui/objectlist.py (ObjectTree._append_internal): Allow
	specify parents which are objects inserted in the tree.



Modified: kiwi/trunk/ChangeLog
==============================================================================
--- kiwi/trunk/ChangeLog	(original)
+++ kiwi/trunk/ChangeLog	Thu Nov  2 21:15:45 2006
@@ -1,3 +1,8 @@
+2006-11-02  Johan Dahlin  <jdahlin at async.com.br>
+
+	* kiwi/ui/objectlist.py (ObjectTree._append_internal): Allow
+	specify parents which are objects inserted in the tree.
+
 2006-10-29  Johan Dahlin  <johan at gnome.org>
 
 	* kiwi/datatypes.py:

Modified: kiwi/trunk/kiwi/ui/objectlist.py
==============================================================================
--- kiwi/trunk/kiwi/ui/objectlist.py	(original)
+++ kiwi/trunk/kiwi/ui/objectlist.py	Thu Nov  2 21:15:45 2006
@@ -1611,17 +1611,20 @@
         ObjectList.__init__(self, columns, objects, mode, sortable, model)
 
     def _append_internal(self, parent, instance, select, prepend):
-        if parent is not None and not isinstance(parent, ObjectRow):
-            raise TypeError("parent must be an ObjectRow or None")
+        iters = self._iters
+        parent_id = id(parent)
+        if isinstance(parent, ObjectRow):
+            parent_iter = parent.iter
+        elif parent_id in iters:
+            parent_iter = iters[parent_id]
+        elif parent is None:
+            parent_iter = None
+        else:
+            raise TypeError("parent must be an Object, ObjectRow or None")
 
         # Freeze and save original selection mode to avoid blinking
         self._treeview.freeze_notify()
 
-        if parent:
-            parent_iter = parent.iter
-        else:
-            parent_iter = None
-
         if prepend:
             row_iter = self._model.prepend(parent_iter, (instance,))
         else:
@@ -1640,7 +1643,7 @@
 
     def append(self, parent, instance, select=False):
         """
-        @param parent: ObjectRow of the parent
+        @param parent: Object, ObjectRow or None, representing the parent
         @param instance: the instance to be added
         @param select: select the row
         """
@@ -1648,7 +1651,7 @@
 
     def prepend(self, parent, instance, select=False):
         """
-        @param parent: ObjectRow of the parent
+        @param parent: Object, ObjectRow or None, representing the parent
         @param instance: the instance to be added
         @param select: select the row
         """


More information about the POS-commit mailing list