forked from AuroraMiddleware/gtk
a11y: Parse booleans in ui files as expected
Accept the same syntax for booleans as GtkBuilder does elsewhere.
This commit is contained in:
parent
e050a2661c
commit
fce455ae0b
@ -45,6 +45,7 @@
|
|||||||
#include "gtkaccessiblevalueprivate.h"
|
#include "gtkaccessiblevalueprivate.h"
|
||||||
|
|
||||||
#include "gtkaccessible.h"
|
#include "gtkaccessible.h"
|
||||||
|
#include "gtkbuilderprivate.h"
|
||||||
#include "gtkenums.h"
|
#include "gtkenums.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -1344,38 +1345,25 @@ gtk_accessible_value_parse (const GtkAccessibleCollect *cstate,
|
|||||||
{
|
{
|
||||||
case GTK_ACCESSIBLE_COLLECT_BOOLEAN:
|
case GTK_ACCESSIBLE_COLLECT_BOOLEAN:
|
||||||
{
|
{
|
||||||
if (strncmp (str, "true", 4) == 0)
|
gboolean b;
|
||||||
res = gtk_boolean_accessible_value_new (TRUE);
|
|
||||||
else if (strncmp (str, "false", 5) == 0)
|
if (collects_undef && strncmp (str, "undefined", 9) == 0)
|
||||||
res = gtk_boolean_accessible_value_new (FALSE);
|
|
||||||
else if (collects_undef && strncmp (str, "undefined", 9) == 0)
|
|
||||||
res = gtk_undefined_accessible_value_new ();
|
res = gtk_undefined_accessible_value_new ();
|
||||||
else
|
else if (_gtk_builder_boolean_from_string (str, &b, error))
|
||||||
g_set_error (error, GTK_ACCESSIBLE_VALUE_ERROR,
|
res = gtk_boolean_accessible_value_new (b);
|
||||||
GTK_ACCESSIBLE_VALUE_ERROR_INVALID_TOKEN,
|
|
||||||
"Invalid token “%s” for boolean attribute",
|
|
||||||
str);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_ACCESSIBLE_COLLECT_TRISTATE:
|
case GTK_ACCESSIBLE_COLLECT_TRISTATE:
|
||||||
{
|
{
|
||||||
if (strncmp (str, "true", 4) == 0)
|
gboolean b;
|
||||||
res = gtk_tristate_accessible_value_new (GTK_ACCESSIBLE_TRISTATE_TRUE);
|
|
||||||
else if (strncmp (str, "false", 5) == 0)
|
if (collects_undef && strncmp (str, "undefined", 9) == 0)
|
||||||
res = gtk_tristate_accessible_value_new (GTK_ACCESSIBLE_TRISTATE_FALSE);
|
res = gtk_undefined_accessible_value_new ();
|
||||||
else if (strncmp (str, "mixed", 5) == 0)
|
else if (strncmp (str, "mixed", 5) == 0)
|
||||||
res = gtk_tristate_accessible_value_new (GTK_ACCESSIBLE_TRISTATE_MIXED);
|
res = gtk_tristate_accessible_value_new (GTK_ACCESSIBLE_TRISTATE_MIXED);
|
||||||
else if (collects_undef && strncmp (str, "undefined", 9) == 0)
|
else if (_gtk_builder_boolean_from_string (str, &b, error))
|
||||||
res = gtk_undefined_accessible_value_new ();
|
res = gtk_boolean_accessible_value_new (b);
|
||||||
else
|
|
||||||
{
|
|
||||||
g_set_error (error, GTK_ACCESSIBLE_VALUE_ERROR,
|
|
||||||
GTK_ACCESSIBLE_VALUE_ERROR_INVALID_TOKEN,
|
|
||||||
"Invalid token “%s” for tristate attribute",
|
|
||||||
str);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user