From 3f0ef3ba6d8389a6aaeef7183c2a41b57ba36a8d Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 21 Apr 2018 22:31:32 +0200 Subject: Put all menu definitions into one resource --- src/colloquium.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/colloquium.c') diff --git a/src/colloquium.c b/src/colloquium.c index 11ac241..3b1caa3 100644 --- a/src/colloquium.c +++ b/src/colloquium.c @@ -42,6 +42,7 @@ struct _colloquium { GtkApplication parent_instance; + GtkBuilder *builder; char *mydir; int first_run; char *imagestore; @@ -319,10 +320,15 @@ int colloquium_get_hidepointer(Colloquium *app) } +GtkBuilder *colloquium_get_uibuilder(Colloquium *app) +{ + return app->builder; +} + + static void colloquium_startup(GApplication *papp) { Colloquium *app = COLLOQUIUM(papp); - GtkBuilder *builder; const char *configdir; char *tmp; @@ -331,10 +337,9 @@ static void colloquium_startup(GApplication *papp) g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries, G_N_ELEMENTS(app_entries), app); - builder = gtk_builder_new_from_resource("/uk/me/bitwiz/Colloquium/menu-bar.ui"); + app->builder = gtk_builder_new_from_resource("/uk/me/bitwiz/Colloquium/menus.ui"); gtk_application_set_menubar(GTK_APPLICATION(app), - G_MENU_MODEL(gtk_builder_get_object(builder, "menubar"))); - g_object_unref(builder); + G_MENU_MODEL(gtk_builder_get_object(app->builder, "menubar"))); if ( gtk_application_prefers_app_menu(GTK_APPLICATION(app)) ) { /* Set the application menu only if it will be shown by the @@ -342,10 +347,8 @@ static void colloquium_startup(GApplication *papp) * normal menus, so don't let GTK create a fallback menu in the * menu bar. */ printf(_("Using app menu\n")); - builder = gtk_builder_new_from_resource("/uk/me/bitwiz/Colloquium/app-menu.ui"); - GMenuModel *mmodel = G_MENU_MODEL(gtk_builder_get_object(builder, "app-menu")); + GMenuModel *mmodel = G_MENU_MODEL(gtk_builder_get_object(app->builder, "app-menu")); gtk_application_set_app_menu(GTK_APPLICATION(app), mmodel); - g_object_unref(builder); } configdir = g_get_user_config_dir(); -- cgit v1.2.3