[gtk+] icon browser: Load app menu automagically



commit 792857c7b8883c7fbeb44b6b3af3c421d32c6ed5
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 24 20:01:33 2016 -0500

    icon browser: Load app menu automagically
    
    No need to manually create a builder and pass the resource to it,
    just follow the conventions and have GtkApplication do it for us.

 demos/icon-browser/iconbrowser.gresource.xml |    4 ++--
 demos/icon-browser/iconbrowserapp.c          |    7 -------
 demos/icon-browser/iconbrowserwin.c          |    2 +-
 demos/icon-browser/{app-menu.ui => menus.ui} |    2 +-
 4 files changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/demos/icon-browser/iconbrowser.gresource.xml b/demos/icon-browser/iconbrowser.gresource.xml
index 455c684..fd2523a 100644
--- a/demos/icon-browser/iconbrowser.gresource.xml
+++ b/demos/icon-browser/iconbrowser.gresource.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/org/gtk/iconbrowser">
+  <gresource prefix="/org/gtk/iconbrowser/gtk">
     <file preprocess="xml-stripblanks">window.ui</file>
-    <file preprocess="xml-stripblanks">app-menu.ui</file>
+    <file preprocess="xml-stripblanks">menus.ui</file>
   </gresource>
 </gresources>
diff --git a/demos/icon-browser/iconbrowserapp.c b/demos/icon-browser/iconbrowserapp.c
index 1c9065e..fc291d0 100644
--- a/demos/icon-browser/iconbrowserapp.c
+++ b/demos/icon-browser/iconbrowserapp.c
@@ -36,8 +36,6 @@ static GActionEntry app_entries[] =
 static void
 icon_browser_app_startup (GApplication *app)
 {
-  GtkBuilder *builder;
-  GMenuModel *app_menu;
   const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
 
   G_APPLICATION_CLASS (icon_browser_app_parent_class)->startup (app);
@@ -48,11 +46,6 @@ icon_browser_app_startup (GApplication *app)
   gtk_application_set_accels_for_action (GTK_APPLICATION (app),
                                          "app.quit",
                                          quit_accels);
-
-  builder = gtk_builder_new_from_resource ("/org/gtk/iconbrowser/app-menu.ui");
-  app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
-  gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
-  g_object_unref (builder);
 }
 
 static void
diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c
index ec3a804..7645dca 100644
--- a/demos/icon-browser/iconbrowserwin.c
+++ b/demos/icon-browser/iconbrowserwin.c
@@ -840,7 +840,7 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
   g_type_ensure (ICON_STORE_TYPE);
 
   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
-                                               "/org/gtk/iconbrowser/window.ui");
+                                               "/org/gtk/iconbrowser/gtk/window.ui");
 
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_list);
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, filter_model);
diff --git a/demos/icon-browser/app-menu.ui b/demos/icon-browser/menus.ui
similarity index 92%
rename from demos/icon-browser/app-menu.ui
rename to demos/icon-browser/menus.ui
index ed89a43..1a0f0c5 100644
--- a/demos/icon-browser/app-menu.ui
+++ b/demos/icon-browser/menus.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <menu id="appmenu">
+  <menu id="app-menu">
     <section>
       <item>
         <attribute name="label" translatable="yes">_Quit</attribute>


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