[network-manager-applet/lr/gapplication: 3/4] connection-editor: add an appmenu



commit 5acbe0375289fa9d4d4a9a9cf089a6d2e4e668f7
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu May 17 17:07:13 2018 +0200

    connection-editor: add an appmenu
    
    It just contains a Quit entry solemnly for the purpose of using a
    standard accelerator (Ctrl+Q).
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1539697

 Makefile.am                            |    1 +
 po/POTFILES.in                         |    1 +
 src/connection-editor/ce.gresource.xml |    1 +
 src/connection-editor/gtk/menus.ui     |   12 ++++++++++++
 src/connection-editor/main.c           |   16 ++++++++++++++++
 src/connection-editor/meson.build      |    1 +
 6 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 25c894a..44c06cd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -761,6 +761,7 @@ EXTRA_DIST += \
        src/connection-editor/ce-page-wifi-security.ui \
        src/connection-editor/ce-page-wifi.ui \
        src/connection-editor/ce-ppp-auth-methods.ui \
+       src/connection-editor/gtk/menus.ui \
        src/connection-editor/nm-connection-editor.ui \
        src/connection-editor/nm-connection-list.ui \
        src/connection-editor/ce.gresource.xml \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d94165b..f2e3172 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -46,6 +46,7 @@ src/connection-editor/ce-polkit.c
 src/connection-editor/ce-polkit-button.c
 [type: gettext/glade]src/connection-editor/ce-ppp-auth-methods.ui
 src/connection-editor/connection-helpers.c
+[type: gettext/glade]src/connection-editor/gtk/menus.ui
 src/connection-editor/ip4-routes-dialog.c
 src/connection-editor/ip6-routes-dialog.c
 src/connection-editor/nm-connection-editor.c
diff --git a/src/connection-editor/ce.gresource.xml b/src/connection-editor/ce.gresource.xml
index d404bc3..75e89d3 100644
--- a/src/connection-editor/ce.gresource.xml
+++ b/src/connection-editor/ce.gresource.xml
@@ -28,5 +28,6 @@
                <file preprocess="xml-stripblanks">ce-page-wifi-security.ui</file>
                <file preprocess="xml-stripblanks">ce-page-wifi.ui</file>
                <file preprocess="xml-stripblanks">ce-ppp-auth-methods.ui</file>
+               <file preprocess="xml-stripblanks">gtk/menus.ui</file>
        </gresource>
 </gresources>
diff --git a/src/connection-editor/gtk/menus.ui b/src/connection-editor/gtk/menus.ui
new file mode 100644
index 0000000..8f9750a
--- /dev/null
+++ b/src/connection-editor/gtk/menus.ui
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <menu id="app-menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+        <attribute name="accel">&lt;Primary&gt;q</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index ec4587b..3d743b6 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -167,11 +167,27 @@ signal_handler (gpointer user_data)
 }
 
 static void
+quit_activated (GSimpleAction *action, GVariant *parameter, gpointer user_data)
+{
+       GApplication *application = G_APPLICATION (user_data);
+
+       g_application_quit (application);
+}
+
+static GActionEntry app_entries[] =
+{
+       { "quit", quit_activated, NULL, NULL, NULL },
+};
+
+static void
 editor_startup (GApplication *application, gpointer user_data)
 {
        GtkApplication *app = GTK_APPLICATION (application);
        NMConnectionList *list;
 
+       g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries,
+                                        G_N_ELEMENTS (app_entries), app);
+
        list = nm_connection_list_new ();
        if (!list) {
                g_warning ("Failed to initialize the UI, exiting...");
diff --git a/src/connection-editor/meson.build b/src/connection-editor/meson.build
index 004303e..ef2657b 100644
--- a/src/connection-editor/meson.build
+++ b/src/connection-editor/meson.build
@@ -62,6 +62,7 @@ resource_data = files(
   'ce-page-wifi-security.ui',
   'ce-page-wifi.ui',
   'ce-ppp-auth-methods.ui',
+  'gtk/menus.ui',
   'nm-connection-editor.ui',
   'nm-connection-list.ui'
 )


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