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

Commit e5f39a2

Browse files
committed
Merge branch 'jNullj-gtk3' into gtk3
merge #132, fix #131
2 parents 9ba2f5b + e48dafe commit e5f39a2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

mcomix/mcomix/keybindings.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,26 @@ def clear_accel(self, name, binding):
129129

130130
self.save()
131131

132-
def clear_all(self):
133-
''' Removes all keybindings. The changes are only persisted if
132+
def reset_keybindings(self):
133+
''' Reset all keybindings. The changes are only persisted if
134134
save() is called afterwards. '''
135135
self._action_to_callback = {}
136136
self._action_to_bindings = defaultdict(list)
137137
self._binding_to_action = {}
138138

139+
stored_action_bindings = keybindings_map.DEFAULT_BINDINGS.copy()
140+
141+
for action in keybindings_map.BINDING_INFO.keys():
142+
if action in stored_action_bindings:
143+
bindings = [
144+
Gtk.accelerator_parse(keyname)
145+
for keyname in stored_action_bindings[action] ]
146+
self._action_to_bindings[action] = bindings
147+
for binding in bindings:
148+
self._binding_to_action[binding] = action
149+
else:
150+
self._action_to_bindings[action] = []
151+
139152
def execute(self, keybinding):
140153
''' Executes an action that has been registered for the
141154
passed keyboard event. If no action is bound to the passed key, this

mcomix/mcomix/preferences_dialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def _response(self, dialog, response):
445445
if self.notebook.get_nth_page(self.notebook.get_current_page()) == self.shortcuts:
446446
# "Shortcuts" page is active, reset all keys to their default value
447447
km = keybindings.keybinding_manager(self._window)
448-
km.clear_all()
448+
km.reset_keybindings()
449449
self._window._event_handler.register_key_events()
450450
km.save()
451451
self.shortcuts.refresh_model()

0 commit comments

Comments
 (0)