[gtk+/gtk-3-22] actionable: Allow all detailed action name formats
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-22] actionable: Allow all detailed action name formats
- Date: Thu, 26 Oct 2017 10:17:36 +0000 (UTC)
commit 5ee34ec72abe3d3aefe3c62e8a9ef610ad7d18fe
Author: Christian Persch <chpe src gnome org>
Date: Wed Oct 11 20:43:19 2017 +0200
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
gtk/gtkactionable.c | 36 +++++++++++++++++++-----------------
1 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkactionable.c b/gtk/gtkactionable.c
index e12936a..74787cf 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]