[POS-commit] CVS: Kiwi/Kiwi Delegates.py,1.95,1.96 List.py,1.68,1.69 Menu.py,1.27,1.28 Proxies.py,1.43,1.44 Views.py,1.76,1.77 __init__.py,1.36,1.37

Christian Reis kiko at async.com.br
Mon Feb 10 23:59:56 BRDT 2003


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

Modified Files:
	Delegates.py List.py Menu.py Proxies.py Views.py __init__.py 
Log Message:
Stop overwriting type() in __init__. This is a bad idea and actually
caused problems when using Kiwi with SQLObject. Renamed to ktype() and
using it selectively when we are actually comparing with widgets. We can
complain about renames later.


Index: Delegates.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/Delegates.py,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- Delegates.py	7 Feb 2003 17:40:41 -0000	1.95
+++ Delegates.py	11 Feb 2003 00:59:53 -0000	1.96
@@ -259,7 +259,7 @@
                 tip = gtk.GtkTooltips()
                 align = clist.get_column_widget(i)
                 col = align['parent']
-                if type(col) == gtk.GtkButtonType:
+                if ktype(col) == gtk.GtkButtonType:
                     tip.set_tip(col, column.tooltip)
                 else:
                     _warn("""Tried to set tooltip `%s' to column %d but found a 
@@ -455,9 +455,9 @@
         
         # Now that the CList is ready, really add the instance
         row = self._real_add_instance(instance)
-        if select:
-            self._select_and_focus_row(row, old_mode)
         clist.set_selection_mode(old_mode)
+        if select:
+            self._select_and_focus_row(row)
         clist.thaw()
         return row
 

Index: List.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/List.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- List.py	7 Feb 2003 18:43:04 -0000	1.68
+++ List.py	11 Feb 2003 00:59:53 -0000	1.69
@@ -1091,17 +1091,17 @@
 
             column = self.get_column_widget(c)
             button = column['parent']
-            buttontype = type(button)
+            buttontype = ktype(button)
 
             if buttontype != gtk.GtkButtonType:
                 msg = "Expected GtkButton, found %s"
                 raise TypeError, msg % buttontype
-            elif type(column) == gtk.GtkAlignmentType:
+            elif ktype(column) == gtk.GtkAlignmentType:
                 align = column
                 child = align.children()[0]
                 # [*] If we have disabled sorting and enabled it again,
                 # the column child is already a GtkHBox.
-                if type(child) == gtk.GtkHBoxType:
+                if ktype(child) == gtk.GtkHBoxType:
                     return TRUE
                 label = child
                 button.remove(align)
@@ -1112,9 +1112,9 @@
                 align.add(label)
             # At this point, we have a button with nothing inside it,
             # and an align containing a label.
-            if type(label) not in (gtk.GtkLabelType, gtk.GtkPixmapType):
+            if ktype(label) not in (gtk.GtkLabelType, gtk.GtkPixmapType):
                 msg = "Expected GtkLabel or GtkPixmap, found %s"
-                raise TypeError, msg % type(label)
+                raise TypeError, msg % ktype(label)
             # We need an extra Alignment so get_column_widget() returns
             # one and (broken) code that expects it doesn't barf.
             align_out = gtk.GtkAlignment()
@@ -1151,10 +1151,10 @@
             return
         align = self.get_column_widget(column)
         hbox = align.children()[0]
-        if type(hbox) != gtk.GtkHBoxType:
+        if ktype(hbox) != gtk.GtkHBoxType:
             msg = "Incorrect column structure, expected %s, found %s"
             raise AssertionError, msg % ( gtk.GtkHBoxType,
-                                          type(hbox) )
+                                          ktype(hbox) )
         # For the reasons behind this, see set_column_justification.
         # Basically, the label is packed to the end of the hbox when it
         # is right-aligned; detect and return the correct order to keep

Index: Menu.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/Menu.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- Menu.py	3 Feb 2003 19:28:32 -0000	1.27
+++ Menu.py	11 Feb 2003 00:59:53 -0000	1.28
@@ -139,7 +139,7 @@
         # Proxies to gtk.GtkMenu.append, but allows it to be
         # subclassed, as is necessary in OptionMenu, since the widget
         # from hell really *contains* a menu
-        if not type(item) in (gtk.GtkMenuItemType,
+        if not ktype(item) in (gtk.GtkMenuItemType,
                               gtk.GtkCheckMenuItemType,
                               gtk.GtkRadioMenuItemType,
                               gtk.GtkTearoffMenuItemType):
@@ -357,7 +357,7 @@
         except TypeError:
             menu = gtk.GtkMenu()
             self.set_menu(menu)
-            if not type(item) in (gtk.GtkMenuItemType,
+            if not ktype(item) in (gtk.GtkMenuItemType,
                                   gtk.GtkCheckMenuItemType,
                                   gtk.GtkRadioMenuItemType,
                                   gtk.GtkTearoffMenuItemType):

Index: Proxies.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/Proxies.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- Proxies.py	3 Feb 2003 19:28:32 -0000	1.43
+++ Proxies.py	11 Feb 2003 00:59:53 -0000	1.44
@@ -181,7 +181,7 @@
         attr_map = self._attr_map
         if attr_map.has_key(name):
             widget = attr_map[name]
-            widget_type = type(widget)
+            widget_type = ktype(widget)
             if self._standard_widgets.has_key(widget_type):
                 suff = self._standard_widgets[widget_type]
                 func = getattr(self, "_update_%s" % suff)
@@ -371,7 +371,7 @@
 
         for attr_name in attributes:
             widget = self._get_widget_by_name(attr_name)
-            widget_type = type(widget)
+            widget_type = ktype(widget)
             self._attr_map[attr_name] = widget
 
             # Please look the other way, this is evil. I swap the name

Index: Views.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/Views.py,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- Views.py	3 Feb 2003 19:28:32 -0000	1.76
+++ Views.py	11 Feb 2003 00:59:53 -0000	1.77
@@ -194,7 +194,7 @@
             # Skip non-gtkwidgets and widgets we don't want to focus
             # XXX: this should *really* be done properly
             if not hasattr(widget, "realize") or \
-                type(widget) in (gtk.GtkLabelType, 
+                ktype(widget) in (gtk.GtkLabelType, 
                                  gtk.GtkHSeparatorType,
                                  gtk.GtkVSeparatorType,
                                  gtk.GtkWindowType):
@@ -302,7 +302,7 @@
 
         if not isinstance(toplevel, gtk.GtkWindow):
             raise TypeError, "toplevel widget must be a GtkWindow \
-(or inherit from it),\nfound `%s' %s" % (toplevel, type(toplevel))
+(or inherit from it),\nfound `%s' %s" % (toplevel, ktype(toplevel))
         self.get_win = self.get_toplevel
 
         SlaveView.__init__(self, toplevel, widgets)
@@ -339,7 +339,7 @@
             # Check if any of the widgets is interactive
             for v in values:
                 if isinstance(v, gtk.GtkWidget) and \
-                   type(v) not in _non_interactive: 
+                   ktype(v) not in _non_interactive: 
                     interactive = v
             if interactive:
                 _warn("""no widget is focused in view %s
@@ -399,7 +399,7 @@
             self.win.set_transient_for(view)
         else:
             raise TypeError, \
-"Parameter to set_transient_for should be View (found %s)" % type(view)
+"Parameter to set_transient_for should be View (found %s)" % ktype(view)
 
     def set_title(self, title):
         """Sets the view's window title"""
@@ -518,7 +518,7 @@
 warning."""
         if not isinstance(slave, SlaveView):
             raise TypeError, "slave specified must be a View, found %s" \
-                  % type(slave)
+                  % ktype(slave)
         shell = slave.get_toplevel()
 
         if isinstance(shell, gtk.GtkWindow): # View with toplevel Window

Index: __init__.py
===================================================================
RCS file: /cvs/Kiwi/Kiwi/__init__.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- __init__.py	3 Feb 2003 19:28:32 -0000	1.36
+++ __init__.py	11 Feb 2003 00:59:53 -0000	1.37
@@ -40,7 +40,6 @@
 # - GhostProxy
 # - Combo signal attaching for list items
 # - Check for dependencies on installation and adjust pygtk.require?
-# - Proxy set_numeric() for numeric types
 # - Kiwi Menu factories
 # - keep Howto updated
 
@@ -77,14 +76,12 @@
     pygtk_version = (0, 6, -1)
     gtk_version = (1, 2, -1)
 
-_type = type
-
-def type(obj):
+def ktype(obj):
     if hasattr(obj, 'get_type'):
         return obj.get_type()
-    return _type(obj)
+    return type(obj)
 
-__builtins__['type'] = type
+__builtins__['ktype'] = ktype
 
 import gtk,libglade
 



More information about the POS-commit mailing list