[gthumb] define the application menu in an external file



commit d78e78abcc79ce89a55b0d6a674b5c3e959b85ae
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Oct 13 15:43:29 2013 +0200

    define the application menu in an external file

 gthumb/gthumb.gresource.xml  |    1 +
 gthumb/main.c                |   35 ++---------------------------------
 gthumb/resources/Makefile.am |    1 +
 gthumb/resources/app-menu.ui |   32 ++++++++++++++++++++++++++++++++
 4 files changed, 36 insertions(+), 33 deletions(-)
---
diff --git a/gthumb/gthumb.gresource.xml b/gthumb/gthumb.gresource.xml
index 756a044..f4864e5 100644
--- a/gthumb/gthumb.gresource.xml
+++ b/gthumb/gthumb.gresource.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/gThumb">
+    <file compressed="true">resources/app-menu.ui</file>
     <file compressed="true">resources/gthumb.css</file>
     <file compressed="true">resources/message-dialog.ui</file>
   </gresource>
diff --git a/gthumb/main.c b/gthumb/main.c
index 9392a7d..aac1134 100644
--- a/gthumb/main.c
+++ b/gthumb/main.c
@@ -42,6 +42,7 @@
 #include "gth-main.h"
 #include "gth-preferences.h"
 #include "gth-window-actions-callbacks.h"
+#include "gtk-utils.h"
 #include "main-migrate.h"
 
 
@@ -403,7 +404,6 @@ _gth_application_initialize_app_menu (GApplication *application)
 {
        gboolean    show_app_menu;
        GtkBuilder *builder;
-       GError     *error = NULL;
 
        g_object_get (gtk_settings_get_default (),
                      "gtk-shell-shows-app-menu", &show_app_menu,
@@ -416,38 +416,7 @@ _gth_application_initialize_app_menu (GApplication *application)
                                         G_N_ELEMENTS (app_menu_entries),
                                         application);
 
-       builder = gtk_builder_new ();
-       gtk_builder_add_from_string (builder,
-                       "<interface>"
-                       "  <menu id='app-menu'>"
-                       "    <section>"
-                       "      <item>"
-                       "        <attribute name='label' translatable='yes'>New _Window</attribute>"
-                       "        <attribute name='action'>app.new-window</attribute>"
-                       "      </item>"
-                       "    </section>"
-                       "    <section>"
-                       "      <item>"
-                       "        <attribute name='label' translatable='yes'>_Preferences</attribute>"
-                       "        <attribute name='action'>app.preferences</attribute>"
-                       "      </item>"
-                       "    </section>"
-                       "    <section>"
-                       "      <item>"
-                       "        <attribute name='label' translatable='yes'>_Help</attribute>"
-                       "        <attribute name='action'>app.help</attribute>"
-                       "      </item>"
-                       "      <item>"
-                       "        <attribute name='label' translatable='yes'>_About gThumb</attribute>"
-                       "        <attribute name='action'>app.about</attribute>"
-                       "      </item>"
-                       "      <item>"
-                       "        <attribute name='label' translatable='yes'>_Quit</attribute>"
-                       "        <attribute name='action'>app.quit</attribute>"
-                       "      </item>"
-                       "    </section>"
-                       "  </menu>"
-                       "</interface>", -1, &error);
+       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")));
 
diff --git a/gthumb/resources/Makefile.am b/gthumb/resources/Makefile.am
index bb720a1..5f420d3 100644
--- a/gthumb/resources/Makefile.am
+++ b/gthumb/resources/Makefile.am
@@ -1,4 +1,5 @@
 EXTRA_DIST =                   \
+       app-menu.ui             \
        gthumb.css              \
        message-dialog.ui
        
diff --git a/gthumb/resources/app-menu.ui b/gthumb/resources/app-menu.ui
new file mode 100644
index 0000000..1c9b6cb
--- /dev/null
+++ b/gthumb/resources/app-menu.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <menu id='app-menu'>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">New _Window</attribute>
+        <attribute name="action">app.new-window</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Preferences</attribute>
+        <attribute name="action">app.preferences</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="action">app.help</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_About gThumb</attribute>
+        <attribute name="action">app.about</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>


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