[POS-commit] CVS: Kiwi/Kiwi Delegates.py,1.85,1.86 List.py,1.59,1.60
Christian Reis
kiko at async.com.br
Sun Feb 2 15:04:02 BRDT 2003
Update of /cvs/Kiwi/Kiwi
In directory anthem:/tmp/cvs-serv29349/Kiwi
Modified Files:
Delegates.py List.py
Log Message:
Implement handling of None as a possible column value in CListDelegate.
In with this goes a small fix to sorting when pixmap columns are
involved, and some cleanups.
Index: Delegates.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/Delegates.py,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- Delegates.py 2 Feb 2003 14:44:24 -0000 1.85
+++ Delegates.py 2 Feb 2003 16:04:00 -0000 1.86
@@ -470,7 +470,10 @@
if column.format:
value = column.format % value
else:
- value = str(value)
+ if value is None:
+ value = ""
+ else:
+ value = str(value)
text.append(value)
return text
Index: List.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/List.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- List.py 2 Feb 2003 14:44:24 -0000 1.59
+++ List.py 2 Feb 2003 16:04:00 -0000 1.60
@@ -375,13 +375,13 @@
pixval = pixmap_spec[value]
# If the pixmap corresponding to the value is None, we are
# to use an empty cell, which we simulate with "".
- if pixval:
+ if pixval is None:
+ _gtk.gtk_clist_set_text(obj, row, col, "")
+ else:
pixval = pixval.get()
_gtk.gtk_clist_set_pixmap(obj, row, col, pixval[0], pixval[1])
- else:
- _gtk.gtk_clist_set_text(obj, row, col, "")
else:
- _warn("""no pixmap corresponding to value %s %s
+ _warn("""no pixmap corresponding to value `%s' %s
possible values are %s.""" % (value, type(value), pixmap_spec.keys()))
def _kiwi_clist_get_text(obj, row, col):
@@ -1139,22 +1139,50 @@
def _sort_rows_by_type(self, rows):
column = self.sort_column
tp = self._get_column_type(column)
- # Do it all inline because the sort is expensive
+ # Do it all inline because the sort is so expensive
if self.sort_type == gtk.SORT_ASCENDING:
if tp == IntType:
rows.sort(lambda x, y, column=column: \
+ # If values are equal
+ (not x["text"][column] == y["text"][column]) and \
+ # If x is none
+ (x["text"][column] == "" and -1) or \
+ # if y is none
+ (y["text"][column] == "" and +1) or \
+ # Normal cmp
cmp(int(x["text"][column] or 0),int(y["text"][column]) or 0))
elif tp == FloatType:
rows.sort(lambda x, y, column=column: \
+ # If values are equal
+ (not x["text"][column] == y["text"][column]) and \
+ # If x is none
+ (x["text"][column] == "" and -1) or \
+ # if y is none
+ (y["text"][column] == "" and +1) or \
+ # Normal cmp
cmp(float(x["text"][column] or 0),float(y["text"][column]) or 0))
else:
raise AssertionError
else:
+ # Pay attention. y and x are inverted in the lambda *parameters*
if tp == IntType:
rows.sort(lambda y, x, column=column: \
+ # If values are equal
+ (not x["text"][column] == y["text"][column]) and \
+ # If x is none
+ (x["text"][column] == "" and -1) or \
+ # if y is none
+ (y["text"][column] == "" and +1) or \
+ # Normal cmp
cmp(int(x["text"][column] or 0),int(y["text"][column]) or 0))
elif tp == FloatType:
rows.sort(lambda y, x, column=column: \
+ # If values are equal
+ (not x["text"][column] == y["text"][column]) and \
+ # If x is none
+ (x["text"][column] == "" and -1) or \
+ # if y is none
+ (y["text"][column] == "" and +1) or \
cmp(float(x["text"][column] or 0),float(y["text"][column]) or 0))
else:
raise AssertionError
@@ -1209,7 +1237,10 @@
self.freeze()
# 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:
+ if self._get_column_type(column) == StringType and \
+ not self.pixmap_specs.has_key(column):
+ # XXX: pixmap sorting is a bit broken in here, see test,
+ # column cool.
gtk.GtkCList.sort(self)
else:
# For numeric columns, use Kiwi's own simulation of sort()
More information about the POS-commit
mailing list