[gtk/a11y/buildable] a11y: Handle relations in UI files
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gtk/a11y/buildable] a11y: Handle relations in UI files
- Date: Wed, 21 Oct 2020 14:00:49 +0000 (UTC)
commit 80756322cd13dd7a4c5f73f797f2603d01ece06a
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Oct 21 14:48:49 2020 +0100
    a11y: Handle relations in UI files
    
    A bit hacky: we skip parsing values that have a reference or
    reference-list type, but we do not error out. Instead, we return a NULL
    value, which we catch in the GtkBuildable interface implementation to
    get the actual object, and construct a reference list value.
    
    There's still some ickyness around the value type that can only be
    solved by having an attribute and role taxonomy.
 gtk/gtkaccessiblevalue.c |  7 +++----
 gtk/gtkwidget.c          | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkaccessiblevalue.c b/gtk/gtkaccessiblevalue.c
index 45bf824648..5a4edd5d85 100644
--- a/gtk/gtkaccessiblevalue.c
+++ b/gtk/gtkaccessiblevalue.c
@@ -1445,11 +1445,10 @@ gtk_accessible_value_parse (const GtkAccessibleCollect  *cstate,
     case GTK_ACCESSIBLE_COLLECT_REFERENCE:
     case GTK_ACCESSIBLE_COLLECT_REFERENCE_LIST:
       {
+        /* We do not error out, to let the caller code deal
+         * with the references themselves
+         */
         res = NULL;
-        g_set_error (error, GTK_ACCESSIBLE_VALUE_ERROR,
-                     GTK_ACCESSIBLE_VALUE_ERROR_INVALID_VALUE,
-                     "Invalid relation “%s”",
-                     str);
       }
       break;
 
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8747e8efcd..aa85cb6ddb 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8831,6 +8831,23 @@ gtk_widget_buildable_finish_accessibility_properties (GtkWidget *widget,
           continue;
         }
 
+      if (value == NULL)
+        {
+          GObject *obj = gtk_builder_get_object (accessibility_data->builder,
+                                                 pinfo->value->str);
+
+          if (obj == NULL)
+            {
+              g_warning ("Failed to find accessible object “%s” for relation “%s”",
+                         pinfo->value->str,
+                         pinfo->name);
+              continue;
+            }
+
+          /* FIXME: Need to distinguish between refs and refslist types */
+          value = gtk_reference_list_accessible_value_new (g_list_append (NULL, obj));
+        }
+
       gtk_at_context_set_accessible_relation (context, relation, value);
       gtk_accessible_value_unref (value);
     }
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]