aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2009-09-10 18:45:10 +0300
committerClaudio Saavedra <csaavedra@igalia.com>2009-09-11 20:15:59 +0300
commitecf300748aa59210d2b65a1a1e446fd1b2386dea (patch)
tree502e6795dea91216d506c15578e0c5ff4aa4d28d
parent7089e90e6ba75e15ebf3734ee8887e21cd6d3c39 (diff)
Add HildonAppMenu::changed signal
* hildon/hildon-app-menu.c: (hildon_app_menu_insert), (hildon_app_menu_add_filter), (hildon_app_menu_class_init): Emit a new HildonAppMenu:changed signal when there are changes in the menu children.
-rw-r--r--ChangeLog9
-rw-r--r--hildon/hildon-app-menu.c43
2 files changed, 52 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c1cd66..d3cd7bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2009-09-10 Claudio Saavedra <csaavedra@igalia.com>
+ Add HildonAppMenu::changed signal
+
+ * hildon/hildon-app-menu.c: (hildon_app_menu_insert),
+ (hildon_app_menu_add_filter), (hildon_app_menu_class_init):
+ Emit a new HildonAppMenu:changed signal when there are changes in
+ the menu children.
+
+2009-09-10 Claudio Saavedra <csaavedra@igalia.com>
+
Add hildon_app_menu_has_visible_children() private method
* hildon/hildon-app-menu-private.h: Add below private method.
diff --git a/hildon/hildon-app-menu.c b/hildon/hildon-app-menu.c
index 243c173..06e8165 100644
--- a/hildon/hildon-app-menu.c
+++ b/hildon/hildon-app-menu.c
@@ -133,10 +133,22 @@ remove_item_from_list (GList **list,
gpointer item);
static void
+emit_menu_changed (HildonAppMenu *menu,
+ gpointer item);
+
+static void
hildon_app_menu_apply_style (GtkWidget *widget);
G_DEFINE_TYPE (HildonAppMenu, hildon_app_menu, GTK_TYPE_WINDOW);
+enum
+{
+ CHANGED,
+ LAST_SIGNAL
+};
+
+static guint app_menu_signals[LAST_SIGNAL] = { 0 };
+
/**
* hildon_app_menu_new:
*
@@ -194,6 +206,9 @@ hildon_app_menu_insert (HildonAppMenu *menu,
/* Remove item from list when it is destroyed */
g_object_weak_ref (G_OBJECT (item), (GWeakNotify) remove_item_from_list, &(priv->buttons));
+ g_object_weak_ref (G_OBJECT (item), (GWeakNotify) emit_menu_changed, menu);
+
+ g_signal_emit (menu, app_menu_signals[CHANGED], 0);
}
/**
@@ -301,6 +316,9 @@ hildon_app_menu_add_filter (HildonAppMenu *menu,
/* Remove filter from list when it is destroyed */
g_object_weak_ref (G_OBJECT (filter), (GWeakNotify) remove_item_from_list, &(priv->filters));
+ g_object_weak_ref (G_OBJECT (filter), (GWeakNotify) emit_menu_changed, menu);
+
+ g_signal_emit (menu, app_menu_signals[CHANGED], 0);
}
static void
@@ -428,6 +446,13 @@ remove_item_from_list (GList **list,
}
static void
+emit_menu_changed (HildonAppMenu *menu,
+ gpointer item)
+{
+ g_signal_emit (menu, app_menu_signals[CHANGED], 0);
+}
+
+static void
hildon_app_menu_show_all (GtkWidget *widget)
{
HildonAppMenu *menu = HILDON_APP_MENU (widget);
@@ -1050,4 +1075,22 @@ hildon_app_menu_class_init (HildonAppMenuClass *klass)
"the screen edges (in horizontal mode)",
0, G_MAXUINT, 50,
G_PARAM_READABLE));
+
+
+ /**
+ * HildonAppMenu::changed:
+ * @widget: the widget that received the signal
+ *
+ * The HildonAppMenu::changed signal is emitted whenever an
+ * item or filter is added or removed from the menu.
+ *
+ * Since: 2.2
+ */
+ app_menu_signals[CHANGED] =
+ g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
}