[gnome-terminal/wip/larsu/gmenumodel: 1/4] Let GtkApplication load the app menu automatically



commit 87514f609824017c1abf5d082ba1ac328f80d2de
Author: Lars Uebernickel <lars uebernickel canonical com>
Date:   Wed Feb 25 15:36:20 2015 +0100

    Let GtkApplication load the app menu automatically
    
    GtkApplication automatically loads the app-menu from
    $BASE_RESOURCE_PATH/gtk/menus.ui. Rename the resource and menu
    identifier to actually make it do that and remove the code that loaded
    the menu manually.
    
    Also remove trailing '/' from TERMINAL_RESOURCES_PATH_PREFIX so that we
    can use it with g_application_set_resource_base_path().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734791

 src/Makefile.am                                |    2 +-
 src/terminal-app.c                             |   12 +-----------
 src/terminal-app.h                             |    2 +-
 src/{terminal-appmenu.ui => terminal-menus.ui} |    2 +-
 src/terminal-util.c                            |    2 +-
 src/terminal-window.c                          |    2 +-
 src/terminal.gresource.xml                     |    2 +-
 7 files changed, 7 insertions(+), 17 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 4848e51..ac4420e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -372,7 +372,7 @@ CLEANFILES = \
 EXTRA_DIST = \
        terminal.about \
        terminal.xml \
-       terminal-appmenu.ui \
+       terminal-menus.ui \
        terminal-window.ui \
        terminal.gresource.xml \
        terminal-marshal.list \
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 94fa35b..8af60f4 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -321,8 +321,7 @@ terminal_app_startup (GApplication *application)
     { "quit",        app_menu_quit_cb,          NULL, NULL, NULL }
   };
 
-  gs_unref_object GtkBuilder *builder;
-  GError *error = NULL;
+  g_application_set_resource_base_path (application, TERMINAL_RESOURCES_PATH_PREFIX);
 
   G_APPLICATION_CLASS (terminal_app_parent_class)->startup (application);
 
@@ -333,15 +332,6 @@ terminal_app_startup (GApplication *application)
                                    app_menu_actions, G_N_ELEMENTS (app_menu_actions),
                                    application);
 
-  builder = gtk_builder_new ();
-  gtk_builder_add_from_resource (builder,
-                                 TERMINAL_RESOURCES_PATH_PREFIX "ui/terminal-appmenu.ui",
-                                 &error);
-  g_assert_no_error (error);
-
-  gtk_application_set_app_menu (GTK_APPLICATION (application),
-                                G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")));
-
   _terminal_debug_print (TERMINAL_DEBUG_SERVER, "Startup complete\n");
 }
 
diff --git a/src/terminal-app.h b/src/terminal-app.h
index 9502845..20cb3ee 100644
--- a/src/terminal-app.h
+++ b/src/terminal-app.h
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
 
 #define GNOME_TERMINAL_ICON_NAME "utilities-terminal"
 
-#define TERMINAL_RESOURCES_PATH_PREFIX "/org/gnome/terminal/"
+#define TERMINAL_RESOURCES_PATH_PREFIX "/org/gnome/terminal"
 
 #define MONOSPACE_FONT_KEY_NAME                 "monospace-font-name"
 
diff --git a/src/terminal-appmenu.ui b/src/terminal-menus.ui
similarity index 98%
rename from src/terminal-appmenu.ui
rename to src/terminal-menus.ui
index 01ff5a8..e248590 100644
--- a/src/terminal-appmenu.ui
+++ b/src/terminal-menus.ui
@@ -16,7 +16,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <interface>
-  <menu id="appmenu">
+  <menu id="app-menu">
     <section>
       <item>
         <attribute name="label" translatable="yes">_New Terminal</attribute>
diff --git a/src/terminal-util.c b/src/terminal-util.c
index 90fcb15..b4e5527 100644
--- a/src/terminal-util.c
+++ b/src/terminal-util.c
@@ -172,7 +172,7 @@ terminal_util_show_about (GtkWindow *transient_parent)
   gs_free char *comment;
   gs_free char *vte_version;
 
-  bytes = g_resources_lookup_data (TERMINAL_RESOURCES_PATH_PREFIX "ui/terminal.about", 
+  bytes = g_resources_lookup_data (TERMINAL_RESOURCES_PATH_PREFIX "/ui/terminal.about",
                                    G_RESOURCE_LOOKUP_FLAGS_NONE,
                                    &error);
   g_assert_no_error (error);
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 12cae4f..c11f19e 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -2672,7 +2672,7 @@ terminal_window_init (TerminalWindow *window)
   /* Load the UI */
   error = NULL;
   priv->ui_id = gtk_ui_manager_add_ui_from_resource (manager,
-                                                     TERMINAL_RESOURCES_PATH_PREFIX "ui/terminal.xml",
+                                                     TERMINAL_RESOURCES_PATH_PREFIX "/ui/terminal.xml",
                                                      &error);
   g_assert_no_error (error);
 
diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml
index ec07643..abab042 100644
--- a/src/terminal.gresource.xml
+++ b/src/terminal.gresource.xml
@@ -18,11 +18,11 @@
 <gresources>
   <gresource prefix="/org/gnome/terminal">
     <file alias="ui/terminal.xml" compressed="true" preprocess="xml-stripblanks">terminal.xml</file>
-    <file alias="ui/terminal-appmenu.ui" compressed="true" 
preprocess="xml-stripblanks">terminal-appmenu.ui</file>
     <file alias="ui/terminal.about" compressed="true">terminal.about</file>
     <file alias="ui/find-dialog.ui" compressed="true" preprocess="xml-stripblanks">find-dialog.ui</file>
     <file alias="ui/preferences.ui" compressed="true" preprocess="xml-stripblanks">preferences.ui</file>
     <file alias="ui/profile-preferences.ui" compressed="true" 
preprocess="xml-stripblanks">profile-preferences.ui</file>
     <file alias="ui/window.ui" compressed="true" preprocess="xml-stripblanks">terminal-window.ui</file>
+    <file alias="gtk/menus.ui" compressed="true" preprocess="xml-stripblanks">terminal-menus.ui</file>
   </gresource>
 </gresources>


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