[gtk+] Plugman: Find the plugins menu in a better way
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Plugman: Find the plugins menu in a better way
- Date: Mon, 19 Dec 2011 18:04:13 +0000 (UTC)
commit aeb550ffd7961c265c3926225a14769dfc40029b
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Dec 14 06:32:13 2011 -0500
Plugman: Find the plugins menu in a better way
Now that GtkBuilder finds named submenus, there's no need for
the clumsy menumodel navigation anymore.
examples/plugman.c | 30 ++++--------------------------
1 files changed, 4 insertions(+), 26 deletions(-)
---
diff --git a/examples/plugman.c b/examples/plugman.c
index e9b6249..ee49a17 100644
--- a/examples/plugman.c
+++ b/examples/plugman.c
@@ -187,30 +187,7 @@ plugin_enabled (const gchar *name)
static GMenuModel *
find_plugin_menu (void)
{
- GMenuModel *menubar;
- GMenuModel *menu;
- gint i, j;
- const gchar *label, *id;
-
- menubar = g_application_get_menubar (g_application_get_default ());
- for (i = 0; i < g_menu_model_get_n_items (menubar); i++)
- {
- if (g_menu_model_get_item_attribute (menubar, i, "label", "s", &label) &&
- g_strcmp0 (label, "_Edit") == 0)
- {
- menu = g_menu_model_get_item_link (menubar, i, "submenu");
- for (j = 0; j < g_menu_model_get_n_items (menu); j++)
- {
- if (g_menu_model_get_item_attribute (menu, j, "id", "s", &id) &&
- g_strcmp0 (id, "plugins") == 0)
- {
- return g_menu_model_get_item_link (menu, j, "section");
- }
- }
- }
- }
-
- return NULL;
+ return (GMenuModel*) g_object_get_data (G_OBJECT (g_application_get_default ()), "plugin-menu");
}
static void
@@ -425,8 +402,8 @@ plug_man_startup (GApplication *application)
" <item label='_Copy' action='win.copy'/>"
" <item label='_Paste' action='win.paste'/>"
" </section>"
- " <section id='plugins'>"
- " </section>"
+ " <item><link name='section' id='plugins'>"
+ " </link></item>"
" <section>"
" <item label='Plugins' action='app.plugins'/>"
" </section>"
@@ -440,6 +417,7 @@ plug_man_startup (GApplication *application)
"</interface>", -1, NULL);
g_application_set_app_menu (application, G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
g_application_set_menubar (application, G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
+ g_object_set_data_full (G_OBJECT (application), "plugin-menu", gtk_builder_get_object (builder, "plugins"), g_object_unref);
g_object_unref (builder);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]