[gedit/wip/shortcuts: 1/2] Add shortcuts window



commit 66d98becb43bdb099313cdec9afeaa5cf60ef4e3
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Dec 8 19:26:27 2015 +0100

    Add shortcuts window

 gedit/gedit-app.c                        |   15 +++
 gedit/gedit-commands-help.c              |   31 ++++++
 gedit/gedit-commands-private.h           |    1 +
 gedit/resources/gedit.gresource.xml.in   |    1 +
 gedit/resources/gtk/menus-default.ui     |    4 +
 gedit/resources/gtk/menus-osx.ui         |    4 +
 gedit/resources/gtk/menus-traditional.ui |    4 +
 gedit/resources/ui/gedit-shortcuts.ui    |  172 ++++++++++++++++++++++++++++++
 po/POTFILES.in                           |    1 +
 9 files changed, 233 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index db5300f..afa05a4 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -560,6 +560,20 @@ preferences_activated (GSimpleAction  *action,
 }
 
 static void
+keyboard_shortcuts_activated (GSimpleAction *action,
+                              GVariant      *parameter,
+                              gpointer       user_data)
+{
+       GtkApplication *app;
+       GeditWindow *window;
+
+       app = GTK_APPLICATION (user_data);
+       window = GEDIT_WINDOW (gtk_application_get_active_window (app));
+
+       _gedit_cmd_help_keyboard_shortcuts (window);
+}
+
+static void
 help_activated (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
@@ -599,6 +613,7 @@ static GActionEntry app_entries[] = {
        { "new-window", new_window_activated, NULL, NULL, NULL },
        { "new-document", new_document_activated, NULL, NULL, NULL },
        { "preferences", preferences_activated, NULL, NULL, NULL },
+       { "shortcuts", keyboard_shortcuts_activated, NULL, NULL, NULL },
        { "help", help_activated, NULL, NULL, NULL },
        { "about", about_activated, NULL, NULL, NULL },
        { "quit", quit_activated, NULL, NULL, NULL }
diff --git a/gedit/gedit-commands-help.c b/gedit/gedit-commands-help.c
index 5f45f9c..42b7dcb 100644
--- a/gedit/gedit-commands-help.c
+++ b/gedit/gedit-commands-help.c
@@ -35,6 +35,37 @@
 #include "gedit-dirs.h"
 
 void
+_gedit_cmd_help_keyboard_shortcuts (GeditWindow *window)
+{
+       static GtkWidget *shortcuts_window;
+
+       gedit_debug (DEBUG_COMMANDS);
+
+       if (shortcuts_window == NULL)
+       {
+               GtkBuilder *builder;
+
+               builder = gtk_builder_new_from_resource ("/org/gnome/gedit/ui/gedit-shortcuts.ui");
+               shortcuts_window = GTK_WIDGET (gtk_builder_get_object (builder, "shortcuts-gedit"));
+
+               g_signal_connect (shortcuts_window,
+                                 "destroy",
+                                 G_CALLBACK (gtk_widget_destroyed),
+                                 &shortcuts_window);
+
+               g_object_unref (builder);
+       }
+
+       if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (shortcuts_window)))
+       {
+               gtk_window_set_transient_for (GTK_WINDOW (shortcuts_window), GTK_WINDOW (window));
+       }
+
+       gtk_widget_show_all (shortcuts_window);
+       gtk_window_present (GTK_WINDOW (shortcuts_window));
+}
+
+void
 _gedit_cmd_help_contents (GeditWindow *window)
 {
        gedit_debug (DEBUG_COMMANDS);
diff --git a/gedit/gedit-commands-private.h b/gedit/gedit-commands-private.h
index c60f565..80d3431 100644
--- a/gedit/gedit-commands-private.h
+++ b/gedit/gedit-commands-private.h
@@ -156,6 +156,7 @@ void                _gedit_cmd_documents_next_tab_group     (GSimpleAction *action,
                                                         GVariant      *parameter,
                                                         gpointer       user_data);
 
+void           _gedit_cmd_help_keyboard_shortcuts      (GeditWindow *window);
 void           _gedit_cmd_help_contents                (GeditWindow *window);
 void           _gedit_cmd_help_about                   (GeditWindow *window);
 
diff --git a/gedit/resources/gedit.gresource.xml.in b/gedit/resources/gedit.gresource.xml.in
index 9191e31..8d67356 100644
--- a/gedit/resources/gedit.gresource.xml.in
+++ b/gedit/resources/gedit.gresource.xml.in
@@ -17,6 +17,7 @@
     <file preprocess="xml-stripblanks">ui/gedit-highlight-mode-selector.ui</file>
     <file preprocess="xml-stripblanks">ui/gedit-window.ui</file>
     <file preprocess="xml-stripblanks">ui/gedit-open-document-selector.ui</file>
+    <file preprocess="xml-stripblanks">ui/gedit-shortcuts.ui</file>
     <file preprocess="xml-stripblanks">ui/gedit-statusbar.ui</file>
     <file>css/gedit-style.css</file>
     <file>css/gedit.adwaita.css</file>
diff --git a/gedit/resources/gtk/menus-default.ui b/gedit/resources/gtk/menus-default.ui
index 0acd51d..572310c 100644
--- a/gedit/resources/gtk/menus-default.ui
+++ b/gedit/resources/gtk/menus-default.ui
@@ -18,6 +18,10 @@
     </section>
     <section>
       <attribute name="id">help-section</attribute>
+        <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>
diff --git a/gedit/resources/gtk/menus-osx.ui b/gedit/resources/gtk/menus-osx.ui
index e4004d8..110dde0 100644
--- a/gedit/resources/gtk/menus-osx.ui
+++ b/gedit/resources/gtk/menus-osx.ui
@@ -258,6 +258,10 @@
         <section>
           <attribute name="id">help-section</attribute>
           <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/gedit/resources/gtk/menus-traditional.ui b/gedit/resources/gtk/menus-traditional.ui
index 154329f..432bf65 100644
--- a/gedit/resources/gtk/menus-traditional.ui
+++ b/gedit/resources/gtk/menus-traditional.ui
@@ -109,6 +109,10 @@
     <section>
       <attribute name="id">help-section</attribute>
       <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/gedit/resources/ui/gedit-shortcuts.ui b/gedit/resources/ui/gedit-shortcuts.ui
new file mode 100644
index 0000000..acb30d0
--- /dev/null
+++ b/gedit/resources/ui/gedit-shortcuts.ui
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.17 -->
+
+  <object class="GtkShortcutsWindow" id="shortcuts-gedit">
+    <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">Touchpad gestures</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="shortcut-type">gesture-two-finger-swipe-right</property>
+                <property name="title" translatable="yes">Switch to the next document</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="shortcut-type">gesture-two-finger-swipe-left</property>
+                <property name="title" translatable="yes">Switch to the previous document</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes">Documents</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;N</property>
+                <property name="title" translatable="yes">Create new document</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 document</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">Save the document</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 document</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;&lt;Alt&gt;Page_Down</property>
+                <property name="title" translatable="yes">Switch to the next document</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;&lt;Alt&gt;Page_Up</property>
+                <property name="title" translatable="yes">Switch to the previous document</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes">Find and Replace</property>
+            <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;G</property>
+                <property name="title" translatable="yes">Find the next match</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;&lt;Shift&gt;G</property>
+                <property name="title" translatable="yes">Find the previous match</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;H</property>
+                <property name="title" translatable="yes">Find and Replace</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;&lt;Shift&gt;K</property>
+                <property name="title" translatable="yes">Clear highlight</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;I</property>
+                <property name="title" translatable="yes">Go to line</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes">Tools</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;shift&gt;F7</property>
+                <property name="title" translatable="yes">Check spelling</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes">Miscellaneous</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">F11</property>
+                <property name="title" translatable="yes">Fullscreen on / off</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;P</property>
+                <property name="title" translatable="yes">Print the document</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">Insert</property>
+                <property name="title" translatable="yes">Toggle insert / overwrite</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c6c81e8..e75e553 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -50,6 +50,7 @@ gedit/gedit-window.c
 [type: gettext/glade]gedit/resources/ui/gedit-print-preferences.ui
 [type: gettext/glade]gedit/resources/ui/gedit-print-preview.ui
 [type: gettext/glade]gedit/resources/ui/gedit-replace-dialog.ui
+[type: gettext/glade]gedit/resources/ui/gedit-shortcuts.ui
 [type: gettext/glade]gedit/resources/ui/gedit-tab-label.ui
 [type: gettext/glade]gedit/resources/ui/gedit-window.ui
 plugins/checkupdate/checkupdate.plugin.desktop.in


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