[file-roller] removed app menu, register app actions accelerators



commit a84aa5fde2207cd20717ea5ad158cc146996a593
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Oct 8 19:33:46 2018 +0200

    removed app menu, register app actions accelerators

 po/POTFILES.in                |  1 -
 src/file-roller.gresource.xml |  1 -
 src/fr-application-menu.c     | 17 +++++++++------
 src/gtk-utils.c               | 28 ++++++++++++++++++++++++
 src/gtk-utils.h               |  6 ++++++
 src/ui/app-menu.ui            | 50 -------------------------------------------
 src/ui/gears-menu.ui          | 41 +++++++++++++++++++++++++++++++++--
 7 files changed, 83 insertions(+), 61 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7c547721..84a06aa9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -129,7 +129,6 @@ src/test-server.c
 src/typedefs.h
 src/ui/add-dialog-options.ui
 src/ui/add-options.ui
-src/ui/app-menu.ui
 src/ui/app-menubar.ui
 src/ui/ask-password.ui
 src/ui/delete.ui
diff --git a/src/file-roller.gresource.xml b/src/file-roller.gresource.xml
index a4ef234b..7ee944cd 100644
--- a/src/file-roller.gresource.xml
+++ b/src/file-roller.gresource.xml
@@ -3,7 +3,6 @@
   <gresource prefix="/org/gnome/FileRoller">
     <file compressed="true">ui/add-dialog-options.ui</file>
     <file compressed="true">ui/add-options.ui</file>
-    <file compressed="true">ui/app-menu.ui</file>
     <file compressed="true">ui/app-menubar.ui</file>
     <file compressed="true">ui/ask-password.ui</file>
     <file compressed="true">ui/delete.ui</file>
diff --git a/src/fr-application-menu.c b/src/fr-application-menu.c
index fba19508..9a7206ba 100644
--- a/src/fr-application-menu.c
+++ b/src/fr-application-menu.c
@@ -159,6 +159,14 @@ static const GActionEntry app_menu_entries[] = {
 };
 
 
+static const FrAccelerator fr_app_accelerators[] = {
+       { "app.new", "<Control>n" },
+       { "app.open", "<Control>o" },
+       { "app.help", "F1" },
+       { "app.quit", "<Control>q" }
+};
+
+
 static void
 pref_view_sidebar_changed (GSettings  *settings,
                           const char *key,
@@ -189,18 +197,13 @@ pref_list_mode_changed (GSettings  *settings,
 void
 initialize_app_menu (GApplication *application)
 {
-       GtkBuilder *builder;
-       GSettings  *settings;
+       GSettings *settings;
 
        g_action_map_add_action_entries (G_ACTION_MAP (application),
                                         app_menu_entries,
                                         G_N_ELEMENTS (app_menu_entries),
                                         application);
-
-       builder = _gtk_builder_new_from_resource ("app-menu.ui");
-       gtk_application_set_app_menu (GTK_APPLICATION (application),
-                                     G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
-       g_object_unref (builder);
+       _gtk_application_add_accelerators (GTK_APPLICATION (application), fr_app_accelerators);
 
        settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI);
        g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR),
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index d4d78c0f..08c45fee 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -878,3 +878,31 @@ _gtk_settings_get_dialogs_use_header (void)
 
        return use_header;
 }
+
+
+void
+_gtk_application_add_accelerator_for_action (GtkApplication   *app,
+                                            const char       *action_name,
+                                            const char       *accel)
+{
+       const char *accels[2];
+
+       accels[0] = accel;
+       accels[1] = NULL;
+       gtk_application_set_accels_for_action (app, action_name, accels);
+}
+
+
+void
+_gtk_application_add_accelerators (GtkApplication *app,
+                                  FrAccelerator  *accelerators)
+{
+       int i;
+
+       for (i = 0; i < G_N_ELEMENTS (accelerators); i++) {
+               const FrAccelerator *acc = accelerators + i;
+               _gtk_application_add_accelerator_for_action (GTK_APPLICATION (app),
+                                                            acc->action_name,
+                                                            acc->accelerator);
+       }
+}
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index 51d8c921..6e17995a 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -115,5 +115,11 @@ void          _gtk_window_add_accelerators_from_menu
                                                   (GtkWindow        *window,
                                                    GMenuModel       *menu);
 gboolean      _gtk_settings_get_dialogs_use_header (void);
+void          _gtk_application_add_accelerator_for_action
+                                                  (GtkApplication   *app,
+                                                   const char       *action_name,
+                                                   const char       *accel);
+void         _gtk_application_add_accelerators    (GtkApplication   *app,
+                                                   FrAccelerator    *accelerators);
 
 #endif
diff --git a/src/ui/gears-menu.ui b/src/ui/gears-menu.ui
index de07a280..980ece95 100644
--- a/src/ui/gears-menu.ui
+++ b/src/ui/gears-menu.ui
@@ -2,6 +2,18 @@
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <menu id="menu">
+    <section>
+      <item>
+        <attribute name="action">app.new</attribute>
+        <attribute name="label" translatable="yes">_New Archive…</attribute>
+        <attribute name="accel"><![CDATA[<Ctrl>n]]></attribute>
+      </item>
+      <item>
+        <attribute name="action">app.open</attribute>
+        <attribute name="label" translatable="yes">_Open…</attribute>
+        <attribute name="accel"><![CDATA[<Ctrl>o]]></attribute>
+      </item>
+    </section>
     <section>
       <item>
         <attribute name="label" translatable="yes">Save As…</attribute>
@@ -15,13 +27,38 @@
         <attribute name="label" translatable="yes">_Test Integrity</attribute>
         <attribute name="action">win.test-archive</attribute>
       </item>
-    </section>
-    <section>
       <item>
         <attribute name="label" translatable="yes">Properties</attribute>
         <attribute name="action">win.view-properties</attribute>
         <attribute name="accel"><![CDATA[<Alt>Return]]></attribute>
       </item>
     </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">View All _Files</attribute>
+        <attribute name="action">app.list-mode</attribute>
+        <attribute name="target">flat</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">View as a F_older</attribute>
+        <attribute name="action">app.list-mode</attribute>
+        <attribute name="target">as-dir</attribute>
+      </item>
+      <item>
+        <attribute name="action">app.view-sidebar</attribute>
+        <attribute name="label" translatable="yes">Sidebar</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="action">app.help</attribute>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="accel">F1</attribute>
+      </item>
+      <item>
+        <attribute name="action">app.about</attribute>
+        <attribute name="label" translatable="yes">_About</attribute>
+      </item>
+    </section>
   </menu>
 </interface>


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