[pitivi] shortcuts: Move F1 and F10 to general
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] shortcuts: Move F1 and F10 to general
- Date: Thu, 16 Jun 2016 14:59:17 +0000 (UTC)
commit 306d09e0634631396ad580173d5455c705ee87f5
Author: Jakub Brindza <jakub brindza gmail com>
Date: Thu Jun 16 15:25:49 2016 +0100
shortcuts: Move F1 and F10 to general
Differential Revision: https://phabricator.freedesktop.org/D1088
pitivi/mainwindow.py | 5 +++--
pitivi/shortcutswindow.py | 44 +++++++++++++++++++++++++++++++-------------
2 files changed, 34 insertions(+), 15 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index dc612e3..9a77d93 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -491,14 +491,15 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
self.help_action.connect("activate", self._userManualCb)
self.add_action(self.help_action)
self.app.set_accels_for_action("win.help", ["F1"])
- ShortcutsWindow.add_action("win.help", _("Help"))
+ ShortcutsWindow.add_action("win.help", _("Help"), group="app")
self.menu_button_action = Gio.SimpleAction.new("menu-button", None)
self.menu_button_action.connect("activate", self._menuCb)
self.add_action(self.menu_button_action)
self.app.set_accels_for_action("win.menu-button", ["F10"])
ShortcutsWindow.add_action("win.menu-button",
- _("Show the menu button content"))
+ _("Show the menu button content"),
+ group="app")
def showProjectStatus(self):
project = self.app.project_manager.current_project
diff --git a/pitivi/shortcutswindow.py b/pitivi/shortcutswindow.py
index a07f04a..5840756 100644
--- a/pitivi/shortcutswindow.py
+++ b/pitivi/shortcutswindow.py
@@ -16,13 +16,16 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
+"""Accelerators info."""
from gi.repository import Gtk
from pitivi.utils.misc import show_user_manual
class ShortcutsWindow(Gtk.ShortcutsWindow):
- group_names = {}
+ """Dialog for displaying the accelerators."""
+
+ group_titles = {}
group_actions = {}
groups = []
@@ -34,15 +37,15 @@ class ShortcutsWindow(Gtk.ShortcutsWindow):
self.set_modal(True)
def populate(self):
- """Gathers the accelerators and creates the structure of the window."""
+ """Gathers the accelerators and populates the window."""
section = Gtk.ShortcutsSection()
section.show()
for group_id in ShortcutsWindow.groups:
- group = Gtk.ShortcutsGroup(title=ShortcutsWindow.group_names[group_id])
+ group = Gtk.ShortcutsGroup(title=ShortcutsWindow.group_titles[group_id])
group.show()
- for action, action_description in ShortcutsWindow.group_actions[group_id]:
+ for action, title in ShortcutsWindow.group_actions[group_id]:
accelerators = " ".join(self.app.get_accels_for_action(action))
- short = Gtk.ShortcutsShortcut(title=action_description, accelerator=accelerators)
+ short = Gtk.ShortcutsShortcut(title=title, accelerator=accelerators)
short.show()
group.add(short)
section.add(group)
@@ -51,21 +54,36 @@ class ShortcutsWindow(Gtk.ShortcutsWindow):
self.add(section)
@classmethod
- def add_action(cls, action, accel_description):
- action_prefix = action.split(".")[0]
- try:
- cls.group_actions[action_prefix].append((action, accel_description))
- except KeyError:
- cls.group_actions[action_prefix] = [(action, accel_description)]
+ def add_action(cls, action, title, group=None):
+ """Adds an action to be displayed.
+
+ Args:
+ action (str): The name identifying the action, formatted like
+ "prefix.name".
+ title (str): The title of the action.
+ group (Optional[str]): The group id registered with `register_group`
+ to be used instead of the one extracted from `action`.
+ """
+ action_prefix = group or action.split(".")[0]
+ if action_prefix not in cls.group_actions:
+ cls.group_actions[action_prefix] = []
+ cls.group_actions[action_prefix].append((action, title))
@classmethod
- def register_group(cls, action_prefix, group_name):
+ def register_group(cls, action_prefix, title):
+ """Registers a group of shortcuts to be displayed.
+
+ Args:
+ action_prefix (str): The group id.
+ title (str): The title of the group.
+ """
if action_prefix not in cls.groups:
cls.groups.append(action_prefix)
- cls.group_names[action_prefix] = group_name
+ cls.group_titles[action_prefix] = title
def show_shortcuts(app):
+ """Shows the shortcuts window or the user manual page with the shortcuts."""
if hasattr(Gtk, "ShortcutsWindow"):
shortcuts_window = ShortcutsWindow(app)
shortcuts_window.show()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]