[gtk/matthiasc/a11y-buildable: 3/6] a11y: Parse booleans in ui files as expected
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/a11y-buildable: 3/6] a11y: Parse booleans in ui files as expected
- Date: Sun, 25 Oct 2020 17:03:14 +0000 (UTC)
commit fce455ae0b050b7196667a6e131a633ddbd90823
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 25 12:20:55 2020 -0400
a11y: Parse booleans in ui files as expected
Accept the same syntax for booleans as GtkBuilder
does elsewhere.
gtk/gtkaccessiblevalue.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkaccessiblevalue.c b/gtk/gtkaccessiblevalue.c
index 5a4edd5d85..c7ac423bd0 100644
--- a/gtk/gtkaccessiblevalue.c
+++ b/gtk/gtkaccessiblevalue.c
@@ -45,6 +45,7 @@
#include "gtkaccessiblevalueprivate.h"
#include "gtkaccessible.h"
+#include "gtkbuilderprivate.h"
#include "gtkenums.h"
#include <math.h>
@@ -1344,38 +1345,25 @@ gtk_accessible_value_parse (const GtkAccessibleCollect *cstate,
{
case GTK_ACCESSIBLE_COLLECT_BOOLEAN:
{
- if (strncmp (str, "true", 4) == 0)
- res = gtk_boolean_accessible_value_new (TRUE);
- else if (strncmp (str, "false", 5) == 0)
- res = gtk_boolean_accessible_value_new (FALSE);
- else if (collects_undef && strncmp (str, "undefined", 9) == 0)
+ gboolean b;
+
+ if (collects_undef && strncmp (str, "undefined", 9) == 0)
res = gtk_undefined_accessible_value_new ();
- else
- g_set_error (error, GTK_ACCESSIBLE_VALUE_ERROR,
- GTK_ACCESSIBLE_VALUE_ERROR_INVALID_TOKEN,
- "Invalid token ā%sā for boolean attribute",
- str);
+ else if (_gtk_builder_boolean_from_string (str, &b, error))
+ res = gtk_boolean_accessible_value_new (b);
}
break;
case GTK_ACCESSIBLE_COLLECT_TRISTATE:
{
- if (strncmp (str, "true", 4) == 0)
- res = gtk_tristate_accessible_value_new (GTK_ACCESSIBLE_TRISTATE_TRUE);
- else if (strncmp (str, "false", 5) == 0)
- res = gtk_tristate_accessible_value_new (GTK_ACCESSIBLE_TRISTATE_FALSE);
+ gboolean b;
+
+ if (collects_undef && strncmp (str, "undefined", 9) == 0)
+ res = gtk_undefined_accessible_value_new ();
else if (strncmp (str, "mixed", 5) == 0)
res = gtk_tristate_accessible_value_new (GTK_ACCESSIBLE_TRISTATE_MIXED);
- else if (collects_undef && strncmp (str, "undefined", 9) == 0)
- res = gtk_undefined_accessible_value_new ();
- else
- {
- g_set_error (error, GTK_ACCESSIBLE_VALUE_ERROR,
- GTK_ACCESSIBLE_VALUE_ERROR_INVALID_TOKEN,
- "Invalid token ā%sā for tristate attribute",
- str);
- return NULL;
- }
+ else if (_gtk_builder_boolean_from_string (str, &b, error))
+ res = gtk_boolean_accessible_value_new (b);
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]