Commit fec8a1ee authored by Matthias Clasen's avatar Matthias Clasen

menu button: Improve accessibility

Rework the way we assign an accessible name to menu buttons,
to make sure we pick up a label, should the button contain
one, and only override the name with "Menu" as a fallback.
parent 98730f71
......@@ -18,6 +18,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "gtkmenubuttonaccessible.h"
......@@ -84,11 +85,29 @@ gtk_menu_button_accessible_ref_child (AtkObject *obj,
return accessible;
}
static const gchar *
gtk_menu_button_accessible_get_name (AtkObject *obj)
{
const gchar *name = NULL;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_menu_button_accessible_parent_class)->get_name (obj);
if (name != NULL)
return name;
return _("Menu");
}
static void
gtk_menu_button_accessible_class_init (GtkMenuButtonAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gtk_menu_button_accessible_get_name;
class->initialize = gtk_menu_button_accessible_initialize;
class->get_n_children = gtk_menu_button_accessible_get_n_children;
class->ref_child = gtk_menu_button_accessible_ref_child;
......
......@@ -624,7 +624,6 @@ static void
gtk_menu_button_init (GtkMenuButton *menu_button)
{
GtkMenuButtonPrivate *priv;
AtkObject *accessible;
priv = gtk_menu_button_get_instance_private (menu_button);
menu_button->priv = priv;
......@@ -634,10 +633,6 @@ gtk_menu_button_init (GtkMenuButton *menu_button)
add_arrow (menu_button);
gtk_widget_set_sensitive (GTK_WIDGET (menu_button), FALSE);
accessible = gtk_widget_get_accessible (GTK_WIDGET (menu_button));
if (GTK_IS_ACCESSIBLE (accessible))
atk_object_set_name (accessible, _("Menu"));
}
/**
......
......@@ -30,6 +30,7 @@ gtk/a11y/gtkcomboboxaccessible.c
gtk/a11y/gtkentryaccessible.c
gtk/a11y/gtkexpanderaccessible.c
gtk/a11y/gtkimageaccessible.c
gtk/a11y/gtkmenubuttonaccessible.c
gtk/a11y/gtkmenuitemaccessible.c
gtk/a11y/gtkrenderercellaccessible.c
gtk/a11y/gtkscalebuttonaccessible.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment