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.
This commit is contained in:
Matthias Clasen
2015-03-13 18:38:18 -04:00
parent 98730f71f9
commit fec8a1ee7f
3 changed files with 20 additions and 5 deletions

View File

@ -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;