Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
Merge branch 'jNullj-gtk3' into gtk3
Browse files Browse the repository at this point in the history
merge #132, fix #131
  • Loading branch information
multiSnow committed Feb 26, 2021
2 parents 9ba2f5b + e48dafe commit e5f39a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions mcomix/mcomix/keybindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,26 @@ def clear_accel(self, name, binding):

self.save()

def clear_all(self):
''' Removes all keybindings. The changes are only persisted if
def reset_keybindings(self):
''' Reset all keybindings. The changes are only persisted if
save() is called afterwards. '''
self._action_to_callback = {}
self._action_to_bindings = defaultdict(list)
self._binding_to_action = {}

stored_action_bindings = keybindings_map.DEFAULT_BINDINGS.copy()

for action in keybindings_map.BINDING_INFO.keys():
if action in stored_action_bindings:
bindings = [
Gtk.accelerator_parse(keyname)
for keyname in stored_action_bindings[action] ]
self._action_to_bindings[action] = bindings
for binding in bindings:
self._binding_to_action[binding] = action
else:
self._action_to_bindings[action] = []

def execute(self, keybinding):
''' Executes an action that has been registered for the
passed keyboard event. If no action is bound to the passed key, this
Expand Down
2 changes: 1 addition & 1 deletion mcomix/mcomix/preferences_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def _response(self, dialog, response):
if self.notebook.get_nth_page(self.notebook.get_current_page()) == self.shortcuts:
# "Shortcuts" page is active, reset all keys to their default value
km = keybindings.keybinding_manager(self._window)
km.clear_all()
km.reset_keybindings()
self._window._event_handler.register_key_events()
km.save()
self.shortcuts.refresh_model()
Expand Down

0 comments on commit e5f39a2

Please sign in to comment.