From 0fdd9985bb4c840d1767f1e15e2fa5c97870ed7a Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Thu, 8 Dec 2011 16:06:01 -0500 Subject: [PATCH] GDBusActionGroup: drop ability to 'inject' Also drop the GDBusActionGroupFlags that were only meant to facilitate injection-based usage. --- gio/gapplicationimpl-dbus.c | 3 +- gio/gdbusactiongroup.c | 95 ++++++++++--------------------------- gio/gdbusactiongroup.h | 8 ---- gio/gioenums.h | 19 -------- gio/tests/actions.c | 2 +- 5 files changed, 28 insertions(+), 99 deletions(-) diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c index 2fa155a27..9edac53c1 100644 --- a/gio/gapplicationimpl-dbus.c +++ b/gio/gapplicationimpl-dbus.c @@ -526,8 +526,7 @@ g_application_impl_register (GApplication *application, * This also serves as a mechanism to ensure that the primary exists * (ie: DBus service files installed correctly, etc). */ - actions = g_dbus_action_group_new_sync (impl->session_bus, impl->bus_name, impl->object_path, - G_DBUS_ACTION_GROUP_FLAGS_NONE, cancellable, error); + actions = g_dbus_action_group_new_sync (impl->session_bus, impl->bus_name, impl->object_path, cancellable, error); if (actions == NULL) { diff --git a/gio/gdbusactiongroup.c b/gio/gdbusactiongroup.c index 4aba34f60..7dde04158 100644 --- a/gio/gdbusactiongroup.c +++ b/gio/gdbusactiongroup.c @@ -402,7 +402,6 @@ g_dbus_action_group_describe_all_done (GObject *source, * @connection: A #GDBusConnection * @bus_name: the bus name which exports the action group * @object_path: the object path at which the action group is exported - * @flags: Flags used when constructing the object * @cancellable: A #GCancellable or %NULL * @callback: Callback function to invoke when the object is ready * @user_data: User data to pass to @callback @@ -420,7 +419,6 @@ void g_dbus_action_group_new (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, - GDBusActionGroupFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -441,18 +439,13 @@ g_dbus_action_group_new (GDBusConnection *connection, result = g_simple_async_result_new (G_OBJECT (group), callback, user_data, g_dbus_action_group_new); g_simple_async_result_set_op_res_gpointer (result, group, g_object_unref); - if (~flags & G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_WATCH) - group->subscription_id = - g_dbus_connection_signal_subscribe (connection, bus_name, "org.gtk.Actions", "Changed", object_path, NULL, - G_DBUS_SIGNAL_FLAGS_NONE, g_dbus_action_group_changed, group, NULL); + group->subscription_id = + g_dbus_connection_signal_subscribe (connection, bus_name, "org.gtk.Actions", "Changed", object_path, NULL, + G_DBUS_SIGNAL_FLAGS_NONE, g_dbus_action_group_changed, group, NULL); - if (~flags & G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_POPULATE) - g_dbus_connection_call (connection, bus_name, object_path, "org.gtk.Actions", "DescribeAll", NULL, - G_VARIANT_TYPE ("(a{s(bgav)})"), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, - g_dbus_action_group_describe_all_done, result); - - else - g_simple_async_result_complete_in_idle (result); + g_dbus_connection_call (connection, bus_name, object_path, "org.gtk.Actions", "DescribeAll", NULL, + G_VARIANT_TYPE ("(a{s(bgav)})"), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, + g_dbus_action_group_describe_all_done, result); } /** @@ -486,7 +479,6 @@ g_dbus_action_group_new_finish (GAsyncResult *result, * @connection: A #GDBusConnection * @bus_name: the bus name which exports the action group * @object_path: the object path at which the action group is exported - * @flags: Flags used when constructing the object * @cancellable: A #GCancellable or %NULL * @error: Return location for error or %NULL * @@ -499,76 +491,41 @@ GDBusActionGroup * g_dbus_action_group_new_sync (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, - GDBusActionGroupFlags flags, GCancellable *cancellable, GError **error) { GDBusActionGroup *group; + GVariant *reply; group = g_object_new (G_TYPE_DBUS_ACTION_GROUP, NULL); group->connection = g_object_ref (connection); group->bus_name = g_strdup (bus_name); group->object_path = g_strdup (object_path); - if (~flags & G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_WATCH) - group->subscription_id = - g_dbus_connection_signal_subscribe (connection, bus_name, "org.gtk.Actions", "Changed", object_path, NULL, + group->subscription_id = + g_dbus_connection_signal_subscribe (connection, bus_name, "org.gtk.Actions", "Changed", object_path, NULL, G_DBUS_SIGNAL_FLAGS_NONE, g_dbus_action_group_changed, group, NULL); - if (~flags & G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_POPULATE) + reply = g_dbus_connection_call_sync (connection, bus_name, object_path, "org.gtk.Actions", + "DescribeAll", NULL, G_VARIANT_TYPE ("(a{s(bgav)})"), + G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error); + + if (reply != NULL) { - GVariant *reply; + GVariantIter *iter; + ActionInfo *action; - reply = g_dbus_connection_call_sync (connection, bus_name, object_path, "org.gtk.Actions", - "DescribeAll", NULL, G_VARIANT_TYPE ("(a{s(bgav)})"), - G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error); - - if (reply != NULL) - { - GVariantIter *iter; - ActionInfo *action; - - g_variant_get (reply, "(a{s(bgav)})", &iter); - while ((action = action_info_new_from_iter (iter))) - g_hash_table_insert (group->actions, action->name, action); - g_variant_iter_free (iter); - g_variant_unref (reply); - } - else - { - g_object_unref (group); - return NULL; - } + g_variant_get (reply, "(a{s(bgav)})", &iter); + while ((action = action_info_new_from_iter (iter))) + g_hash_table_insert (group->actions, action->name, action); + g_variant_iter_free (iter); + g_variant_unref (reply); + } + else + { + g_object_unref (group); + return NULL; } return group; } - -gboolean -g_dbus_action_group_inject (GDBusActionGroup *group, - const gchar *action_name, - const GVariantType *parameter_type, - gboolean enabled, - GVariant *state) -{ - ActionInfo *action; - - g_return_val_if_fail (G_IS_DBUS_ACTION_GROUP (group), FALSE); - g_return_val_if_fail (action_name != NULL, FALSE); - - if (g_hash_table_lookup (group->actions, action_name)) - return FALSE; - - action = g_slice_new (ActionInfo); - action->name = g_strdup (action_name); - action->parameter_type = parameter_type ? g_variant_type_copy (parameter_type) : NULL; - action->enabled = !!enabled; - action->state = state ? g_variant_ref_sink (state) : NULL; - - g_hash_table_insert (group->actions, action->name, action); - - if (group->strict) - g_action_group_action_added (G_ACTION_GROUP (group), action_name); - - return TRUE; -} diff --git a/gio/gdbusactiongroup.h b/gio/gdbusactiongroup.h index a418e8d2b..6da5861c0 100644 --- a/gio/gdbusactiongroup.h +++ b/gio/gdbusactiongroup.h @@ -48,7 +48,6 @@ GType g_dbus_action_group_get_type (void) G_G void g_dbus_action_group_new (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, - GDBusActionGroupFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -59,16 +58,9 @@ GDBusActionGroup * g_dbus_action_group_new_finish (GAsyncRes GDBusActionGroup * g_dbus_action_group_new_sync (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, - GDBusActionGroupFlags flags, GCancellable *cancellable, GError **error); -gboolean g_dbus_action_group_inject (GDBusActionGroup *group, - const gchar *action_name, - const GVariantType *parameter_type, - gboolean enabled, - GVariant *state); - G_END_DECLS #endif /* __G_DBUS_ACTION_GROUP_H__ */ diff --git a/gio/gioenums.h b/gio/gioenums.h index 5c2878498..47d72bd38 100644 --- a/gio/gioenums.h +++ b/gio/gioenums.h @@ -1517,25 +1517,6 @@ typedef enum { G_IO_MODULE_SCOPE_BLOCK_DUPLICATES } GIOModuleScopeFlags; -/* GDBusActionGroupFlags: - * @G_DBUS_ACTION_GROUP_FLAGS_NONE: No flags set. - * @G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_POPULATE: Do not make the initial - * D-Bus call to populate the set of actions in the group. Instead, - * actions can be added using g_dbus_action_group_inject(). Changes - * are still monitored. - * @G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_WATCH: Don't watch for changes. - * - * Flags used when constructing a #GDBusActionGroup. - * - * Since: 2.30 - **/ -typedef enum -{ - G_DBUS_ACTION_GROUP_FLAGS_NONE = 0, - G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_POPULATE = (1<<0), - G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_WATCH = (1<<1) -} GDBusActionGroupFlags; - G_END_DECLS #endif /* __GIO_ENUMS_H__ */ diff --git a/gio/tests/actions.c b/gio/tests/actions.c index 63ffe4855..e8874583b 100644 --- a/gio/tests/actions.c +++ b/gio/tests/actions.c @@ -539,7 +539,7 @@ test_dbus_export (void) id = g_dbus_connection_export_action_group (bus, "/", G_ACTION_GROUP (group), &error); g_assert_no_error (error); - g_dbus_action_group_new (bus, g_dbus_connection_get_unique_name (bus), "/", 0, NULL, got_proxy, NULL); + g_dbus_action_group_new (bus, g_dbus_connection_get_unique_name (bus), "/", NULL, got_proxy, NULL); g_assert_no_error (error); g_timeout_add (100, stop_loop, loop);