mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
GApplication: fix remote action states
Fix up remote_action_info_new_from_iter() to do its job better and use it from all places that it's appropriate. Closes #650236.
This commit is contained in:
parent
0e10116b3b
commit
0e63b57eea
@ -417,27 +417,50 @@ g_application_impl_destroy (GApplicationImpl *impl)
|
|||||||
g_slice_free (GApplicationImpl, impl);
|
g_slice_free (GApplicationImpl, impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unwrap_fake_maybe (GVariant **value)
|
||||||
|
{
|
||||||
|
GVariant *tmp;
|
||||||
|
|
||||||
|
if (g_variant_n_children (*value))
|
||||||
|
g_variant_get_child (*value, 0, "v", &tmp);
|
||||||
|
else
|
||||||
|
tmp = NULL;
|
||||||
|
|
||||||
|
g_variant_unref (*value);
|
||||||
|
*value = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
RemoteActionInfo *
|
RemoteActionInfo *
|
||||||
remote_action_info_new_from_iter (GVariantIter *iter)
|
remote_action_info_new_from_iter (GVariantIter *iter)
|
||||||
{
|
{
|
||||||
RemoteActionInfo *info;
|
RemoteActionInfo *info;
|
||||||
const gchar *name;
|
|
||||||
GVariant *param_type;
|
GVariant *param_type;
|
||||||
gboolean enabled;
|
gboolean enabled;
|
||||||
GVariant *state;
|
GVariant *state;
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
if (!g_variant_iter_next (iter, "(s@avb@av)", &name,
|
if (!g_variant_iter_next (iter, "(s@avb@av)", &name,
|
||||||
¶m_type, &enabled, &state))
|
¶m_type, &enabled, &state))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
unwrap_fake_maybe (¶m_type);
|
||||||
|
unwrap_fake_maybe (&state);
|
||||||
|
|
||||||
info = g_slice_new (RemoteActionInfo);
|
info = g_slice_new (RemoteActionInfo);
|
||||||
info->parameter_type = g_variant_type_copy (
|
info->name = name;
|
||||||
g_variant_type_element (
|
|
||||||
g_variant_get_type (param_type)));
|
|
||||||
info->enabled = enabled;
|
info->enabled = enabled;
|
||||||
info->state = state;
|
info->state = state;
|
||||||
|
|
||||||
|
if (param_type != NULL)
|
||||||
|
{
|
||||||
|
info->parameter_type = g_variant_type_copy (
|
||||||
|
g_variant_type_element (
|
||||||
|
g_variant_get_type (param_type)));
|
||||||
g_variant_unref (param_type);
|
g_variant_unref (param_type);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
info->parameter_type = NULL;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -708,32 +731,16 @@ g_application_impl_register (GApplication *application,
|
|||||||
|
|
||||||
/* Create and populate the hashtable */
|
/* Create and populate the hashtable */
|
||||||
{
|
{
|
||||||
|
RemoteActionInfo *info;
|
||||||
GVariant *descriptions;
|
GVariant *descriptions;
|
||||||
GVariantIter iter;
|
GVariantIter iter;
|
||||||
GVariant *param_type;
|
|
||||||
gboolean enabled;
|
|
||||||
GVariant *state;
|
|
||||||
gchar *name;
|
|
||||||
|
|
||||||
*remote_actions = g_hash_table_new (g_str_hash, g_str_equal);
|
*remote_actions = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
descriptions = g_variant_get_child_value (reply, 0);
|
descriptions = g_variant_get_child_value (reply, 0);
|
||||||
g_variant_iter_init (&iter, descriptions);
|
g_variant_iter_init (&iter, descriptions);
|
||||||
|
|
||||||
while (g_variant_iter_next (&iter, "(s@avb@av)", &name,
|
while ((info = remote_action_info_new_from_iter (&iter)))
|
||||||
¶m_type, &enabled, &state))
|
g_hash_table_insert (*remote_actions, info->name, info);
|
||||||
{
|
|
||||||
RemoteActionInfo *action;
|
|
||||||
|
|
||||||
action = g_slice_new (RemoteActionInfo);
|
|
||||||
action->parameter_type = g_variant_type_copy (
|
|
||||||
g_variant_type_element (
|
|
||||||
g_variant_get_type (param_type)));
|
|
||||||
action->enabled = enabled;
|
|
||||||
action->state = state;
|
|
||||||
|
|
||||||
g_hash_table_insert (*remote_actions, name, action);
|
|
||||||
g_variant_unref (param_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_variant_unref (descriptions);
|
g_variant_unref (descriptions);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user