[gtk: 9/60] a11y: Allow bulk attribute update with the GValue API
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 9/60] a11y: Allow bulk attribute update with the GValue API
- Date: Sat, 5 Sep 2020 13:54:20 +0000 (UTC)
commit 92737b27bf1f074b16f27106647d858439caa97f
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Aug 5 15:03:00 2020 +0100
a11y: Allow bulk attribute update with the GValue API
Like we do for the varargs API.
gtk/gtkaccessible.c | 150 +++++++++++++++++++++++++++++-----------------------
gtk/gtkaccessible.h | 15 +++---
2 files changed, 93 insertions(+), 72 deletions(-)
---
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index f8dc8640af..b136f1a946 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -174,10 +174,11 @@ out:
/**
* gtk_accessible_update_state_value:
* @self: a #GtkAccessible
- * @state: a #GtkAccessibleState
- * @value: a #GValue with the value for @state
+ * @n_states: the number of accessible states to set
+ * @states: (array length=n_states): an array of #GtkAccessibleState
+ * @values: (array length=n_states): an array of #GValues, one for each state
*
- * Updates an accessible state.
+ * Updates an array of accessible states.
*
* This function should be called by #GtkWidget types whenever an accessible
* state change must be communicated to assistive technologies.
@@ -186,34 +187,39 @@ out:
*/
void
gtk_accessible_update_state_value (GtkAccessible *self,
- GtkAccessibleState state,
- const GValue *value)
+ int n_states,
+ GtkAccessibleState states[],
+ const GValue values[])
{
- GtkATContext *context;
-
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
+ g_return_if_fail (n_states > 0);
- context = gtk_accessible_get_at_context (self);
+ GtkATContext *context = gtk_accessible_get_at_context (self);
if (context == NULL)
return;
- GError *error = NULL;
- GtkAccessibleValue *real_value =
- gtk_accessible_value_collect_for_state_value (state, value, &error);
-
- if (error != NULL)
+ for (int i = 0; i < n_states; i++)
{
- g_critical ("Unable to collect the value for state “%s”: %s",
- gtk_accessible_state_get_attribute_name (state),
- error->message);
- g_error_free (error);
- return;
- }
+ GtkAccessibleState state = states[i];
+ const GValue *value = &(values[i]);
+ GError *error = NULL;
+ GtkAccessibleValue *real_value =
+ gtk_accessible_value_collect_for_state_value (state, value, &error);
- gtk_at_context_set_accessible_state (context, state, real_value);
+ if (error != NULL)
+ {
+ g_critical ("Unable to collect the value for state “%s”: %s",
+ gtk_accessible_state_get_attribute_name (state),
+ error->message);
+ g_error_free (error);
+ break;
+ }
+
+ gtk_at_context_set_accessible_state (context, state, real_value);
- if (real_value != NULL)
- gtk_accessible_value_unref (real_value);
+ if (real_value != NULL)
+ gtk_accessible_value_unref (real_value);
+ }
gtk_at_context_update (context);
}
@@ -312,10 +318,11 @@ out:
/**
* gtk_accessible_update_property_value:
* @self: a #GtkAccessible
- * @property: a #GtkAccessibleProperty
- * @value: a #GValue with the value for @property
+ * @n_properties: the number of accessible properties to set
+ * @properties: (array length=n_properties): an array of #GtkAccessibleProperty
+ * @values: (array length=n_properties): an array of #GValues, one for each property
*
- * Updates an accessible property.
+ * Updates an array of accessible properties.
*
* This function should be called by #GtkWidget types whenever an accessible
* property change must be communicated to assistive technologies.
@@ -324,34 +331,39 @@ out:
*/
void
gtk_accessible_update_property_value (GtkAccessible *self,
- GtkAccessibleProperty property,
- const GValue *value)
+ int n_properties,
+ GtkAccessibleProperty properties[],
+ const GValue values[])
{
- GtkATContext *context;
-
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
+ g_return_if_fail (n_properties > 0);
- context = gtk_accessible_get_at_context (self);
+ GtkATContext *context = gtk_accessible_get_at_context (self);
if (context == NULL)
return;
- GError *error = NULL;
- GtkAccessibleValue *real_value =
- gtk_accessible_value_collect_for_property_value (property, value, &error);
-
- if (error != NULL)
+ for (int i = 0; i < n_properties; i++)
{
- g_critical ("Unable to collect the value for property “%s”: %s",
- gtk_accessible_property_get_attribute_name (property),
- error->message);
- g_error_free (error);
- return;
- }
+ GtkAccessibleProperty property = properties[i];
+ const GValue *value = &(values[i]);
+ GError *error = NULL;
+ GtkAccessibleValue *real_value =
+ gtk_accessible_value_collect_for_property_value (property, value, &error);
+
+ if (error != NULL)
+ {
+ g_critical ("Unable to collect the value for property “%s”: %s",
+ gtk_accessible_property_get_attribute_name (property),
+ error->message);
+ g_error_free (error);
+ break;
+ }
- gtk_at_context_set_accessible_property (context, property, real_value);
+ gtk_at_context_set_accessible_property (context, property, real_value);
- if (real_value != NULL)
- gtk_accessible_value_unref (real_value);
+ if (real_value != NULL)
+ gtk_accessible_value_unref (real_value);
+ }
gtk_at_context_update (context);
}
@@ -441,10 +453,11 @@ out:
/**
* gtk_accessible_update_relation_value:
* @self: a #GtkAccessible
- * @relation: a #GtkAccessibleRelation
- * @value: a #GValue with the value for @relation
+ * @n_relations: the number of accessible relations to set
+ * @relations: (array length=n_relations): an array of #GtkAccessibleRelation
+ * @values: (array length=n_relations): an array of #GValues, one for each relation
*
- * Updates an accessible relation.
+ * Updates an array of accessible relations.
*
* This function should be called by #GtkWidget types whenever an accessible
* relation change must be communicated to assistive technologies.
@@ -453,34 +466,39 @@ out:
*/
void
gtk_accessible_update_relation_value (GtkAccessible *self,
- GtkAccessibleRelation relation,
- const GValue *value)
+ int n_relations,
+ GtkAccessibleRelation relations[],
+ const GValue values[])
{
- GtkATContext *context;
-
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
+ g_return_if_fail (n_relations > 0);
- context = gtk_accessible_get_at_context (self);
+ GtkATContext *context = gtk_accessible_get_at_context (self);
if (context == NULL)
return;
- GError *error = NULL;
- GtkAccessibleValue *real_value =
- gtk_accessible_value_collect_for_relation_value (relation, value, &error);
-
- if (error != NULL)
+ for (int i = 0; i < n_relations; i++)
{
- g_critical ("Unable to collect the value for relation “%s”: %s",
- gtk_accessible_relation_get_attribute_name (relation),
- error->message);
- g_error_free (error);
- return;
- }
+ GtkAccessibleRelation relation = relations[i];
+ const GValue *value = &(values[i]);
+ GError *error = NULL;
+ GtkAccessibleValue *real_value =
+ gtk_accessible_value_collect_for_relation_value (relation, value, &error);
+
+ if (error != NULL)
+ {
+ g_critical ("Unable to collect the value for relation “%s”: %s",
+ gtk_accessible_relation_get_attribute_name (relation),
+ error->message);
+ g_error_free (error);
+ break;
+ }
- gtk_at_context_set_accessible_relation (context, relation, real_value);
+ gtk_at_context_set_accessible_relation (context, relation, real_value);
- if (real_value != NULL)
- gtk_accessible_value_unref (real_value);
+ if (real_value != NULL)
+ gtk_accessible_value_unref (real_value);
+ }
gtk_at_context_update (context);
}
diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h
index 0aec20974f..c8b00cd35b 100644
--- a/gtk/gtkaccessible.h
+++ b/gtk/gtkaccessible.h
@@ -52,16 +52,19 @@ void gtk_accessible_update_relation (GtkAccessible
...);
GDK_AVAILABLE_IN_ALL
void gtk_accessible_update_state_value (GtkAccessible *self,
- GtkAccessibleState state,
- const GValue *value);
+ int n_states,
+ GtkAccessibleState states[],
+ const GValue values[]);
GDK_AVAILABLE_IN_ALL
void gtk_accessible_update_property_value (GtkAccessible *self,
- GtkAccessibleProperty property,
- const GValue *value);
+ int n_properties,
+ GtkAccessibleProperty properties[],
+ const GValue values[]);
GDK_AVAILABLE_IN_ALL
void gtk_accessible_update_relation_value (GtkAccessible *self,
- GtkAccessibleRelation relation,
- const GValue *value);
+ int n_relations,
+ GtkAccessibleRelation relations[],
+ const GValue values[]);
GDK_AVAILABLE_IN_ALL
void gtk_accessible_reset_state (GtkAccessible *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]