mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
button: Improve accessible setup
With the current approach, we get duplicate labels in the accessible name: _Cancel Cancel. Change things around to always set the labelled-by accessible relation if we have a label, and not the label accessible property.
This commit is contained in:
parent
5e07710f5a
commit
cf30a4f304
@ -842,7 +842,7 @@ gtk_button_finish_activate (GtkButton *button,
|
||||
* This will also clear any previously set labels.
|
||||
*/
|
||||
void
|
||||
gtk_button_set_label (GtkButton *button,
|
||||
gtk_button_set_label (GtkButton *button,
|
||||
const char *label)
|
||||
{
|
||||
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
||||
@ -853,13 +853,18 @@ gtk_button_set_label (GtkButton *button,
|
||||
if (priv->child_type != LABEL_CHILD || priv->child == NULL)
|
||||
{
|
||||
child = gtk_label_new (NULL);
|
||||
gtk_button_set_child (button, child);
|
||||
if (priv->use_underline)
|
||||
{
|
||||
gtk_label_set_use_underline (GTK_LABEL (child), priv->use_underline);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (child), GTK_WIDGET (button));
|
||||
}
|
||||
|
||||
gtk_button_set_child (button, child);
|
||||
else
|
||||
{
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, child, NULL,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (priv->child), label);
|
||||
@ -869,10 +874,6 @@ gtk_button_set_label (GtkButton *button,
|
||||
|
||||
gtk_button_set_child_type (button, LABEL_CHILD);
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, label,
|
||||
-1);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "gtkheaderbar.h"
|
||||
#include "gtkactionable.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkaccessible.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
@ -189,6 +190,10 @@ setup_tweak_button (GtkFontChooserDialog *dialog)
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_button_set_icon_name (GTK_BUTTON (button), "emblem-system-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, _("Change Font Features"));
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL,
|
||||
_("Change Font Features"),
|
||||
-1);
|
||||
|
||||
header = gtk_dialog_get_header_bar (GTK_DIALOG (dialog));
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
@ -63,19 +63,29 @@
|
||||
<property name="activates-default">1</property>
|
||||
<property name="placeholder-text" translatable="yes">Search font name</property>
|
||||
<signal name="stop-search" handler="stop_search_cb" swapped="no"/>
|
||||
<accessibility>
|
||||
<property name="label" translatable="1">Search font name</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<accessibility>
|
||||
<property name="label" translatable="1">Filters</property>
|
||||
</accessibility>
|
||||
<property name="icon-name">pan-down-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Filters</property>
|
||||
<property name="popover">
|
||||
<object class="GtkPopover">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">1</property>
|
||||
<property name="spacing">6</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">filter_by_label</relation>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<object class="GtkLabel" id="filter_by_label">
|
||||
<property name="label" translatable="yes">Filter by</property>
|
||||
<property name="width-chars">20</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
|
@ -20,7 +20,8 @@ button_label (void)
|
||||
GtkWidget *button = gtk_button_new_with_label ("Hello");
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_test_accessible_assert_property (button, GTK_ACCESSIBLE_PROPERTY_LABEL, "Hello");
|
||||
gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, gtk_widget_get_first_child (button), NULL);
|
||||
|
||||
g_object_unref (button);
|
||||
}
|
||||
@ -58,7 +59,8 @@ linkbutton_label (void)
|
||||
GtkWidget *button = gtk_link_button_new ("Hello");
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_test_accessible_assert_property (button, GTK_ACCESSIBLE_PROPERTY_LABEL, "Hello");
|
||||
gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, gtk_widget_get_first_child (button), NULL);
|
||||
|
||||
g_object_unref (button);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user