diff options
| author | Robert McQueen <robot101@debian.org> | 2006-02-15 23:45:50 +0000 | 
|---|---|---|
| committer | Robert McQueen <robot101@debian.org> | 2006-02-15 23:45:50 +0000 | 
| commit | 397b0a4ec150c4400de8a041d077c819f6e978bd (patch) | |
| tree | 4d4f13752e02db90fed751fb933d10fda961fbdd /python/matchrules.py | |
| parent | 08bbc0210c243cb1c7e41d0c434fc069c7b2743c (diff) | |
2006-02-16  Robert McQueen  <robot101@debian.org>
	* glib/dbus-gmain.c: Make the previous commit compile.
	* python/_dbus.py, python/matchrules.py: Patch from Ole Andre
	Ravnaas <ole.andre.ravnaas@collabora.co.uk> to allow you to
	specify sender_keyword="foo", path_keyword="bar" when adding
	a signal listener, so that you can bind to signals generically
	but still do something useful in your callback.
	* python/dbus_bindings.pyx: Demarshal the byte type as unsigned
	chars so that they're not cast to chars and made negative. Thanks
	to Jakub Stachowski for reporting this and testing the fix.
Diffstat (limited to 'python/matchrules.py')
| -rw-r--r-- | python/matchrules.py | 17 | 
1 files changed, 13 insertions, 4 deletions
| diff --git a/python/matchrules.py b/python/matchrules.py index 3a2fbedf..023a5b76 100644 --- a/python/matchrules.py +++ b/python/matchrules.py @@ -130,16 +130,25 @@ class SignalMatchRule:          self.args = args      def execute(self, message, args=None): -        #optimization just in case we already extarcted the args +        keywords = {} + +        if self.sender_keyword is not None: +            keywords[self.sender_keyword] = message.get_sender() +        if self.path_keyword is not None: +            keywords[self.path_keyword] = message.get_path() + +        # optimization just in case we already extracted the args          if not args:             args = message.get_args_list()          for handler in self.handler_functions:              if getattr(handler, "_dbus_pass_message", False): -                keywords = {"dbus_message": message} -                handler(*args, **keywords) -            else: +                keywords["dbus_message"] = message + +            if len(keywords) == 0:                  handler(*args) +            else: +                handler(*args, **keywords)      def add_handler(self, handler):          self.handler_functions.append(handler) | 
