The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Allow same key bindings in different tabs

These changes was commited to the Birdfont repository Fri, 30 Oct 2015 09:50:13 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 30 Oct 2015 09:50:13 +0000 (10:50 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 30 Oct 2015 09:50:13 +0000 (10:50 +0100)
commit 9eabc61c012cc53e2bffcd44324c2e8c5e40a6cc
tree fda9bdfc38cbaa1d5c7938de0861dd46fc6a7c41
parent 1cd465fe0783b81b0adc2dad1927a0d63b166ac5
Allow same key bindings in different tabs

libbirdfont/SettingsDisplay.vala
--- a/libbirdfont/SettingsDisplay.vala +++ b/libbirdfont/SettingsDisplay.vala @@ -113,8 +113,11 @@ if (has_key_binding (KeyBindings.modifier, (unichar) keyval)) { old_key_binding = (!) get_key_binding (KeyBindings.modifier, (unichar) keyval); - old_key_binding.menu_item.modifiers = NONE; - old_key_binding.menu_item.key = '\0'; + + if (same_scope (old_key_binding, new_key_bindings)) { + old_key_binding.menu_item.modifiers = NONE; + old_key_binding.menu_item.key = '\0'; + } } new_key_bindings.menu_item.modifiers = KeyBindings.modifier; @@ -129,6 +132,17 @@ } } + /** Check if key binding is used in same tab. */ + bool same_scope (SettingsItem key_binding1, SettingsItem key_binding2) { + foreach (string scope in key_binding1.menu_item.displays) { + if (key_binding2.menu_item.in_display (scope)) { + return true; + } + } + + return false; + } + bool has_key_binding (uint modifier, unichar key) { return get_key_binding (modifier, key) != null; }