From f58df66d4d640ea926573104be9849037a3c8522 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Fri, 16 Dec 2011 22:23:30 -0500 Subject: [PATCH] GDBusActionGroup: add _full variants of activation This allows the platform_data to be explicitly specified. --- docs/reference/gio/gio-sections.txt | 4 ++ gio/gdbusactiongroup.c | 93 +++++++++++++++++++++++++---- gio/gdbusactiongroup.h | 9 +++ gio/gio.symbols | 2 + 4 files changed, 95 insertions(+), 13 deletions(-) diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index 83cb30854..ae667f4c4 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -2924,6 +2924,10 @@ g_dbus_connection_unexport_action_group GDBusActionGroup g_dbus_action_group_get + +g_dbus_action_group_activate_action_full +g_dbus_action_group_change_action_state_full + G_TYPE_DBUS_ACTION_GROUP G_DBUS_ACTION_GROUP diff --git a/gio/gdbusactiongroup.c b/gio/gdbusactiongroup.c index 7c7b38e50..4e08d1002 100644 --- a/gio/gdbusactiongroup.c +++ b/gio/gdbusactiongroup.c @@ -369,10 +369,7 @@ g_dbus_action_group_change_state (GActionGroup *g_group, { GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group); - /* Don't bother with the checks. The other side will do it again. */ - g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "SetState", - g_variant_new ("(sva{sv})", action_name, value, NULL), - NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + g_dbus_action_group_change_action_state_full (group, action_name, value, g_variant_new ("a{sv}", NULL)); } static void @@ -381,16 +378,8 @@ g_dbus_action_group_activate (GActionGroup *g_group, GVariant *parameter) { GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group); - GVariantBuilder builder; - g_variant_builder_init (&builder, G_VARIANT_TYPE ("av")); - - if (parameter) - g_variant_builder_add (&builder, "v", parameter); - - g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "Activate", - g_variant_new ("(sava{sv})", action_name, &builder, NULL), - NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + g_dbus_action_group_activate_action_full (group, action_name, parameter, g_variant_new ("a{sv}", NULL)); } static void @@ -507,3 +496,81 @@ g_dbus_action_group_sync (GDBusActionGroup *group, return reply != NULL; } + +/** + * g_dbus_action_group_activate_action_full: + * @action_group: a #GDBusActionGroup + * @action_name: the name of the action to activate + * @parameter: (allow none): the optional parameter to the activation + * @platform_data: the platform data to send + * + * Activates the remote action. + * + * This is the same as g_action_group_activate_action() except that it + * allows for provision of "platform data" to be sent along with the + * activation request. This typically contains details such as the user + * interaction timestamp or startup notification information. + * + * @platform_data must be non-%NULL and must have the type + * %G_VARIANT_TYPE_VARDICT. If it is floating, it will be consumed. + * + * Since: 2.32 + **/ +void +g_dbus_action_group_activate_action_full (GDBusActionGroup *action_group, + const gchar *action_name, + GVariant *parameter, + GVariant *platform_data) +{ + GVariantBuilder builder; + + g_return_if_fail (G_IS_DBUS_ACTION_GROUP (action_group)); + g_return_if_fail (action_name != NULL); + g_return_if_fail (platform_data != NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("av")); + + if (parameter) + g_variant_builder_add (&builder, "v", parameter); + + g_dbus_connection_call (action_group->connection, action_group->bus_name, action_group->object_path, + "org.gtk.Actions", "Activate", + g_variant_new ("(sav@a{sv})", action_name, &builder, platform_data), + NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} + +/** + * g_dbus_action_group_activate_action_full: + * @action_group: a #GDBusActionGroup + * @action_name: the name of the action to change the state of + * @value: the new requested value for the state + * @platform_data: the platform data to send + * + * Changes the state of a remote action. + * + * This is the same as g_action_group_change_action_state() except that + * it allows for provision of "platform data" to be sent along with the + * state change request. This typically contains details such as the + * user interaction timestamp or startup notification information. + * + * @platform_data must be non-%NULL and must have the type + * %G_VARIANT_TYPE_VARDICT. If it is floating, it will be consumed. + * + * Since: 2.32 + **/ +void +g_dbus_action_group_change_action_state_full (GDBusActionGroup *action_group, + const gchar *action_name, + GVariant *value, + GVariant *platform_data) +{ + g_return_if_fail (G_IS_DBUS_ACTION_GROUP (action_group)); + g_return_if_fail (action_name != NULL); + g_return_if_fail (value != NULL); + g_return_if_fail (platform_data != NULL); + + g_dbus_connection_call (action_group->connection, action_group->bus_name, action_group->object_path, + "org.gtk.Actions", "SetState", + g_variant_new ("(sv@a{sv})", action_name, value, platform_data), + NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} diff --git a/gio/gdbusactiongroup.h b/gio/gdbusactiongroup.h index 12a8edf01..afd428553 100644 --- a/gio/gdbusactiongroup.h +++ b/gio/gdbusactiongroup.h @@ -49,6 +49,15 @@ GDBusActionGroup * g_dbus_action_group_get (GDBusConn const gchar *bus_name, const gchar *object_path); +void g_dbus_action_group_activate_action_full (GDBusActionGroup *action_group, + const gchar *action_name, + GVariant *parameter, + GVariant *platform_data); +void g_dbus_action_group_change_action_state_full (GDBusActionGroup *action_group, + const gchar *action_name, + GVariant *value, + GVariant *platform_data); + G_END_DECLS #endif /* __G_DBUS_ACTION_GROUP_H__ */ diff --git a/gio/gio.symbols b/gio/gio.symbols index 8fed849e7..7c6eb788e 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -1443,6 +1443,8 @@ g_simple_action_set_enabled g_simple_action_set_state g_dbus_action_group_get_type g_dbus_action_group_get +g_dbus_action_group_activate_action_full +g_dbus_action_group_change_action_state_full g_dbus_menu_model_get_type g_dbus_menu_model_get g_dbus_connection_export_action_group