[gtk/ebassi/new-a11y: 24/29] a11y: Add binding-friendly accessible property setter



commit 5d9661322603929a896933188570df70013d6674
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Jul 13 17:47:36 2020 +0100

    a11y: Add binding-friendly accessible property setter
    
    Matching the one for the accessible state.

 gtk/gtkaccessible.c | 37 +++++++++++++++++++++++++++++++++++++
 gtk/gtkaccessible.h |  4 ++++
 2 files changed, 41 insertions(+)
---
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index 0d6e2bd717..c06612ba83 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -239,3 +239,40 @@ gtk_accessible_update_property (GtkAccessible         *self,
 out:
   va_end (args);
 }
+
+/**
+ * gtk_accessible_update_property_value:
+ * @self: a #GtkAccessible
+ * @property: a #GtkAccessibleProperty
+ * @value: a #GValue with the value for @property
+ *
+ * Updates an accessible property.
+ *
+ * This function should be called by #GtkWidget types whenever an accessible
+ * property change must be communicated to assistive technologies.
+ *
+ * This function is meant to be used by language bindings.
+ */
+void
+gtk_accessible_update_property_value (GtkAccessible         *self,
+                                      GtkAccessibleProperty  property,
+                                      const GValue          *value)
+{
+  GtkATContext *context;
+
+  g_return_if_fail (GTK_IS_ACCESSIBLE (self));
+
+  context = gtk_accessible_get_at_context (self);
+  if (context == NULL)
+    return;
+
+  GtkAccessibleValue *real_value =
+    gtk_accessible_value_collect_for_property_value (property, value);
+
+  if (real_value == NULL)
+    return;
+
+  gtk_at_context_set_accessible_property (context, property, real_value);
+  gtk_accessible_value_unref (real_value);
+  gtk_at_context_update (context);
+}
diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h
index f95ba930d2..9ad56784c7 100644
--- a/gtk/gtkaccessible.h
+++ b/gtk/gtkaccessible.h
@@ -46,5 +46,9 @@ GDK_AVAILABLE_IN_ALL
 void                    gtk_accessible_update_state_value       (GtkAccessible         *self,
                                                                  GtkAccessibleState     state,
                                                                  const GValue          *value);
+GDK_AVAILABLE_IN_ALL
+void                    gtk_accessible_update_property_value    (GtkAccessible         *self,
+                                                                 GtkAccessibleProperty  property,
+                                                                 const GValue          *value);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]