mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
a11y: Add GValue initializers for accessible attributes
Consumers of the GValue-based API for GtkAccessible need to have a way to initialize the GValue with the correct type for the given attribute.
This commit is contained in:
parent
1bdc8b9061
commit
6af89e9034
@ -76,4 +76,14 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
void gtk_accessible_reset_relation (GtkAccessible *self,
|
void gtk_accessible_reset_relation (GtkAccessible *self,
|
||||||
GtkAccessibleRelation relation);
|
GtkAccessibleRelation relation);
|
||||||
|
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
void gtk_accessible_state_init_value (GtkAccessibleState state,
|
||||||
|
GValue *value);
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
void gtk_accessible_property_init_value (GtkAccessibleProperty property,
|
||||||
|
GValue *value);
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
void gtk_accessible_relation_init_value (GtkAccessibleRelation relation,
|
||||||
|
GValue *value);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -641,6 +641,7 @@ typedef struct {
|
|||||||
GCallback ctor;
|
GCallback ctor;
|
||||||
GCallback getter;
|
GCallback getter;
|
||||||
GCallback parser;
|
GCallback parser;
|
||||||
|
GCallback init_value;
|
||||||
} GtkAccessibleCollect;
|
} GtkAccessibleCollect;
|
||||||
|
|
||||||
static const GtkAccessibleCollect collect_states[] = {
|
static const GtkAccessibleCollect collect_states[] = {
|
||||||
@ -676,6 +677,7 @@ static const GtkAccessibleCollect collect_states[] = {
|
|||||||
.ctor = (GCallback) gtk_invalid_accessible_value_new,
|
.ctor = (GCallback) gtk_invalid_accessible_value_new,
|
||||||
.getter = (GCallback) gtk_invalid_accessible_value_get,
|
.getter = (GCallback) gtk_invalid_accessible_value_get,
|
||||||
.parser = (GCallback) gtk_invalid_accessible_value_parse,
|
.parser = (GCallback) gtk_invalid_accessible_value_parse,
|
||||||
|
.init_value = (GCallback) gtk_invalid_accessible_value_init_value,
|
||||||
},
|
},
|
||||||
[GTK_ACCESSIBLE_STATE_PRESSED] = {
|
[GTK_ACCESSIBLE_STATE_PRESSED] = {
|
||||||
.value = GTK_ACCESSIBLE_STATE_PRESSED,
|
.value = GTK_ACCESSIBLE_STATE_PRESSED,
|
||||||
@ -698,6 +700,7 @@ static const GtkAccessibleCollect collect_props[] = {
|
|||||||
.ctor = (GCallback) gtk_autocomplete_accessible_value_new,
|
.ctor = (GCallback) gtk_autocomplete_accessible_value_new,
|
||||||
.getter = (GCallback) gtk_autocomplete_accessible_value_get,
|
.getter = (GCallback) gtk_autocomplete_accessible_value_get,
|
||||||
.parser = (GCallback) gtk_autocomplete_accessible_value_parse,
|
.parser = (GCallback) gtk_autocomplete_accessible_value_parse,
|
||||||
|
.init_value = (GCallback) gtk_autocomplete_accessible_value_init_value,
|
||||||
},
|
},
|
||||||
[GTK_ACCESSIBLE_PROPERTY_DESCRIPTION] = {
|
[GTK_ACCESSIBLE_PROPERTY_DESCRIPTION] = {
|
||||||
.value = GTK_ACCESSIBLE_PROPERTY_DESCRIPTION,
|
.value = GTK_ACCESSIBLE_PROPERTY_DESCRIPTION,
|
||||||
@ -750,6 +753,7 @@ static const GtkAccessibleCollect collect_props[] = {
|
|||||||
.ctor = (GCallback) gtk_orientation_accessible_value_new,
|
.ctor = (GCallback) gtk_orientation_accessible_value_new,
|
||||||
.getter = (GCallback) gtk_orientation_accessible_value_get,
|
.getter = (GCallback) gtk_orientation_accessible_value_get,
|
||||||
.parser = (GCallback) gtk_orientation_accessible_value_parse,
|
.parser = (GCallback) gtk_orientation_accessible_value_parse,
|
||||||
|
.init_value = (GCallback) gtk_orientation_accessible_value_init_value,
|
||||||
},
|
},
|
||||||
[GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER] = {
|
[GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER] = {
|
||||||
.value = GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER,
|
.value = GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER,
|
||||||
@ -778,6 +782,7 @@ static const GtkAccessibleCollect collect_props[] = {
|
|||||||
.ctor = (GCallback) gtk_sort_accessible_value_new,
|
.ctor = (GCallback) gtk_sort_accessible_value_new,
|
||||||
.getter = (GCallback) gtk_sort_accessible_value_get,
|
.getter = (GCallback) gtk_sort_accessible_value_get,
|
||||||
.parser = (GCallback) gtk_sort_accessible_value_parse,
|
.parser = (GCallback) gtk_sort_accessible_value_parse,
|
||||||
|
.init_value = (GCallback) gtk_sort_accessible_value_init_value,
|
||||||
},
|
},
|
||||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_MAX] = {
|
[GTK_ACCESSIBLE_PROPERTY_VALUE_MAX] = {
|
||||||
.value = GTK_ACCESSIBLE_PROPERTY_VALUE_MAX,
|
.value = GTK_ACCESSIBLE_PROPERTY_VALUE_MAX,
|
||||||
@ -907,6 +912,7 @@ typedef GtkAccessibleValue * (* GtkAccessibleValueRefListCtor) (GList *value);
|
|||||||
typedef GtkAccessibleValue * (* GtkAccessibleValueEnumParser) (const char *str,
|
typedef GtkAccessibleValue * (* GtkAccessibleValueEnumParser) (const char *str,
|
||||||
gsize len,
|
gsize len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
typedef void (* GtkAccessibleValueEnumInit) (GValue *value);
|
||||||
|
|
||||||
/*< private >
|
/*< private >
|
||||||
* gtk_accessible_value_get_default_for_state:
|
* gtk_accessible_value_get_default_for_state:
|
||||||
@ -1099,6 +1105,8 @@ gtk_accessible_value_collect_valist (const GtkAccessibleCollect *cstate,
|
|||||||
{
|
{
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
res = gtk_reference_accessible_value_new (value);
|
res = gtk_reference_accessible_value_new (value);
|
||||||
|
else
|
||||||
|
res = gtk_undefined_accessible_value_new ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1448,6 +1456,75 @@ gtk_accessible_value_parse (const GtkAccessibleCollect *cstate,
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_accessible_attribute_init_value (const GtkAccessibleCollect *cstate,
|
||||||
|
GValue *value)
|
||||||
|
{
|
||||||
|
GtkAccessibleCollectType ctype = cstate->ctype;
|
||||||
|
gboolean collects_undef = (ctype & GTK_ACCESSIBLE_COLLECT_UNDEFINED) != 0;
|
||||||
|
|
||||||
|
ctype &= (GTK_ACCESSIBLE_COLLECT_UNDEFINED - 1);
|
||||||
|
|
||||||
|
/* Tristate values include "undefined" by definition */
|
||||||
|
if (ctype == GTK_ACCESSIBLE_COLLECT_TRISTATE)
|
||||||
|
collects_undef = TRUE;
|
||||||
|
|
||||||
|
switch (ctype)
|
||||||
|
{
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_BOOLEAN:
|
||||||
|
{
|
||||||
|
if (collects_undef)
|
||||||
|
g_value_init (value, G_TYPE_INT);
|
||||||
|
else
|
||||||
|
g_value_init (value, G_TYPE_BOOLEAN);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_TRISTATE:
|
||||||
|
g_value_init (value, GTK_TYPE_ACCESSIBLE_TRISTATE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_TOKEN:
|
||||||
|
if (cstate->init_value != NULL)
|
||||||
|
{
|
||||||
|
GtkAccessibleValueEnumInit init_value =
|
||||||
|
(GtkAccessibleValueEnumInit) cstate->init_value;
|
||||||
|
|
||||||
|
(* init_value) (value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_value_init (value, G_TYPE_INT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_INTEGER:
|
||||||
|
g_value_init (value, G_TYPE_INT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_NUMBER:
|
||||||
|
g_value_init (value, G_TYPE_DOUBLE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_STRING:
|
||||||
|
g_value_init (value, G_TYPE_STRING);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_REFERENCE:
|
||||||
|
g_value_init (value, GTK_TYPE_ACCESSIBLE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_REFERENCE_LIST:
|
||||||
|
g_value_init (value, G_TYPE_POINTER);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_UNDEFINED:
|
||||||
|
case GTK_ACCESSIBLE_COLLECT_INVALID:
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*< private >
|
/*< private >
|
||||||
* gtk_accessible_value_collect_for_state:
|
* gtk_accessible_value_collect_for_state:
|
||||||
* @state: a #GtkAccessibleState
|
* @state: a #GtkAccessibleState
|
||||||
@ -1517,6 +1594,27 @@ gtk_accessible_value_parse_for_state (GtkAccessibleState state,
|
|||||||
return gtk_accessible_value_parse (cstate, str, len, error);
|
return gtk_accessible_value_parse (cstate, str, len, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_accessible_state_init_value:
|
||||||
|
* @state: a #GtkAccessibleState
|
||||||
|
* @value: an uninitialized #GValue
|
||||||
|
*
|
||||||
|
* Initializes @value with the appropriate type for the @state.
|
||||||
|
*
|
||||||
|
* This function is mostly meant for language bindings, in conjunction
|
||||||
|
* with gtk_accessible_update_relation_state().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_accessible_state_init_value (GtkAccessibleState state,
|
||||||
|
GValue *value)
|
||||||
|
{
|
||||||
|
const GtkAccessibleCollect *cstate = &collect_states[state];
|
||||||
|
|
||||||
|
g_return_if_fail (state <= GTK_ACCESSIBLE_STATE_SELECTED);
|
||||||
|
|
||||||
|
gtk_accessible_attribute_init_value (cstate, value);
|
||||||
|
}
|
||||||
|
|
||||||
/*< private >
|
/*< private >
|
||||||
* gtk_accessible_value_get_default_for_property:
|
* gtk_accessible_value_get_default_for_property:
|
||||||
* @property: a #GtkAccessibleProperty
|
* @property: a #GtkAccessibleProperty
|
||||||
@ -1647,6 +1745,27 @@ gtk_accessible_value_parse_for_property (GtkAccessibleProperty property,
|
|||||||
return gtk_accessible_value_parse (cstate, str, len, error);
|
return gtk_accessible_value_parse (cstate, str, len, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_accessible_property_init_value:
|
||||||
|
* @property: a #GtkAccessibleProperty
|
||||||
|
* @value: an uninitialized #GValue
|
||||||
|
*
|
||||||
|
* Initializes @value with the appropriate type for the @property.
|
||||||
|
*
|
||||||
|
* This function is mostly meant for language bindings, in conjunction
|
||||||
|
* with gtk_accessible_update_property_value().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_accessible_property_init_value (GtkAccessibleProperty property,
|
||||||
|
GValue *value)
|
||||||
|
{
|
||||||
|
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||||
|
|
||||||
|
g_return_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT);
|
||||||
|
|
||||||
|
gtk_accessible_attribute_init_value (cstate, value);
|
||||||
|
}
|
||||||
|
|
||||||
/*< private >
|
/*< private >
|
||||||
* gtk_accessible_value_get_default_for_relation:
|
* gtk_accessible_value_get_default_for_relation:
|
||||||
* @relation: a #GtkAccessibleRelation
|
* @relation: a #GtkAccessibleRelation
|
||||||
@ -1769,4 +1888,25 @@ gtk_accessible_value_parse_for_relation (GtkAccessibleRelation relation,
|
|||||||
return gtk_accessible_value_parse (cstate, str, len, error);
|
return gtk_accessible_value_parse (cstate, str, len, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_accessible_relation_init_value:
|
||||||
|
* @relation: a #GtkAccessibleRelation
|
||||||
|
* @value: an uninitialized #GValue
|
||||||
|
*
|
||||||
|
* Initializes @value with the appropriate type for the @relation.
|
||||||
|
*
|
||||||
|
* This function is mostly meant for language bindings, in conjunction
|
||||||
|
* with gtk_accessible_update_relation_value().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_accessible_relation_init_value (GtkAccessibleRelation relation,
|
||||||
|
GValue *value)
|
||||||
|
{
|
||||||
|
const GtkAccessibleCollect *cstate = &collect_rels[relation];
|
||||||
|
|
||||||
|
g_return_if_fail (relation <= GTK_ACCESSIBLE_RELATION_SET_SIZE);
|
||||||
|
|
||||||
|
gtk_accessible_attribute_init_value (cstate, value);
|
||||||
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -158,23 +158,27 @@ GtkAccessibleInvalidState gtk_invalid_accessible_value_get (const G
|
|||||||
GtkAccessibleValue * gtk_invalid_accessible_value_parse (const char *str,
|
GtkAccessibleValue * gtk_invalid_accessible_value_parse (const char *str,
|
||||||
gsize len,
|
gsize len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
void gtk_invalid_accessible_value_init_value (GValue *value);
|
||||||
|
|
||||||
GtkAccessibleValue * gtk_autocomplete_accessible_value_new (GtkAccessibleAutocomplete value);
|
GtkAccessibleValue * gtk_autocomplete_accessible_value_new (GtkAccessibleAutocomplete value);
|
||||||
GtkAccessibleAutocomplete gtk_autocomplete_accessible_value_get (const GtkAccessibleValue *value);
|
GtkAccessibleAutocomplete gtk_autocomplete_accessible_value_get (const GtkAccessibleValue *value);
|
||||||
GtkAccessibleValue * gtk_autocomplete_accessible_value_parse (const char *str,
|
GtkAccessibleValue * gtk_autocomplete_accessible_value_parse (const char *str,
|
||||||
gsize len,
|
gsize len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
void gtk_autocomplete_accessible_value_init_value (GValue *value);
|
||||||
|
|
||||||
GtkAccessibleValue * gtk_orientation_accessible_value_new (GtkOrientation value);
|
GtkAccessibleValue * gtk_orientation_accessible_value_new (GtkOrientation value);
|
||||||
GtkOrientation gtk_orientation_accessible_value_get (const GtkAccessibleValue *value);
|
GtkOrientation gtk_orientation_accessible_value_get (const GtkAccessibleValue *value);
|
||||||
GtkAccessibleValue * gtk_orientation_accessible_value_parse (const char *str,
|
GtkAccessibleValue * gtk_orientation_accessible_value_parse (const char *str,
|
||||||
gsize len,
|
gsize len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
void gtk_orientation_accessible_value_init_value (GValue *value);
|
||||||
|
|
||||||
GtkAccessibleValue * gtk_sort_accessible_value_new (GtkAccessibleSort value);
|
GtkAccessibleValue * gtk_sort_accessible_value_new (GtkAccessibleSort value);
|
||||||
GtkAccessibleSort gtk_sort_accessible_value_get (const GtkAccessibleValue *value);
|
GtkAccessibleSort gtk_sort_accessible_value_get (const GtkAccessibleValue *value);
|
||||||
GtkAccessibleValue * gtk_sort_accessible_value_parse (const char *str,
|
GtkAccessibleValue * gtk_sort_accessible_value_parse (const char *str,
|
||||||
gsize len,
|
gsize len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
void gtk_sort_accessible_value_init_value (GValue *value);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -298,6 +298,12 @@ gtk_invalid_accessible_value_parse (const char *str,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_invalid_accessible_value_init_value (GValue *value)
|
||||||
|
{
|
||||||
|
g_value_init (value, GTK_TYPE_ACCESSIBLE_INVALID_STATE);
|
||||||
|
}
|
||||||
|
|
||||||
static const GtkAccessibleValueClass GTK_AUTOCOMPLETE_ACCESSIBLE_VALUE = {
|
static const GtkAccessibleValueClass GTK_AUTOCOMPLETE_ACCESSIBLE_VALUE = {
|
||||||
.type = GTK_ACCESSIBLE_VALUE_TYPE_TOKEN,
|
.type = GTK_ACCESSIBLE_VALUE_TYPE_TOKEN,
|
||||||
.type_name = "GtkAutocompleteAccessibleValue",
|
.type_name = "GtkAutocompleteAccessibleValue",
|
||||||
@ -356,6 +362,12 @@ gtk_autocomplete_accessible_value_parse (const char *str,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_autocomplete_accessible_value_init_value (GValue *value)
|
||||||
|
{
|
||||||
|
g_value_init (value, GTK_TYPE_ACCESSIBLE_AUTOCOMPLETE);
|
||||||
|
}
|
||||||
|
|
||||||
static const GtkAccessibleValueClass GTK_ORIENTATION_ACCESSIBLE_VALUE = {
|
static const GtkAccessibleValueClass GTK_ORIENTATION_ACCESSIBLE_VALUE = {
|
||||||
.type = GTK_ACCESSIBLE_VALUE_TYPE_TOKEN,
|
.type = GTK_ACCESSIBLE_VALUE_TYPE_TOKEN,
|
||||||
.type_name = "GtkOrientationAccessibleValue",
|
.type_name = "GtkOrientationAccessibleValue",
|
||||||
@ -408,6 +420,12 @@ gtk_orientation_accessible_value_parse (const char *str,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_orientation_accessible_value_init_value (GValue *value)
|
||||||
|
{
|
||||||
|
g_value_init (value, GTK_TYPE_ORIENTATION);
|
||||||
|
}
|
||||||
|
|
||||||
static const GtkAccessibleValueClass GTK_SORT_ACCESSIBLE_VALUE = {
|
static const GtkAccessibleValueClass GTK_SORT_ACCESSIBLE_VALUE = {
|
||||||
.type = GTK_ACCESSIBLE_VALUE_TYPE_TOKEN,
|
.type = GTK_ACCESSIBLE_VALUE_TYPE_TOKEN,
|
||||||
.type_name = "GtkSortAccessibleValue",
|
.type_name = "GtkSortAccessibleValue",
|
||||||
@ -466,4 +484,10 @@ gtk_sort_accessible_value_parse (const char *str,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_sort_accessible_value_init_value (GValue *value)
|
||||||
|
{
|
||||||
|
g_value_init (value, GTK_TYPE_ACCESSIBLE_SORT);
|
||||||
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
Loading…
Reference in New Issue
Block a user