[output] Using "instance" for callback registration doesn't make sense

"instance" is actually better suited to be an argument to the callback
(which it already is) than part of the key for callback lookup.
This commit is contained in:
Tobias Witek 2016-11-01 07:58:50 +01:00
parent 7c2170f58a
commit a63094af47

View file

@ -4,30 +4,21 @@ class Output(object):
self._theme = theme self._theme = theme
self._callbacks = {} self._callbacks = {}
def add_callback(self, cmd, button, module=None, instance=None): def add_callback(self, cmd, button, module=None):
self._callbacks[( self._callbacks[(
button, button,
module, module,
instance
)] = cmd )] = cmd
def callback(self, event): def callback(self, event):
cb = self._callbacks.get(( cb = self._callbacks.get((
event.get("button", -1), event.get("button", -1),
event.get("name", None), event.get("name", None),
event.get("instance", None)
), None)
if cb is not None: return cb
cb = self._callbacks.get((
event.get("button", -1),
event.get("name", None),
None
), None) ), None)
if cb is not None: return cb if cb is not None: return cb
cb = self._callbacks.get(( cb = self._callbacks.get((
event.get("button", -1), event.get("button", -1),
None, None,
None
), None) ), None)
return cb return cb