summaryrefslogtreecommitdiff
path: root/src/events.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-07 15:09:39 +0100
committermathieui <mathieui@mathieui.net>2011-11-07 15:09:39 +0100
commitd6b8ca50f2c046aa1248173f453b3804f40c479a (patch)
tree9a6d64a2c5a6c664a0f32416b53bed96f7073603 /src/events.py
parent1f3fafe15569c50fc877b5b24209e1d1214ae97a (diff)
downloadpoezio-d6b8ca50f2c046aa1248173f453b3804f40c479a.tar.gz
poezio-d6b8ca50f2c046aa1248173f453b3804f40c479a.tar.bz2
poezio-d6b8ca50f2c046aa1248173f453b3804f40c479a.tar.xz
poezio-d6b8ca50f2c046aa1248173f453b3804f40c479a.zip
Remove first&last and only use "position" in plugins events
Diffstat (limited to 'src/events.py')
-rw-r--r--src/events.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/events.py b/src/events.py
index d4fc8fc6..22d60ddf 100644
--- a/src/events.py
+++ b/src/events.py
@@ -30,23 +30,20 @@ class EventHandler(object):
'muc_msg': [],
}
- def add_event_handler(self, name, callback, first=True, last=False, position=None):
+ def add_event_handler(self, name, callback, position=0):
"""
Add a callback to a given event.
Note that if that event name doesn’t exist, it just returns False.
If it was successfully added, it returns True
+ position: 0 means insert a the beginning, -1 means end
"""
if name not in self.events:
return False
- if first:
- self.events[name].insert(0, callback)
- elif last:
- self.events[name].append(callback)
- elif position != None and isinstance(position, int):
+ if position >= 0:
self.events[name].insert(position, callback)
else:
- self.events[name].insert(0, callback)
+ self.events[name].append(callback)
return True