atcontext: Change the way we handle fallback
authorMatthias Clasen <mclasen@redhat.com>
Sun, 11 Jun 2023 23:27:18 +0000 (19:27 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 12 Jun 2023 00:27:31 +0000 (20:27 -0400)
The tooltip text should only be considered after
all other means are exhausted. but it can be used
for both the name and the description.

See https://www.w3.org/TR/accname-1.2/

gtk/gtkatcontext.c
gtk/gtkwidget.c

index d12a5be9bdca92693ba1190bc5a81aeb3b84a795..922ca94668a302951034260667f20af1db699826 100644 (file)
@@ -1075,6 +1075,15 @@ gtk_at_context_get_name_accumulate (GtkATContext *self,
         return;
     }
 
+  if (names->len == 0)
+    {
+      if (GTK_IS_WIDGET (self->accessible))
+        {
+          const char *tooltip = gtk_widget_get_tooltip_text (GTK_WIDGET (self->accessible));
+          if (tooltip)
+            g_ptr_array_add (names, (char *) tooltip);
+        }
+    }
 }
 
 static void
@@ -1148,6 +1157,16 @@ gtk_at_context_get_description_accumulate (GtkATContext *self,
       if (gtk_boolean_accessible_value_get (value))
         return;
     }
+
+  if (labels->len == 0)
+    {
+      if (GTK_IS_WIDGET (self->accessible))
+        {
+          const char *tooltip = gtk_widget_get_tooltip_text (GTK_WIDGET (self->accessible));
+          if (tooltip)
+            g_ptr_array_add (labels, (char *) tooltip);
+        }
+    }
 }
 
 static GtkAccessibleRole name_forbidden[] = {
index ee2d09de3cc9be2c87cf4afaa031e28c0374ea39..9e8c1e038bfdefa56164d4d36323eaae73330754 100644 (file)
@@ -9917,10 +9917,6 @@ gtk_widget_set_tooltip_text (GtkWidget  *widget,
   priv->tooltip_text = tooltip_text;
   priv->tooltip_markup = tooltip_markup;
 
-  gtk_accessible_update_property (GTK_ACCESSIBLE (widget),
-                                  GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, priv->tooltip_text,
-                                  -1);
-
   gtk_widget_set_has_tooltip (widget, priv->tooltip_text != NULL);
   if (_gtk_widget_get_visible (widget))
     gtk_widget_trigger_tooltip_query (widget);