~ubicast/easyevent/1.2-stable

« back to all changes in this revision

Viewing changes to easyevent/event.py

  • Committer: Damien Boucard
  • Date: 2009-12-14 13:56:55 UTC
  • Revision ID: damien.boucard@ubicast.eu-20091214135655-7yyzlmmycbjschb0
Adding forward_gsignal to convert a gobject signal to a easyevent event ;

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
            content = event.content
196
196
        self.launch_event(self.event_type, content)
197
197
 
 
198
class forward_gsignal(User):
 
199
    """ Connect an instance of forward_gsignal to a gobject signal to launch
 
200
    an event having the given event_type when receiving connected gsignal.
 
201
    """
 
202
    def __init__(self, event_type):
 
203
        User.__init__(self)
 
204
        self.event_type = event_type
 
205
    
 
206
    def __call__(self, source, *args):
 
207
        nb_args = len(args)
 
208
        if nb_args == 0:
 
209
            content = None
 
210
        elif nb_args == 1:
 
211
            content = args[0]
 
212
        else:
 
213
            content = args
 
214
        self.event_manager.dispatch_event(
 
215
                                       Event(self.event_type, source, content))
198
216
 
199
217
class Event:
200
218
    """ Represents an event entity.