[glib] GApplication: emit signals on action changes
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GApplication: emit signals on action changes
- Date: Fri, 16 Dec 2011 16:44:32 +0000 (UTC)
commit e370631f46ca9b9d5b6ca1f7bbdf0ce708922ad3
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Dec 16 11:39:24 2011 -0500
GApplication: emit signals on action changes
Now that we're a GActionMap the story about propagating signals from our
(now-constant) internal action group is vastly simplified. If someone
calls g_application_set_action_group() then signals will stop working --
but this function is deprecated and they never worked before, so no big
loss there.
https://bugzilla.gnome.org/show_bug.cgi?id=643736
gio/gapplication.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 17398e0..02a0cf6 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -475,7 +475,9 @@ g_application_set_property (GObject *object,
*
* Deprecated:2.32:Use the #GActionMap interface instead. Never ever
* mix use of this API with use of #GActionMap on the same @application
- * or things will go very badly wrong.
+ * or things will go very badly wrong. This function is known to
+ * introduce buggy behaviour (ie: signals not emitted on changes to the
+ * action group), so you should really use #GActionMap instead.
**/
void
g_application_set_action_group (GApplication *application,
@@ -700,7 +702,20 @@ g_application_init (GApplication *application)
application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application,
G_TYPE_APPLICATION,
GApplicationPrivate);
+
application->priv->actions = G_ACTION_GROUP (g_simple_action_group_new ());
+
+ /* application->priv->actions is the one and only ref on the group, so when
+ * we dispose, the action group will die, disconnecting all signals.
+ */
+ g_signal_connect_swapped (application->priv->actions, "action-added",
+ G_CALLBACK (g_action_group_action_added), application);
+ g_signal_connect_swapped (application->priv->actions, "action-enabled-changed",
+ G_CALLBACK (g_action_group_action_enabled_changed), application);
+ g_signal_connect_swapped (application->priv->actions, "action-state-changed",
+ G_CALLBACK (g_action_group_action_state_changed), application);
+ g_signal_connect_swapped (application->priv->actions, "action-removed",
+ G_CALLBACK (g_action_group_action_removed), application);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]