[gtk+/wip/gmenu] Brute-force dynamic change propagation
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/gmenu] Brute-force dynamic change propagation
- Date: Tue, 1 Nov 2011 12:50:21 +0000 (UTC)
commit eadfead25469ed2912379cfd3cd985c1f1a29bfb
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 1 08:49:04 2011 -0400
Brute-force dynamic change propagation
We need to make sure that we connect to ::items-changed on every
single model, as they appear and disappear. Ugly business.
tests/testgmenu.c | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/tests/testgmenu.c b/tests/testgmenu.c
index 566ae7c..c04e166 100644
--- a/tests/testgmenu.c
+++ b/tests/testgmenu.c
@@ -727,17 +727,6 @@ button_clicked (GtkButton *button, gpointer data)
}
static void
-items_changed (GMenuModel *model,
- gint position,
- gint removed,
- gint added,
- GtkButton *button)
-{
- g_print ("Received GMenuModel::items-changed\n");
- g_object_set_data (G_OBJECT (button), "menu", NULL);
-}
-
-static void
action_added (GActionGroup *group,
const gchar *name,
gpointer data)
@@ -762,7 +751,11 @@ recursively_connect_to_items_changed (GMenuModel *model,
GMenuModel *m;
GMenuLinkIter *iter;
- g_signal_connect (model, "items-changed", callback, data);
+ if (!g_object_get_data (G_OBJECT (model), "handler-connected"))
+ {
+ g_signal_connect (model, "items-changed", callback, data);
+ g_object_set_data (G_OBJECT (model), "handler-connected", GINT_TO_POINTER (1));
+ }
for (i = 0; i < g_menu_model_get_n_items (model); i++)
{
iter = g_menu_model_iterate_item_links (model, i);
@@ -776,6 +769,18 @@ recursively_connect_to_items_changed (GMenuModel *model,
}
}
+static void
+items_changed (GMenuModel *model,
+ gint position,
+ gint removed,
+ gint added,
+ GtkButton *button)
+{
+ g_print ("Received GMenuModel::items-changed\n");
+ g_object_set_data (G_OBJECT (button), "menu", NULL);
+ recursively_connect_to_items_changed (model, G_CALLBACK (items_changed), button);
+}
+
static GtkWidget *
create_menu_button (GMenuModel *model, GActionGroup *group)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]