[gnome-system-monitor] Add help-overlay.ui and related changes



commit cab5da5efdd921a4a8c22a54bae910fec7b24efb
Author: Sabri Ünal <libreajans gmail com>
Date:   Wed Nov 4 18:30:38 2020 +0000

    Add help-overlay.ui and related changes

 data/help-overlay.ui  | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++
 data/menus.ui         |   8 +++
 po/POTFILES.in        |   1 +
 src/gsm.gresource.xml |   1 +
 src/interface.cpp     |  12 +++++
 5 files changed, 166 insertions(+)
---
diff --git a/data/help-overlay.ui b/data/help-overlay.ui
new file mode 100644
index 00000000..daadf541
--- /dev/null
+++ b/data/help-overlay.ui
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkShortcutsWindow" id="help_overlay">
+    <property name="modal">true</property>
+    <child>
+      <object class="GtkShortcutsSection">
+        <property name="visible">true</property>
+        <property name="section-name">shortcuts</property>
+        <property name="max-height">13</property>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">true</property>
+            <property name="title" translatable="yes" context="shortcut window">General</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">F1</property>
+                <property name="title" translatable="yes" context="shortcut window">Show help</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">F10</property>
+                <property name="title" translatable="yes" context="shortcut window">Open menu</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;question</property>
+                <property name="title" translatable="yes" context="shortcut window">Keyboard 
shortcuts</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;Q</property>
+                <property name="title" translatable="yes" context="shortcut window">Quit</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;F</property>
+                <property name="title" translatable="yes" context="shortcut window">Search</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Alt&gt;1</property>
+                <property name="title" translatable="yes" context="shortcut window">Show Processes</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Alt&gt;2</property>
+                <property name="title" translatable="yes" context="shortcut window">Show Resources</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Alt&gt;3</property>
+                <property name="title" translatable="yes" context="shortcut window">Show File 
Systems</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;R</property>
+                <property name="title" translatable="yes" context="shortcut window">Refresh</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">true</property>
+            <property name="title" translatable="yes" context="shortcut window">Processes</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;D</property>
+                <property name="title" translatable="yes" context="shortcut window">Show 
dependencies</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Alt&gt;Return</property>
+                <property name="title" translatable="yes" context="shortcut window">Show process 
properties</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;M</property>
+                <property name="title" translatable="yes" context="shortcut window">Memory maps</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;O</property>
+                <property name="title" translatable="yes" context="shortcut window">Open files</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;S</property>
+                <property name="title" translatable="yes" context="shortcut window">Send stop 
signal</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;C</property>
+                <property name="title" translatable="yes" context="shortcut window">Send continue 
signal</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;E</property>
+                <property name="title" translatable="yes" context="shortcut window">Send End 
signal</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">true</property>
+                <property name="accelerator">&lt;Primary&gt;K</property>
+                <property name="title" translatable="yes" context="shortcut window">Send Kill 
signal</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/data/menus.ui b/data/menus.ui
index c395e65d..3c44864e 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -16,6 +16,10 @@
         <attribute name="label" translatable="yes">Help</attribute>
         <attribute name="action">app.help</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
+        <attribute name="action">win.show-help-overlay</attribute>
+      </item>
       <item>
         <attribute name="label" translatable="yes">About System Monitor</attribute>
         <attribute name="action">win.about</attribute>
@@ -67,6 +71,10 @@
         <attribute name="label" translatable="yes">Help</attribute>
         <attribute name="action">app.help</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
+        <attribute name="action">win.show-help-overlay</attribute>
+      </item>
       <item>
         <attribute name="label" translatable="yes">About System Monitor</attribute>
         <attribute name="action">win.about</attribute>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8c822284..ad65d7d6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ gnome-system-monitor.desktop.in.in
 gnome-system-monitor-kde.desktop.in.in
 gnome-system-monitor.appdata.xml.in
 org.gnome.gnome-system-monitor.policy.in.in
+data/help-overlay.ui
 data/interface.ui
 data/lsof.ui
 data/menus.ui
diff --git a/src/gsm.gresource.xml b/src/gsm.gresource.xml
index d6b4a8dd..a8abf390 100644
--- a/src/gsm.gresource.xml
+++ b/src/gsm.gresource.xml
@@ -9,5 +9,6 @@
     <file preprocess="xml-stripblanks">data/menus.ui</file>
     <file preprocess="xml-stripblanks">pixmaps/download.svg</file>
     <file preprocess="xml-stripblanks">pixmaps/upload.svg</file>
+    <file preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">data/help-overlay.ui</file>
   </gresource>
 </gresources>
diff --git a/src/interface.cpp b/src/interface.cpp
index f137db5d..17219ea2 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -419,6 +419,13 @@ on_activate_about (GSimpleAction *, GVariant *, gpointer data)
         );
 }
 
+static void
+on_activate_keyboard_shortcuts (GSimpleAction *, GVariant *, gpointer data)
+{
+    GsmApplication *app = (GsmApplication *) data;
+    gtk_widget_show (GTK_WIDGET (gtk_application_window_get_help_overlay (app->main_window)));
+}
+
 static void
 on_activate_refresh (GSimpleAction *, GVariant *, gpointer data)
 {
@@ -690,12 +697,16 @@ create_main_window (GsmApplication *app)
     GtkBuilder *builder = gtk_builder_new();
     gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/interface.ui", NULL);
     gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/menus.ui", NULL);
+    gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/gtk/help-overlay.ui", NULL);
 
     main_window = GTK_APPLICATION_WINDOW (gtk_builder_get_object (builder, "main_window"));
     gtk_window_set_application (GTK_WINDOW (main_window), app->gobj());
     gtk_widget_set_name (GTK_WIDGET (main_window), "gnome-system-monitor");
     app->main_window = main_window;
 
+    gtk_application_window_set_help_overlay (app->main_window, 
+                                             GTK_SHORTCUTS_WINDOW (gtk_builder_get_object (builder, 
"help_overlay")));
+
     session = g_getenv ("XDG_CURRENT_DESKTOP");
     if (session && !strstr (session, "GNOME")){
         GtkBox *mainbox;
@@ -743,6 +754,7 @@ create_main_window (GsmApplication *app)
 
     GActionEntry win_action_entries[] = {
         { "about", on_activate_about, NULL, NULL, NULL },
+        { "show-help-overlay", on_activate_keyboard_shortcuts,  NULL, NULL, NULL},
         { "search", on_activate_search, "b", "false", NULL },
         { "send-signal-stop", on_activate_send_signal, "i", NULL, NULL },
         { "send-signal-cont", on_activate_send_signal, "i", NULL, NULL },


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