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.
This commit is contained in:
Matthias Clasen 2016-01-24 20:01:33 -05:00
parent e8ad47498b
commit 792857c7b8
4 changed files with 4 additions and 11 deletions

View File

@ -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>

View File

@ -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

View File

@ -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);

View File

@ -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>