diff options
author | Christian Persch <chpe@src.gnome.org> | 2017-10-11 20:43:19 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-10-26 06:16:59 -0400 |
commit | 29d1cc2fcd43bd4d929243f8cc8dc0adbcb5428a (patch) | |
tree | 42d235f77c78ddb4f531a7a6f89b1c0e2d1f9e76 /gtk/gtkactionable.c | |
parent | fda120ceece7b15daee81430a45ca795719eecca (diff) | |
download | gtk+-29d1cc2fcd43bd4d929243f8cc8dc0adbcb5428a.tar.gz |
actionable: Allow all detailed action name formats
Use g_action_parse_detailed_name() to enable use of this API
for actions with non-string parameter.
https://bugzilla.gnome.org/show_bug.cgi?id=788841
Diffstat (limited to 'gtk/gtkactionable.c')
-rw-r--r-- | gtk/gtkactionable.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/gtk/gtkactionable.c b/gtk/gtkactionable.c index 0d4d610a5c..e515af241b 100644 --- a/gtk/gtkactionable.c +++ b/gtk/gtkactionable.c @@ -224,14 +224,14 @@ gtk_actionable_set_action_target (GtkActionable *actionable, * Sets the action-name and associated string target value of an * actionable widget. * - * This allows for the effect of both gtk_actionable_set_action_name() - * and gtk_actionable_set_action_target_value() in the common case that - * the target is string-valued. + * @detailed_action_name is a string in the format accepted by + * g_action_parse_detailed_name(). * - * @detailed_action_name is a string of the form - * `"action::target"` where `action` - * is the action name and `target` is the string to use - * as the target. + * (Note that prior to version 3.22.25, + * this function is only usable for actions with a simple "s" target, and + * @detailed_action_name must be of the form `"action::target"` where + * `action` is the action name and `target` is the string to use + * as the target.) * * Since: 3.4 **/ @@ -239,9 +239,9 @@ void gtk_actionable_set_detailed_action_name (GtkActionable *actionable, const gchar *detailed_action_name) { - gchar **parts; - - g_return_if_fail (GTK_IS_ACTIONABLE (actionable)); + GError *error = NULL; + GVariant *target; + gchar *name; if (detailed_action_name == NULL) { @@ -250,12 +250,14 @@ gtk_actionable_set_detailed_action_name (GtkActionable *actionable, return; } - parts = g_strsplit (detailed_action_name, "::", 2); - gtk_actionable_set_action_name (actionable, parts[0]); - if (parts[0] && parts[1]) - gtk_actionable_set_action_target (actionable, "s", parts[1]); - else - gtk_actionable_set_action_target_value (actionable, NULL); - g_strfreev (parts); + if (!g_action_parse_detailed_name (detailed_action_name, &name, &target, &error)) + g_error ("gtk_actionable_set_detailed_action_name: %s", error->message); + + gtk_actionable_set_action_name (actionable, name); + gtk_actionable_set_action_target_value (actionable, target); + + if (target) + g_variant_unref (target); + g_free (name); } |