make shortcuts work, migrate to plugin api
This commit is contained in:
parent
0abe30791d
commit
17d2773344
@ -10,7 +10,6 @@ import _thread
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
settings = None
|
||||
keybindings = None
|
||||
speech = None
|
||||
braille = None
|
||||
input_event = None
|
||||
@ -35,17 +34,14 @@ class SimplePluginSystem(GObject.Object, Peas.Activatable, plugin.Plugin):
|
||||
def do_activate(self):
|
||||
API = self.object
|
||||
global settings
|
||||
global keybindings
|
||||
global speech
|
||||
global braille
|
||||
global input_event
|
||||
settings = API.app.getDynamicApiManager().getAPI('Settings')
|
||||
keybindings = API.app.getDynamicApiManager().getAPI('Keybindings')
|
||||
speech = API.app.getDynamicApiManager().getAPI('Speech')
|
||||
braille = API.app.getDynamicApiManager().getAPI('Braille')
|
||||
input_event = API.app.getDynamicApiManager().getAPI('InputEvent')
|
||||
"""Required method for plugins"""
|
||||
self.my_key_bindings = keybindings.KeyBindings()
|
||||
if not self.loaded:
|
||||
self.load_plugins()
|
||||
|
||||
@ -53,35 +49,34 @@ class SimplePluginSystem(GObject.Object, Peas.Activatable, plugin.Plugin):
|
||||
"""Required method for plugins"""
|
||||
# Remove all registered keybindings
|
||||
for plugin in self.plugin_list:
|
||||
if plugin.get('inputeventhandler'):
|
||||
self.my_key_bindings.remove(plugin['inputeventhandler'])
|
||||
settings.keyBindingsMap["default"] = keybindings.KeyBindings()
|
||||
self.unregisterShortcut(plugin['function'], plugin['shortcut'])
|
||||
self.loaded = False
|
||||
self.plugin_list = []
|
||||
|
||||
def SetupShortcutAndHandle(self, currPluginSetting):
|
||||
currPluginSetting['inputeventhandler'] = input_event.InputEventHandler(currPluginSetting['function'], currPluginSetting['pluginname'])
|
||||
shortcut = ''
|
||||
# just the modifier
|
||||
if not currPluginSetting['shiftkey'] and not currPluginSetting['ctrlkey'] and not currPluginSetting['altkey']:
|
||||
self.my_key_bindings.add(keybindings.KeyBinding(currPluginSetting['key'], keybindings.defaultModifierMask, keybindings.CTHULHU_MODIFIER_MASK, currPluginSetting['inputeventhandler']))
|
||||
# + alt
|
||||
shortcut = 'kb:cthulhu+' + currPluginSetting['key']
|
||||
# cthulhu + alt
|
||||
if not currPluginSetting['shiftkey'] and not currPluginSetting['ctrlkey'] and currPluginSetting['altkey']:
|
||||
self.my_key_bindings.add(keybindings.KeyBinding(currPluginSetting['key'], keybindings.defaultModifierMask, keybindings.CTHULHU_ALT_MODIFIER_MASK, currPluginSetting['inputeventhandler']))
|
||||
# + CTRL
|
||||
shortcut = 'kb:cthulhu+alt+' + currPluginSetting['key']
|
||||
# cthulhu + CTRL
|
||||
if not currPluginSetting['shiftkey'] and currPluginSetting['ctrlkey'] and not currPluginSetting['altkey']:
|
||||
self.my_key_bindings.add(keybindings.KeyBinding(currPluginSetting['key'], keybindings.defaultModifierMask, keybindings.CTHULHU_CTRL_MODIFIER_MASK, currPluginSetting['inputeventhandler']))
|
||||
# + alt + CTRL
|
||||
shortcut = 'kb:cthulhu+control+' + currPluginSetting['key']
|
||||
# cthulhu + alt + CTRL
|
||||
if not currPluginSetting['shiftkey'] and currPluginSetting['ctrlkey'] and currPluginSetting['altkey']:
|
||||
self.my_key_bindings.add(keybindings.KeyBinding(currPluginSetting['key'], keybindings.defaultModifierMask, keybindings.CTHULHU_CTRL_ALT_MODIFIER_MASK, currPluginSetting['inputeventhandler']))
|
||||
# + shift
|
||||
shortcut = 'kb:cthulhu+alt+control+ ' + currPluginSetting['key']
|
||||
# cthulhu + shift
|
||||
if currPluginSetting['shiftkey'] and not currPluginSetting['ctrlkey'] and not currPluginSetting['altkey']:
|
||||
self.my_key_bindings.add(keybindings.KeyBinding(currPluginSetting['key'], keybindings.defaultModifierMask, keybindings.CTHULHU_SHIFT_MODIFIER_MASK, currPluginSetting['inputeventhandler']))
|
||||
shortcut = 'kb:cthulhu+shift+' + currPluginSetting['key']
|
||||
# alt + shift
|
||||
if currPluginSetting['shiftkey'] and not currPluginSetting['ctrlkey'] and currPluginSetting['altkey']:
|
||||
self.my_key_bindings.add(keybindings.KeyBinding(currPluginSetting['key'], keybindings.defaultModifierMask, keybindings.SHIFT_ALT_MODIFIER_MASK, currPluginSetting['inputeventhandler']))
|
||||
print(self.my_key_bindings, currPluginSetting['function'])
|
||||
|
||||
settings.keyBindingsMap["default"] = self.my_key_bindings
|
||||
shortcut = 'kb:alt+shift+' + currPluginSetting['key']
|
||||
if shortcut != '':
|
||||
print(shortcut)
|
||||
currPluginSetting['shortcut'] = shortcut
|
||||
self.registerGestureByString(currPluginSetting['function'], _(currPluginSetting['pluginname']), shortcut)
|
||||
return currPluginSetting
|
||||
|
||||
def id_generator(self, size=7, chars=string.ascii_letters):
|
||||
@ -89,7 +84,6 @@ class SimplePluginSystem(GObject.Object, Peas.Activatable, plugin.Plugin):
|
||||
|
||||
def initSettings(self):
|
||||
currPluginSetting={
|
||||
'filepath':'',
|
||||
'pluginname':'',
|
||||
'functionname':'',
|
||||
'key':'',
|
||||
@ -105,7 +99,8 @@ class SimplePluginSystem(GObject.Object, Peas.Activatable, plugin.Plugin):
|
||||
'function':None,
|
||||
'inputeventhandler':None,
|
||||
'valid':False,
|
||||
'supressoutput':False
|
||||
'supressoutput':False,
|
||||
'shortcut': ''
|
||||
}
|
||||
return currPluginSetting
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user