[pitivi] prefs: Reset the keyboard shortcuts when factory resetting
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] prefs: Reset the keyboard shortcuts when factory resetting
- Date: Tue, 27 Sep 2016 08:49:14 +0000 (UTC)
commit b4bea7b7bb1f7fae7044e934690da4bba61f1ac0
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Thu Sep 15 15:15:14 2016 +0200
prefs: Reset the keyboard shortcuts when factory resetting
Reviewed-by: Jakub Brindza <jakub brindza gmail com>
Differential Revision: https://phabricator.freedesktop.org/D1307
pitivi/dialogs/prefs.py | 19 +++++++++++++------
pitivi/shortcuts.py | 3 ++-
2 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index b9288c6..e30b434 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -54,7 +54,7 @@ class PreferencesDialog(Loggable):
def __init__(self, app):
Loggable.__init__(self)
self.app = app
- self.app.shortcuts.connect("accel-changed", self.__do_accel_changed_cb)
+ self.app.shortcuts.connect("accel-changed", self.__accel_changed_cb)
self.settings = app.settings
self.widgets = {}
@@ -77,11 +77,6 @@ class PreferencesDialog(Loggable):
self.__add_shortcuts_section()
self.dialog.set_transient_for(app.gui)
- def __do_accel_changed_cb(self, shortcuts_manager, action_name):
- if action_name:
- index = self.action_ids[action_name]
- self.list_store.emit("items-changed", index, 1, 1)
-
def run(self):
"""Runs the dialog."""
self.dialog.run()
@@ -330,11 +325,23 @@ class PreferencesDialog(Loggable):
"""Resets the accelerator to the default value."""
self.app.shortcuts.reset_accels(item.action_name)
+ def __accel_changed_cb(self, shortcuts_manager, action_name):
+ """Handles the changing of a shortcut's accelerator."""
+ if action_name:
+ index = self.action_ids[action_name]
+ count = 1
+ else:
+ # All items changed.
+ index = 0
+ count = self.list_store.get_n_items()
+ self.list_store.emit("items-changed", index, count, count)
+
def _factorySettingsButtonCb(self, unused_button):
"""Resets all settings to the defaults."""
for section in self.prefs.values():
for attrname in section:
self._resetOptionCb(self.resets[attrname], attrname)
+ self.app.shortcuts.reset_accels()
def _revertButtonCb(self, unused_button):
"""Resets all settings to the values when the dialog was opened."""
diff --git a/pitivi/shortcuts.py b/pitivi/shortcuts.py
index 5950145..2bd6fd5 100644
--- a/pitivi/shortcuts.py
+++ b/pitivi/shortcuts.py
@@ -127,6 +127,7 @@ class ShortcutsManager(GObject.Object):
if action:
self.app.set_accels_for_action(action, self.default_accelerators[action])
self.save()
+ self.emit("accel-changed", action)
else:
for action, accelerators in self.default_accelerators.items():
self.app.set_accels_for_action(action, accelerators)
@@ -134,7 +135,7 @@ class ShortcutsManager(GObject.Object):
os.remove(self.config_path)
except FileNotFoundError:
pass
- self.emit("accel-changed", action)
+ self.emit("accel-changed", None)
class ShortcutsWindow(Gtk.ShortcutsWindow):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]