give list of removed event to fire_event_removed func so that it transmits it to listeners

This commit is contained in:
Yann Leboulanger 2007-03-11 08:58:08 +00:00
parent a7ce2b28c3
commit 81c0b528ae
2 changed files with 9 additions and 6 deletions

View File

@ -74,9 +74,9 @@ class Events:
for listener in self._event_added_listeners: for listener in self._event_added_listeners:
listener(event) listener(event)
def fire_event_removed(self): def fire_event_removed(self, event_list):
for listener in self._event_removed_listeners: for listener in self._event_removed_listeners:
listener() listener(event_list)
def change_account_name(self, old_name, new_name): def change_account_name(self, old_name, new_name):
if self._events.has_key(old_name): if self._events.has_key(old_name):
@ -122,26 +122,29 @@ class Events:
del self._events[account][jid] del self._events[account][jid]
else: else:
self._events[account][jid].remove(event) self._events[account][jid].remove(event)
self.fire_event_deleted(event) self.fire_event_removed([event])
return return
else: else:
return True return True
if types: if types:
new_list = [] # list of events to keep new_list = [] # list of events to keep
removed_list = [] # list of removed events
for ev in self._events[account][jid]: for ev in self._events[account][jid]:
if ev.type_ not in types: if ev.type_ not in types:
new_list.append(ev) new_list.append(ev)
else:
removed_list.append(ev)
if len(new_list) == len(self._events[account][jid]): if len(new_list) == len(self._events[account][jid]):
return True return True
if new_list: if new_list:
self._events[account][jid] = new_list self._events[account][jid] = new_list
else: else:
del self._events[account][jid] del self._events[account][jid]
self.fire_event_removed() self.fire_event_removed(removed_list)
return return
# no event nor type given, remove them all # no event nor type given, remove them all
del self._events[account][jid] del self._events[account][jid]
self.fire_event_removed() self.fire_event_removed(self._events[account][jid])
def change_jid(self, account, old_jid, new_jid): def change_jid(self, account, old_jid, new_jid):
if not self._events[account].has_key(old_jid): if not self._events[account].has_key(old_jid):

View File

@ -74,7 +74,7 @@ class Systray:
if event.show_in_systray: if event.show_in_systray:
self.set_img() self.set_img()
def on_event_removed(self): def on_event_removed(self, event_list):
'''Called when one or more events are removed from the event list''' '''Called when one or more events are removed from the event list'''
self.set_img() self.set_img()