[gnome-clocks/wip/helpoverlay] Add a help overlay



commit 8ecd6e31777d39093c73a6c1783f7964bbba0a4e
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Dec 9 07:37:47 2015 -0500

    Add a help overlay
    
    This is just copying the example from gtk3-demo.
    
    Some more work needed:
    - Verify that all the shortcuts are accurate and existing
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757837

 data/gnome-clocks.gresource.xml |    1 +
 data/gtk/help-overlay.ui        |  146 +++++++++++++++++++++++++++++++++++++++
 data/gtk/menus.ui               |    5 ++
 src/window.vala                 |    2 +
 4 files changed, 154 insertions(+), 0 deletions(-)
---
diff --git a/data/gnome-clocks.gresource.xml b/data/gnome-clocks.gresource.xml
index 6305a4d..adee346 100644
--- a/data/gnome-clocks.gresource.xml
+++ b/data/gnome-clocks.gresource.xml
@@ -3,6 +3,7 @@
   <gresource prefix="/org/gnome/clocks">
     <file>css/gnome-clocks.css</file>
     <file preprocess="xml-stripblanks">gtk/menus.ui</file>
+    <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
     <file preprocess="xml-stripblanks">ui/window.ui</file>
     <file preprocess="xml-stripblanks">ui/worldlocationdialog.ui</file>
     <file preprocess="xml-stripblanks">ui/world.ui</file>
diff --git a/data/gtk/help-overlay.ui b/data/gtk/help-overlay.ui
new file mode 100644
index 0000000..c81961f
--- /dev/null
+++ b/data/gtk/help-overlay.ui
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.17 -->
+  <object class="GtkShortcutsWindow" id="help_overlay">
+    <property name="modal">1</property>
+    <child>
+      <object class="GtkShortcutsSection">
+        <property name="visible">1</property>
+        <property name="section-name">shortcuts</property>
+        <property name="max-height">10</property>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes">General</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;Page_Down</property>
+                <property name="title" translatable="yes">Go to the next section</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;Page_Up</property>
+                <property name="title" translatable="yes">Go to the previous section</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;alt&gt;Q</property>
+                <property name="title" translatable="yes">Quit</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;alt&gt;Right</property>
+                <property name="title" translatable="yes">Forward</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;Left</property>
+                <property name="title" translatable="yes">Back</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="view">ClocksWorldFace</property>
+            <property name="title" translatable="yes">World Clocks</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;N</property>
+                <property name="title" translatable="yes">Add a world clock</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;S</property>
+                <property name="title" translatable="yes">Select world clocks</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="view">ClocksAlarmFace</property>
+            <property name="title" translatable="yes">Alarm</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;N</property>
+                <property name="title" translatable="yes">Add an alarm</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;S</property>
+                <property name="title" translatable="yes">Select alarms</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="view">ClocksStopwatchFace</property>
+            <property name="title" translatable="yes">Stopwatch</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">Return space</property>
+                <property name="title" translatable="yes">Start / Stop / Continue</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">L</property>
+                <property name="title" translatable="yes">Lap</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">Delete</property>
+                <property name="title" translatable="yes">Reset</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="view">ClocksTimerFace</property>
+            <property name="title" translatable="yes">Timer</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">Return space</property>
+                <property name="title" translatable="yes">Start / Stop / Pause</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">Delete</property>
+                <property name="title" translatable="yes">Reset</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index 10ac040..d143ac4 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -4,6 +4,11 @@
   <menu id="app-menu">
     <section>
       <item>
+        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+        <attribute name="action">win.show-help-overlay</attribute>
+        <attribute name="accel">&lt;Primary&gt;F1</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_Help</attribute>
         <attribute name="action">win.help</attribute>
         <attribute name="accel">F1</attribute>
diff --git a/src/window.vala b/src/window.vala
index 4fb8bfc..421b113 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -81,6 +81,8 @@ public class Window : Gtk.ApplicationWindow {
         stack_switcher.set_stack (stack);
 
         var stack_id = stack.notify["visible-child"].connect (() => {
+            var help_overlay = get_help_overlay ();
+            help_overlay.view_name = Type.from_instance(stack.visible_child).name();
             update_header_bar ();
         });
 


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