atcontext: Change the way we handle fallback

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/
This commit is contained in:
Matthias Clasen 2023-06-11 19:27:18 -04:00
parent 22548785b0
commit 79847f20c4
2 changed files with 19 additions and 4 deletions

View File

@ -1075,6 +1075,15 @@ gtk_at_context_get_name_accumulate (GtkATContext *self,
return; 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 static void
@ -1148,6 +1157,16 @@ gtk_at_context_get_description_accumulate (GtkATContext *self,
if (gtk_boolean_accessible_value_get (value)) if (gtk_boolean_accessible_value_get (value))
return; 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[] = { static GtkAccessibleRole name_forbidden[] = {

View File

@ -9917,10 +9917,6 @@ gtk_widget_set_tooltip_text (GtkWidget *widget,
priv->tooltip_text = tooltip_text; priv->tooltip_text = tooltip_text;
priv->tooltip_markup = tooltip_markup; 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); gtk_widget_set_has_tooltip (widget, priv->tooltip_text != NULL);
if (_gtk_widget_get_visible (widget)) if (_gtk_widget_get_visible (widget))
gtk_widget_trigger_tooltip_query (widget); gtk_widget_trigger_tooltip_query (widget);