[pygobject] Do not always pass in user_data to callbacks.



commit af8bc9d5cdba48a7ee728ccb7ea9039df3ecceba
Author: Johan Dahlin <jdahlin litl com>
Date:   Mon Jun 27 00:38:30 2011 -0300

    Do not always pass in user_data to callbacks.
    
    This keeps API compatibility with PyGTK and avoids sending
    in user_data if it's None.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=653462

 gi/overrides/Gtk.py |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 513b7ff..37cdee1 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -155,7 +155,10 @@ class ActionGroup(Gtk.ActionGroup):
         def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None):
             action = Action(name, label, tooltip, stock_id)
             if callback is not None:
-                action.connect('activate', callback, user_data)
+                if user_data is None:
+                    action.connect('activate', callback)
+                else:
+                    action.connect('activate', callback, user_data)
 
             self.add_action_with_accel(action, accelerator)
 
@@ -201,7 +204,10 @@ class ActionGroup(Gtk.ActionGroup):
             action = Gtk.ToggleAction(name, label, tooltip, stock_id)
             action.set_active(is_active)
             if callback is not None:
-                action.connect('activate', callback, user_data)
+                if user_data is None:
+                    action.connect('activate', callback)
+                else:
+                    action.connect('activate', callback, user_data)
 
             self.add_action_with_accel(action, accelerator)
 
@@ -269,7 +275,10 @@ class ActionGroup(Gtk.ActionGroup):
                 first_action = action
 
         if first_action is not None and on_change is not None:
-            first_action.connect('changed', on_change, user_data)
+            if user_data is None:
+                action.connect('changed', on_change)
+            else:
+                action.connect('changed', on_change, user_data)
 
 ActionGroup = override(ActionGroup)
 __all__.append('ActionGroup')



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