[gitg] Provide shortcuts window



commit dc71185a8df3bf10dc73283a61bb6d815948a7a9
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Jan 16 11:33:44 2016 +0100

    Provide shortcuts window
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757878

 gitg/gitg-application.vala           |   26 ++++++++++++-
 gitg/resources/gitg-resources.xml.in |    1 +
 gitg/resources/ui/gitg-menus.ui      |   12 ++++++
 gitg/resources/ui/gitg-shortcuts.ui  |   69 ++++++++++++++++++++++++++++++++++
 4 files changed, 107 insertions(+), 1 deletions(-)
---
diff --git a/gitg/gitg-application.vala b/gitg/gitg-application.vala
index b6bd3f4..893e247 100644
--- a/gitg/gitg-application.vala
+++ b/gitg/gitg-application.vala
@@ -69,6 +69,7 @@ public class Application : Gtk.Application
        }
 
        private PreferencesDialog d_preferences;
+       private Gtk.ShortcutsWindow d_shortcuts;
 
        static construct
        {
@@ -268,6 +269,28 @@ public class Application : Gtk.Application
                d_preferences.present();
        }
 
+       private void on_shortcuts_activated()
+       {
+               unowned List<Gtk.Window> wnds = get_windows();
+
+               // Create preferences dialog if needed
+               if (d_shortcuts == null)
+               {
+                       d_shortcuts = Builder.load_object<Gtk.ShortcutsWindow>("ui/gitg-shortcuts.ui", 
"shortcuts-gitg");
+
+                       d_shortcuts.destroy.connect((w) => {
+                               d_shortcuts = null;
+                       });
+               }
+
+               if (wnds != null)
+               {
+                       d_shortcuts.set_transient_for(wnds.data);
+               }
+
+               d_shortcuts.present();
+       }
+
        private void on_app_author_details_global_activated()
        {
                unowned List<Gtk.Window> wnds = get_windows();
@@ -287,7 +310,8 @@ public class Application : Gtk.Application
                {"about", on_app_about_activated},
                {"quit", on_app_quit_activated},
                {"author-details-global", on_app_author_details_global_activated},
-               {"preferences", on_preferences_activated}
+               {"preferences", on_preferences_activated},
+               {"shortcuts", on_shortcuts_activated}
        };
 
        struct Accel
diff --git a/gitg/resources/gitg-resources.xml.in b/gitg/resources/gitg-resources.xml.in
index 3ba23df..a97175f 100644
--- a/gitg/resources/gitg-resources.xml.in
+++ b/gitg/resources/gitg-resources.xml.in
@@ -22,6 +22,7 @@
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-dash-view.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-simple-notification.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-remote-notification.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">ui/gitg-shortcuts.ui</file>
 
     <file compressed="true">ui/style.css</file>
     <file compressed="true">ui/style- PLATFORM_NAME@.css</file>
diff --git a/gitg/resources/ui/gitg-menus.ui b/gitg/resources/ui/gitg-menus.ui
index ca40d23..a08468f 100644
--- a/gitg/resources/ui/gitg-menus.ui
+++ b/gitg/resources/ui/gitg-menus.ui
@@ -22,6 +22,10 @@
     </section>
     <section>
       <item>
+        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+        <attribute name="action">app.shortcuts</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_Help</attribute>
         <attribute name="action">app.help</attribute>
       </item>
@@ -72,6 +76,10 @@
     </section>
     <section>
       <item>
+        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+        <attribute name="action">app.shortcuts</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_Help</attribute>
         <attribute name="action">app.help</attribute>
       </item>
@@ -114,6 +122,10 @@
     </section>
     <section>
       <item>
+        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+        <attribute name="action">app.shortcuts</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_Help</attribute>
         <attribute name="action">app.help</attribute>
       </item>
diff --git a/gitg/resources/ui/gitg-shortcuts.ui b/gitg/resources/ui/gitg-shortcuts.ui
new file mode 100644
index 0000000..0c70ba2
--- /dev/null
+++ b/gitg/resources/ui/gitg-shortcuts.ui
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.17 -->
+  <object class="GtkShortcutsWindow" id="shortcuts-gitg">
+    <property name="modal">1</property>
+    <child>
+      <object class="GtkShortcutsSection">
+        <property name="visible">1</property>
+        <property name="section-name">shortcuts</property>
+        <property name="max-height">12</property>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes">Windows</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;N</property>
+                <property name="title" translatable="yes">Open a new window</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">F10</property>
+                <property name="title" translatable="yes">Open the window menu</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;O</property>
+                <property name="title" translatable="yes">Open a repository</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">F1</property>
+                <property name="title" translatable="yes">Open the help</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;F</property>
+                <property name="title" translatable="yes">Find</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;W</property>
+                <property name="title" translatable="yes">Close the active window</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;Q</property>
+                <property name="title" translatable="yes">Quit the application</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>


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