[gnome-games] shortcuts-window: Don't subclass GtkShortcutsWindow
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] shortcuts-window: Don't subclass GtkShortcutsWindow
- Date: Fri, 16 Oct 2020 16:20:42 +0000 (UTC)
commit 44bdfc93ff635d1dfec63929a2eed2086e15b336
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Mon Aug 19 15:55:51 2019 +0500
shortcuts-window: Don't subclass GtkShortcutsWindow
Instead, use a standard help-overlay.ui and init the RTL logic in
ApplicationWindow.
Manually activate win.show-help-overlay on ctrl+?, later we should be able
to register a proper shortcut for this.
data/{ui/shortcuts-window.ui => gtk/help-overlay.ui} | 7 +++----
data/org.gnome.Games.gresource.xml | 2 +-
src/main.vala | 3 +++
src/meson.build | 1 -
src/ui/application-window.vala | 19 ++++++++++++++++++-
src/ui/collection-view.vala | 6 ++++--
src/ui/shortcuts-window.vala | 20 --------------------
7 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/data/ui/shortcuts-window.ui b/data/gtk/help-overlay.ui
similarity index 98%
rename from data/ui/shortcuts-window.ui
rename to data/gtk/help-overlay.ui
index 4cd656cc..8a14bee9 100644
--- a/data/ui/shortcuts-window.ui
+++ b/data/gtk/help-overlay.ui
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesShortcutsWindow" parent="GtkShortcutsWindow">
- <property name="modal">1</property>
- <signal name="direction-changed" after="yes" handler="update_direction"/>
+ <object class="GtkShortcutsWindow" id="help_overlay">
+ <property name="modal">True</property>
<child>
<object class="GtkShortcutsSection">
<property name="max-height">12</property>
@@ -259,7 +258,7 @@
</child>
</object>
</child>
- </template>
+ </object>
<object class="GThemedIcon" id="button_home_icon">
<property name="name">button-home-symbolic</property>
</object>
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index f4756bf9..0256b22c 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -10,6 +10,7 @@
<file preprocess="xml-stripblanks">gesture/dpad-symbolic.svg</file>
<file preprocess="xml-stripblanks">gesture/shoulders-front-symbolic.svg</file>
<file preprocess="xml-stripblanks">gesture/stick-symbolic.svg</file>
+ <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">ui/application-window.ui</file>
<file preprocess="xml-stripblanks">ui/checkmark-item.ui</file>
<file preprocess="xml-stripblanks">ui/collection-action-window.ui</file>
@@ -47,7 +48,6 @@
<file preprocess="xml-stripblanks">ui/remote-display.ui</file>
<file preprocess="xml-stripblanks">ui/search-bar.ui</file>
<file preprocess="xml-stripblanks">ui/selection-action-bar.ui</file>
- <file preprocess="xml-stripblanks">ui/shortcuts-window.ui</file>
<file preprocess="xml-stripblanks">ui/snapshot-row.ui</file>
<file preprocess="xml-stripblanks">ui/snapshots-list.ui</file>
<file preprocess="xml-stripblanks">ui/undo-notification.ui</file>
diff --git a/src/main.vala b/src/main.vala
index bded1f53..39eb4a14 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -10,6 +10,9 @@ int main (string[] args) {
Grl.init (ref unowned_args);
+ // Needed for shortcuts window
+ typeof (ThemedIcon).ensure ();
+
var app = new Games.Application ();
var result = app.run (args);
diff --git a/src/meson.build b/src/meson.build
index aff81fbe..9955f645 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -158,7 +158,6 @@ vala_sources = [
'ui/remote-display.vala',
'ui/search-bar.vala',
'ui/selection-action-bar.vala',
- 'ui/shortcuts-window.vala',
'ui/snapshot-row.vala',
'ui/snapshot-thumbnail.vala',
'ui/snapshots-list.vala',
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 96adb05c..8bf68f1d 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -93,7 +93,24 @@ private class Games.ApplicationWindow : Hdy.ApplicationWindow {
if (Config.PROFILE == "Devel")
get_style_context ().add_class ("devel");
- set_help_overlay (new ShortcutsWindow ());
+ init_help_overlay ();
+ }
+
+ private void init_help_overlay () {
+ var builder = new Gtk.Builder.from_resource ("/org/gnome/Games/gtk/help-overlay.ui");
+ var shortcuts_window = builder.get_object ("help_overlay") as Gtk.ShortcutsWindow;
+ var shortcut = builder.get_object ("general_shortcut_alt_left") as Gtk.ShortcutsShortcut;
+
+ shortcuts_window.direction_changed.connect (() => {
+ shortcut.accelerator = get_alt_left_right ();
+ });
+ shortcut.accelerator = get_alt_left_right ();
+
+ set_help_overlay (shortcuts_window);
+ }
+
+ private string get_alt_left_right () {
+ return get_direction () == Gtk.TextDirection.LTR ? "<alt>Left" : "<alt>Right";
}
public void run_search (string query) {
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 04fe71d8..2af67499 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -217,8 +217,10 @@ private class Games.CollectionView : Gtk.Box, UiView {
if ((keyval == Gdk.Key.question) &&
(event.state & default_modifiers) == (Gdk.ModifierType.CONTROL_MASK |
Gdk.ModifierType.SHIFT_MASK)) {
- var shortcuts_window = new ShortcutsWindow ();
- shortcuts_window.show_all();
+ var win = window as Gtk.ApplicationWindow;
+ var action = win.lookup_action ("show-help-overlay");
+
+ action.activate (null);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]