[bug 681] Plugin Submission + Generic Plugin Utility Functions & KeyBinding Feature: Mouseless / Mousefree / Keyboard URL opening or yanking #681

- renamed api interfacted for better clarity
- removed double checking of short-cut binding for plugins in keybindings
This commit is contained in:
Vishweshwar Saran Singh Deo 2022-11-23 15:34:22 +05:30
parent 8edebc6ca5
commit 8e5e6d1642
3 changed files with 28 additions and 16 deletions

View File

@ -723,7 +723,7 @@ class ConfigBase(Borg):
from terminatorlib.plugin import KeyBindUtil from terminatorlib.plugin import KeyBindUtil
# for plugin KeyBindUtil assist in plugin_util # for plugin KeyBindUtil assist in plugin_util
keybindutil = KeyBindUtil(); keybindutil = KeyBindUtil();
keyb_keys = keybindutil.get_act_to_keys() keyb_keys = keybindutil.get_all_act_to_keys()
# we only need keys as a reference so to match them # we only need keys as a reference so to match them
# against new values # against new values
keyb_keys = dict.fromkeys(keyb_keys, "") keyb_keys = dict.fromkeys(keyb_keys, "")

View File

@ -303,8 +303,22 @@ class KeyBindUtil:
dbg("keyaction: (%s)" % str(ret)) dbg("keyaction: (%s)" % str(ret))
return self.map_key_to_act.get(ret, None) return self.map_key_to_act.get(ret, None)
def get_act_to_keys(self): def get_act_to_keys(self, key):
return self.map_act_to_keys.get(key)
def get_all_act_to_keys(self):
return self.map_act_to_keys return self.map_act_to_keys
def get_act_to_desc(self): def get_all_act_to_desc(self):
return self.map_act_to_desc return self.map_act_to_desc
def get_act_to_desc(self, act):
return self.map_act_to_desc.get(act)
#get action to key binding from config
def get_act_to_keys_config(self, act):
if not self.config:
raise Warning("get_keyvalmask_for_act called without config init")
keybindings = self.config["keybindings"]
return keybindings.get(act)

View File

@ -464,8 +464,8 @@ class PrefsEditor:
keybindings = self.config['keybindings'] keybindings = self.config['keybindings']
keybindutil = KeyBindUtil() keybindutil = KeyBindUtil()
plugin_keyb_act = keybindutil.get_act_to_keys() plugin_keyb_act = keybindutil.get_all_act_to_keys()
plugin_keyb_desc = keybindutil.get_act_to_desc() plugin_keyb_desc = keybindutil.get_all_act_to_desc()
#merge give preference to main bindings over plugin #merge give preference to main bindings over plugin
keybindings = {**plugin_keyb_act, **keybindings} keybindings = {**plugin_keyb_act, **keybindings}
self.keybindingnames = {**plugin_keyb_desc, **self.keybindingnames} self.keybindingnames = {**plugin_keyb_desc, **self.keybindingnames}
@ -1817,7 +1817,7 @@ class PrefsEditor:
keybindutil = KeyBindUtil() keybindutil = KeyBindUtil()
keybindings = self.config["keybindings"] keybindings = self.config["keybindings"]
#merge give preference to main bindings over plugin #merge give preference to main bindings over plugin
plugin_keyb_act = keybindutil.get_act_to_keys() plugin_keyb_act = keybindutil.get_all_act_to_keys()
keybindings = {**plugin_keyb_act, **keybindings} keybindings = {**plugin_keyb_act, **keybindings}
duplicate_bindings = [] duplicate_bindings = []
@ -1865,16 +1865,14 @@ class PrefsEditor:
accel = Gtk.accelerator_name(key, mods) accel = Gtk.accelerator_name(key, mods)
self.config['keybindings'][binding] = accel self.config['keybindings'][binding] = accel
plugin_keyb_desc = keybindutil.get_act_to_desc() plugin_keyb_desc = keybindutil.get_act_to_desc(binding)
if plugin_keyb_desc:
if binding in plugin_keyb_desc: dbg("modifying plugin binding: %s, %s, %s" %
if binding in plugin_keyb_desc: (plugin_keyb_desc, binding, accel))
desc = plugin_keyb_desc[binding] keybindutil.bindkey([plugin_keyb_desc, binding, accel])
dbg("modifying plugin binding: %s, %s, %s" % (desc, binding, accel)) else:
keybindutil.bindkey([desc, binding, accel]) dbg("skipping: %s" % binding)
else: pass
dbg("skipping: %s" % binding)
pass
self.config.save() self.config.save()