[gnome-games/wip/exalm/ds-popover: 30/30] Show the shortcut in shortcuts window
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/ds-popover: 30/30] Show the shortcut in shortcuts window
- Date: Fri, 18 Jan 2019 20:19:38 +0000 (UTC)
commit 2184d309cea461504bec030fc74a9680bea97deb
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sat Jan 19 01:17:36 2019 +0500
Show the shortcut in shortcuts window
data/ui/shortcuts-window.ui | 2 +-
plugins/nintendo-ds/src/nintendo-ds-plugin.vala | 24 ++++++++++++++++++++++++
src/core/plugin.vala | 4 ++++
src/ui/shortcuts-window.vala | 16 ++++++++++++++++
4 files changed, 45 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/shortcuts-window.ui b/data/ui/shortcuts-window.ui
index 2b73d330..fc2a6903 100644
--- a/data/ui/shortcuts-window.ui
+++ b/data/ui/shortcuts-window.ui
@@ -4,7 +4,7 @@
<property name="modal">1</property>
<signal name="direction-changed" after="yes" handler="update_direction"/>
<child>
- <object class="GtkShortcutsSection">
+ <object class="GtkShortcutsSection" id="shortcuts_section">
<property name="max-height">12</property>
<property name="section-name">shortcuts</property>
<property name="title" translatable="yes">Shortcuts</property>
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index ec8d2519..13cfead8 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -24,6 +24,30 @@ private class Games.NintendoDsPlugin : Object, Plugin {
return { factory };
}
+ public virtual Gtk.ShortcutsGroup get_shortcuts_group () {
+ var group = Object.new (typeof (Gtk.ShortcutsGroup)) as Gtk.ShortcutsGroup;
+ group.visible = true;
+ group.title = _("Nintendo DS");
+
+ var shortcut = Object.new (typeof (Gtk.ShortcutsShortcut)) as Gtk.ShortcutsShortcut;
+ shortcut.visible = true;
+ shortcut.title = _("Swap screens");
+ shortcut.accelerator = "<ctrl>s";
+ group.add (shortcut);
+
+ var file = File.new_for_uri ("resource:///org/gnome/Games/gesture/stick-symbolic.svg");
+
+ shortcut = Object.new (typeof (Gtk.ShortcutsShortcut)) as Gtk.ShortcutsShortcut;
+ shortcut.visible = true;
+ shortcut.shortcut_type = Gtk.ShortcutType.GESTURE;
+ shortcut.icon = new FileIcon (file);
+ shortcut.title = _("Swap screens");
+ shortcut.subtitle = _("Right analog stick press");
+ group.add (shortcut);
+
+ return group;
+ }
+
private static Game game_for_uri (Uri uri) throws Error {
var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
var title = new FilenameTitle (uri);
diff --git a/src/core/plugin.vala b/src/core/plugin.vala
index 74d8a3eb..fbb37959 100644
--- a/src/core/plugin.vala
+++ b/src/core/plugin.vala
@@ -12,4 +12,8 @@ public interface Games.Plugin : Object {
public virtual UriGameFactory[] get_uri_game_factories () {
return {};
}
+
+ public virtual Gtk.ShortcutsGroup get_shortcuts_group () {
+ return null;
+ }
}
diff --git a/src/ui/shortcuts-window.vala b/src/ui/shortcuts-window.vala
index 7a665bab..5849b7ff 100644
--- a/src/ui/shortcuts-window.vala
+++ b/src/ui/shortcuts-window.vala
@@ -21,6 +21,9 @@ private class Games.ShortcutsWindow : Gtk.ShortcutsWindow {
[GtkChild]
private Gtk.ShortcutsShortcut ingame_shortcut_east;
+ [GtkChild]
+ private Gtk.ShortcutsSection shortcuts_section;
+
construct {
update_direction ();
@@ -32,6 +35,19 @@ private class Games.ShortcutsWindow : Gtk.ShortcutsWindow {
ingame_shortcut_home.icon = icon_for_uri
("resource:///org/gnome/Games/gesture/button-home-symbolic.svg");
ingame_shortcut_south.icon = icon_for_uri
("resource:///org/gnome/Games/gesture/button-south-symbolic.svg");
ingame_shortcut_east.icon = icon_for_uri
("resource:///org/gnome/Games/gesture/button-east-symbolic.svg");
+
+ var register = PluginRegister.get_register ();
+ foreach (var plugin_registrar in register)
+ add_plugin_shortcuts (plugin_registrar);
+ }
+
+ private void add_plugin_shortcuts (PluginRegistrar plugin_registrar) {
+ var plugin = plugin_registrar.get_plugin ();
+
+ var group = plugin.get_shortcuts_group ();
+
+ if (group != null)
+ shortcuts_section.add (group);
}
static GLib.Icon icon_for_uri (string uri) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]