[bijiben/wip/sadiq/modernize: 3/8] app-menu: Simplify setting Application menu



commit 17d73867f74d417e80915c1b7375ce6ca393fa63
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Wed Oct 25 18:00:51 2017 +0530

    app-menu: Simplify setting Application menu
    
    gtk_application() looks for "gtk/menus.ui" and set it as app-menu if
    it has a menu with id "app-menu".
    
    So set the resource path such so that we don't have to manually take
    care of configuring the menu.
    
    This is a part of effort to clean up codebase and make the code
    more maintainable.
    https://bugzilla.gnome.org/show_bug.cgi?id=789696

 src/bjb-app-menu.c    |    9 ---------
 src/bjb.gresource.xml |    5 ++++-
 2 files changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/src/bjb-app-menu.c b/src/bjb-app-menu.c
index f1877a9..dff6324 100644
--- a/src/bjb-app-menu.c
+++ b/src/bjb-app-menu.c
@@ -163,17 +163,8 @@ static GActionEntry app_entries[] = {
 
 void bjb_app_menu_set(GApplication *application)
 {
-  GtkBuilder *builder;
-
   g_action_map_add_action_entries (G_ACTION_MAP (application),
                                    app_entries,
                                    G_N_ELEMENTS (app_entries),
                                    application);
-
-  builder = gtk_builder_new ();
-  gtk_builder_add_from_resource (builder, "/org/gnome/bijiben/app-menu.ui", NULL);
-
-  gtk_application_set_app_menu (GTK_APPLICATION (application),
-                                G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
-  g_object_unref (builder);
 }
diff --git a/src/bjb.gresource.xml b/src/bjb.gresource.xml
index a3f5149..690c927 100644
--- a/src/bjb.gresource.xml
+++ b/src/bjb.gresource.xml
@@ -2,12 +2,15 @@
 <gresources>
   <gresource prefix="/org/gnome/bijiben">
     <file alias="Adwaita.css">resources/Adwaita.css</file>
-    <file alias="app-menu.ui">resources/app-menu.ui</file>
     <file alias="editor-toolbar.ui" compressed="true" 
preprocess="xml-stripblanks">resources/editor-toolbar.ui</file>
     <file alias="thumbnail-frame.png">resources/thumbnail-frame.png</file>
     <file alias="note-symbolic.svg">resources/note-symbolic.svg</file>
   </gresource>
 
+  <gresource prefix="/org/gnome/bijiben/gtk">
+    <file alias="menus.ui">resources/app-menu.ui</file>
+  </gresource>
+    
   <gresource prefix="/org/gnome/bijiben/ui">
     <file alias="settings-dialog.ui">resources/settings-dialog.ui</file>
   </gresource>


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