From: Felix Domke Date: Tue, 19 Jun 2007 23:33:23 +0000 (+0000) Subject: use domain, provide removeKeyBindings for a domain X-Git-Tag: 2.6.0~2157 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/dfbaaea681173a6f7d95e1574a851b1f462cf86e use domain, provide removeKeyBindings for a domain --- diff --git a/lib/python/Tools/KeyBindings.py b/lib/python/Tools/KeyBindings.py index 40c184f6..5bd70254 100644 --- a/lib/python/Tools/KeyBindings.py +++ b/lib/python/Tools/KeyBindings.py @@ -27,18 +27,20 @@ keyDescriptions = { KEYIDS["KEY_PREVIOUS"]: ("prev", 559, 203) } -def addKeyBinding(key, context, action): - if (context, action) in keyBindings: - keyBindings[(context, action)].append(key) - else: - keyBindings[(context, action)] = [key] +def addKeyBinding(domain, key, context, action): + keyBindings.setdefault((context, action), []).append((key, domain)) def queryKeyBinding(context, action): if (context, action) in keyBindings: - return keyBindings[(context, action)] + return [x[0] for x in keyBindings[(context, action)]] else: return [ ] def getKeyDescription(key): if key in keyDescriptions: return keyDescriptions.get(key, [ ]) + +def removeKeyBindings(domain): + # remove all entries of domain 'domain' + for x in keyBindings: + keyBindings[x] = filter(lambda e: e[1] != domain, keyBindings[x])