[POS-commit] CVS: Kiwi/Kiwi Delegates.py,1.93,1.94 List.py,1.64,1.65

Christian Reis kiko at async.com.br
Fri Feb 7 16:10:20 BRDT 2003


Update of /cvs/Kiwi/Kiwi
In directory anthem:/tmp/cvs-serv30454/Kiwi

Modified Files:
	Delegates.py List.py 
Log Message:
Optimize CList somewhat by avoiding the call to sync_shade for every
single insertion on the face of the earth :-)


Index: Delegates.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/Delegates.py,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- Delegates.py	7 Feb 2003 16:37:42 -0000	1.93
+++ Delegates.py	7 Feb 2003 17:10:18 -0000	1.94
@@ -296,6 +296,7 @@
         # and then emit, but I think this is easier on the eyes
         clist = self.clist
         clist.freeze()
+        clist.disable_shade()
         old_mode = clist['selection_mode']
         old_sel = self.get_selected()
         clist.set_selection_mode(gtk.SELECTION_SINGLE)
@@ -312,6 +313,7 @@
                 row = clist.find_row_from_data(instance)
                 if row >= 0:
                     self._select_and_focus_row(row)
+        clist.enable_shade()
         clist.thaw()
 
     def clear_list(self):

Index: List.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/List.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- List.py	7 Feb 2003 16:37:42 -0000	1.64
+++ List.py	7 Feb 2003 17:10:18 -0000	1.65
@@ -341,34 +341,35 @@
 
 # Oy, what a hack. Offer pixmap-safe functions to handle clist manipulation so
 # they can easily substitute the fast C versions that we use by default.
-
-# Looks up self in a special key in the _o object we get
-# This is used so we can access `self' in the _kiwi_clist functions
-def _kiwi_clist_get_self(obj):
-    return _gtk.gtk_object_get_data(obj, "_kiwi_clist_self")
+# We look up self in a special key in the _o object we get; this is used
+# so we can access `self' in the _kiwi_clist functions
 
 def _kiwi_clist_append(obj, values):
     row = _gtk.gtk_clist_append(obj, values)
-    _kiwi_clist_fix_pixmap(obj, row, values)
+    self = _gtk.gtk_object_get_data(obj, "_kiwi_clist_self")
+    if self.pixmap_specs:
+        _kiwi_clist_fix_pixmap(obj, self.pixmap_specs, row, values)
+    # Yes, sync_shade does this check, but this is speed-critical
+    if self._shading: self._sync_shade
     return row
 
 def _kiwi_clist_insert(obj, row, values):
     row = _gtk.gtk_clist_insert(obj, row, values)
-    _kiwi_clist_fix_pixmap(obj, row, values)
+    self = _gtk.gtk_object_get_data(obj, "_kiwi_clist_self")
+    if self.pixmap_specs:
+        _kiwi_clist_fix_pixmap(obj, self.pixmap_specs, row, values)
+    # Yes, sync_shade does this check, but this is speed-critical
+    if self._shading: self._sync_shade
     return row
 
 # Looks through the list of pixmap_specs and substitutes values 
 # for pixmaps as necessary
-def _kiwi_clist_fix_pixmap(obj, row, values):
-    self = _kiwi_clist_get_self(obj)
-    pixmap_specs = self.pixmap_specs
+def _kiwi_clist_fix_pixmap(obj, pixmap_specs, row, values):
     for col, pixmap_spec in pixmap_specs.items():
         _kiwi_clist_set_pixmap(obj, row, col, pixmap_specs[col], values[col])
-    # Make sure shading is correct
-    self._sync_shade(row)
 
 def _kiwi_clist_set_text(obj, row, col, value):
-    self = _kiwi_clist_get_self(obj)
+    self = _gtk.gtk_object_get_data(obj, "_kiwi_clist_self")
     _gtk.gtk_clist_set_text(obj, row, col, value)
     if self.pixmap_specs.has_key(col): # if it is a pixmap column
         _kiwi_clist_set_pixmap(obj, row, col, self.pixmap_specs[col], value)
@@ -391,7 +392,7 @@
          % (repr(value), col, pixmap_spec.keys()))
 
 def _kiwi_clist_get_text(obj, row, col):
-    self = _kiwi_clist_get_self(obj)
+    self = _gtk.gtk_object_get_data(obj, "_kiwi_clist_self")
     if not self.pixmap_rspecs.has_key(col):
         return _gtk.gtk_clist_get_text(obj, row, col)
     pixmap_rspec = self.pixmap_rspecs[col]
@@ -938,19 +939,19 @@
         gtk.GtkCList.set_column_visibility(self, column, visible)
 
     # radix requested this, so he could delete rows by text
-    def find_row_from_text(self, text, column = -1, cmpfunc = cmp):
+    def find_row_from_text(self, text, column = None, cmpfunc = cmp):
         """
 Searches through the clist and returns the index of the first row where
 the text is located. Returns -1 if not found. You may specify a column
 and a specific comparison function that override the defaults."""
-        if column < 0:
+        if column is None:
             columns = range(0, self.columns)
         else:
             columns = [column]
 
         for r in range(0,self.rows):
             for c in columns:
-                if cmpfunc(text, self._raw_get_text(self._o, r,c)) < 1:
+                if cmpfunc(text, self._raw_get_text(self._o, r,c)) is not 1:
                     return r
         return -1
 
@@ -1341,6 +1342,10 @@
         self._stop_select_row = TRUE
 
         self.freeze()
+        # Storage state of shading to reenable at the end
+        shading = self._shading
+        self._shading = FALSE
+
         # if all we have are strings we can use the builtin sorting and
         # take advantage of it's speed.
         if self._get_column_type(column) == StringType:
@@ -1389,6 +1394,7 @@
                 gdkwin.set_cursor(None)
                 gtk.mainiteration()
 
+        self._shading = shading
         if self._shading:
             self._sync_shade()
         self.thaw()



More information about the POS-commit mailing list