mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
GDBusActionGroup: drop ability to 'inject'
Also drop the GDBusActionGroupFlags that were only meant to facilitate injection-based usage.
This commit is contained in:
parent
caa6287f39
commit
0fdd9985bb
@ -526,8 +526,7 @@ g_application_impl_register (GApplication *application,
|
|||||||
* This also serves as a mechanism to ensure that the primary exists
|
* This also serves as a mechanism to ensure that the primary exists
|
||||||
* (ie: DBus service files installed correctly, etc).
|
* (ie: DBus service files installed correctly, etc).
|
||||||
*/
|
*/
|
||||||
actions = g_dbus_action_group_new_sync (impl->session_bus, impl->bus_name, impl->object_path,
|
actions = g_dbus_action_group_new_sync (impl->session_bus, impl->bus_name, impl->object_path, cancellable, error);
|
||||||
G_DBUS_ACTION_GROUP_FLAGS_NONE, cancellable, error);
|
|
||||||
|
|
||||||
if (actions == NULL)
|
if (actions == NULL)
|
||||||
{
|
{
|
||||||
|
@ -402,7 +402,6 @@ g_dbus_action_group_describe_all_done (GObject *source,
|
|||||||
* @connection: A #GDBusConnection
|
* @connection: A #GDBusConnection
|
||||||
* @bus_name: the bus name which exports the action group
|
* @bus_name: the bus name which exports the action group
|
||||||
* @object_path: the object path at which the action group is exported
|
* @object_path: the object path at which the action group is exported
|
||||||
* @flags: Flags used when constructing the object
|
|
||||||
* @cancellable: A #GCancellable or %NULL
|
* @cancellable: A #GCancellable or %NULL
|
||||||
* @callback: Callback function to invoke when the object is ready
|
* @callback: Callback function to invoke when the object is ready
|
||||||
* @user_data: User data to pass to @callback
|
* @user_data: User data to pass to @callback
|
||||||
@ -420,7 +419,6 @@ void
|
|||||||
g_dbus_action_group_new (GDBusConnection *connection,
|
g_dbus_action_group_new (GDBusConnection *connection,
|
||||||
const gchar *bus_name,
|
const gchar *bus_name,
|
||||||
const gchar *object_path,
|
const gchar *object_path,
|
||||||
GDBusActionGroupFlags flags,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
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);
|
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);
|
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 =
|
group->subscription_id =
|
||||||
g_dbus_connection_signal_subscribe (connection, bus_name, "org.gtk.Actions", "Changed", object_path, NULL,
|
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);
|
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_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_VARIANT_TYPE ("(a{s(bgav)})"), G_DBUS_CALL_FLAGS_NONE, -1, cancellable,
|
||||||
g_dbus_action_group_describe_all_done, result);
|
g_dbus_action_group_describe_all_done, result);
|
||||||
|
|
||||||
else
|
|
||||||
g_simple_async_result_complete_in_idle (result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -486,7 +479,6 @@ g_dbus_action_group_new_finish (GAsyncResult *result,
|
|||||||
* @connection: A #GDBusConnection
|
* @connection: A #GDBusConnection
|
||||||
* @bus_name: the bus name which exports the action group
|
* @bus_name: the bus name which exports the action group
|
||||||
* @object_path: the object path at which the action group is exported
|
* @object_path: the object path at which the action group is exported
|
||||||
* @flags: Flags used when constructing the object
|
|
||||||
* @cancellable: A #GCancellable or %NULL
|
* @cancellable: A #GCancellable or %NULL
|
||||||
* @error: Return location for error or %NULL
|
* @error: Return location for error or %NULL
|
||||||
*
|
*
|
||||||
@ -499,26 +491,21 @@ GDBusActionGroup *
|
|||||||
g_dbus_action_group_new_sync (GDBusConnection *connection,
|
g_dbus_action_group_new_sync (GDBusConnection *connection,
|
||||||
const gchar *bus_name,
|
const gchar *bus_name,
|
||||||
const gchar *object_path,
|
const gchar *object_path,
|
||||||
GDBusActionGroupFlags flags,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GDBusActionGroup *group;
|
GDBusActionGroup *group;
|
||||||
|
GVariant *reply;
|
||||||
|
|
||||||
group = g_object_new (G_TYPE_DBUS_ACTION_GROUP, NULL);
|
group = g_object_new (G_TYPE_DBUS_ACTION_GROUP, NULL);
|
||||||
group->connection = g_object_ref (connection);
|
group->connection = g_object_ref (connection);
|
||||||
group->bus_name = g_strdup (bus_name);
|
group->bus_name = g_strdup (bus_name);
|
||||||
group->object_path = g_strdup (object_path);
|
group->object_path = g_strdup (object_path);
|
||||||
|
|
||||||
if (~flags & G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_WATCH)
|
|
||||||
group->subscription_id =
|
group->subscription_id =
|
||||||
g_dbus_connection_signal_subscribe (connection, bus_name, "org.gtk.Actions", "Changed", object_path, NULL,
|
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);
|
G_DBUS_SIGNAL_FLAGS_NONE, g_dbus_action_group_changed, group, NULL);
|
||||||
|
|
||||||
if (~flags & G_DBUS_ACTION_GROUP_FLAGS_DO_NOT_POPULATE)
|
|
||||||
{
|
|
||||||
GVariant *reply;
|
|
||||||
|
|
||||||
reply = g_dbus_connection_call_sync (connection, bus_name, object_path, "org.gtk.Actions",
|
reply = g_dbus_connection_call_sync (connection, bus_name, object_path, "org.gtk.Actions",
|
||||||
"DescribeAll", NULL, G_VARIANT_TYPE ("(a{s(bgav)})"),
|
"DescribeAll", NULL, G_VARIANT_TYPE ("(a{s(bgav)})"),
|
||||||
G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error);
|
G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error);
|
||||||
@ -539,36 +526,6 @@ g_dbus_action_group_new_sync (GDBusConnection *connection,
|
|||||||
g_object_unref (group);
|
g_object_unref (group);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return group;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -48,7 +48,6 @@ GType g_dbus_action_group_get_type (void) G_G
|
|||||||
void g_dbus_action_group_new (GDBusConnection *connection,
|
void g_dbus_action_group_new (GDBusConnection *connection,
|
||||||
const gchar *bus_name,
|
const gchar *bus_name,
|
||||||
const gchar *object_path,
|
const gchar *object_path,
|
||||||
GDBusActionGroupFlags flags,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@ -59,16 +58,9 @@ GDBusActionGroup * g_dbus_action_group_new_finish (GAsyncRes
|
|||||||
GDBusActionGroup * g_dbus_action_group_new_sync (GDBusConnection *connection,
|
GDBusActionGroup * g_dbus_action_group_new_sync (GDBusConnection *connection,
|
||||||
const gchar *bus_name,
|
const gchar *bus_name,
|
||||||
const gchar *object_path,
|
const gchar *object_path,
|
||||||
GDBusActionGroupFlags flags,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __G_DBUS_ACTION_GROUP_H__ */
|
#endif /* __G_DBUS_ACTION_GROUP_H__ */
|
||||||
|
@ -1517,25 +1517,6 @@ typedef enum {
|
|||||||
G_IO_MODULE_SCOPE_BLOCK_DUPLICATES
|
G_IO_MODULE_SCOPE_BLOCK_DUPLICATES
|
||||||
} GIOModuleScopeFlags;
|
} 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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GIO_ENUMS_H__ */
|
#endif /* __GIO_ENUMS_H__ */
|
||||||
|
@ -539,7 +539,7 @@ test_dbus_export (void)
|
|||||||
id = g_dbus_connection_export_action_group (bus, "/", G_ACTION_GROUP (group), &error);
|
id = g_dbus_connection_export_action_group (bus, "/", G_ACTION_GROUP (group), &error);
|
||||||
g_assert_no_error (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_assert_no_error (error);
|
||||||
|
|
||||||
g_timeout_add (100, stop_loop, loop);
|
g_timeout_add (100, stop_loop, loop);
|
||||||
|
Loading…
Reference in New Issue
Block a user