[gnome-clocks] Added ALT + 1,2,3,4 navigation.



commit 963f873c92cebc5bfc35ffa9cf2956fdfe0d227e
Author: Radush Niemczyk <radoslaw n protonmail com>
Date:   Mon Jan 11 20:54:07 2021 +0100

    Added ALT + 1,2,3,4 navigation.
    
    Added new signal for navigation to concrete page.
    Added new shortucts descriptions to the "Keyboard Shortcuts".
    
    Fixes #167

 data/gtk/help-overlay.ui | 28 ++++++++++++++++++++++++++++
 src/window.vala          | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
---
diff --git a/data/gtk/help-overlay.ui b/data/gtk/help-overlay.ui
index 011970c..698ab02 100644
--- a/data/gtk/help-overlay.ui
+++ b/data/gtk/help-overlay.ui
@@ -54,6 +54,34 @@
                 <property name="title" translatable="yes" context="shortcut window">Go to the previous 
section</property>
               </object>
             </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;alt&gt;1</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to the first 
section</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;alt&gt;2</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to the second 
section</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;alt&gt;3</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to the third 
section</property>
+              </object>
+            </child>
+             <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;alt&gt;4</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to the fourth 
section</property>
+              </object>
+            </child>
           </object>
         </child>
         <child>
diff --git a/src/window.vala b/src/window.vala
index 55ac1ba..698dc03 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -133,6 +133,27 @@ public class Window : Hdy.ApplicationWindow {
                                      "change-page", 1,
                                      typeof (int), 1);
 
+        Gtk.BindingEntry.add_signal (binding_set,
+                                    Gdk.Key.@1,
+                                    Gdk.ModifierType.MOD1_MASK,
+                                    "set-page", 1,
+                                    typeof (int), 1);
+        Gtk.BindingEntry.add_signal (binding_set,
+                                    Gdk.Key.@2,
+                                    Gdk.ModifierType.MOD1_MASK,
+                                    "set-page", 1,
+                                    typeof (int), 2);
+        Gtk.BindingEntry.add_signal (binding_set,
+                                    Gdk.Key.@3,
+                                    Gdk.ModifierType.MOD1_MASK,
+                                    "set-page", 1,
+                                    typeof (int), 3);
+        Gtk.BindingEntry.add_signal (binding_set,
+                                    Gdk.Key.@4,
+                                    Gdk.ModifierType.MOD1_MASK,
+                                    "set-page", 1,
+                                    typeof (int), 4);
+
         Gtk.StyleContext style = get_style_context ();
         if (Config.PROFILE == "Devel") {
             style.add_class ("devel");
@@ -181,6 +202,27 @@ public class Window : Hdy.ApplicationWindow {
         }
     }
 
+    [Signal (action = true)]
+    public virtual signal void set_page (int index) {
+        switch (index) {
+            case 1:
+                stack.visible_child = world;
+                break;
+            case 2:
+                stack.visible_child = alarm;
+                break;
+            case 3:
+                stack.visible_child = stopwatch;
+                break;
+            case 4:
+                stack.visible_child = timer;
+                break;
+            default:
+                stack.error_bell ();
+                break;
+        }
+    }
+
     private void on_show_primary_menu_activate (SimpleAction action) {
         var state = ((!) action.get_state ()).get_boolean ();
         action.set_state (new Variant.boolean (!state));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]