1 /* GTK+ - accessibility implementations
2 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 #include "gtkmenuaccessible.h"
21 #include "gtkwidgetaccessibleprivate.h"
25 G_DEFINE_TYPE (GtkMenuAccessible, gtk_menu_accessible, GTK_TYPE_MENU_SHELL_ACCESSIBLE)
28 gtk_menu_accessible_initialize (AtkObject *obj,
31 ATK_OBJECT_CLASS (gtk_menu_accessible_parent_class)->initialize (obj, data);
33 obj->role = ATK_ROLE_MENU;
35 _gtk_widget_accessible_set_layer (GTK_WIDGET_ACCESSIBLE (obj), ATK_LAYER_POPUP);
39 gtk_menu_accessible_get_parent (AtkObject *accessible)
42 GtkWidget *widget, *parent_widget;
44 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
48 parent = accessible->accessible_parent;
52 /* If the menu is attached to a menu item or a button (Gnome Menu)
53 * report the menu item as parent.
55 parent_widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
57 if (!GTK_IS_MENU_ITEM (parent_widget) &&
58 !GTK_IS_BUTTON (parent_widget) &&
59 !GTK_IS_COMBO_BOX (parent_widget))
60 parent_widget = gtk_widget_get_parent (widget);
62 if (parent_widget == NULL)
65 parent = gtk_widget_get_accessible (parent_widget);
66 atk_object_set_parent (accessible, parent);
72 gtk_menu_accessible_get_index_in_parent (AtkObject *accessible)
76 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
80 if (gtk_menu_get_attach_widget (GTK_MENU (widget)))
83 return ATK_OBJECT_CLASS (gtk_menu_accessible_parent_class)->get_index_in_parent (accessible);
87 gtk_menu_accessible_class_init (GtkMenuAccessibleClass *klass)
89 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
91 class->get_parent = gtk_menu_accessible_get_parent;
92 class->get_index_in_parent = gtk_menu_accessible_get_index_in_parent;
93 class->initialize = gtk_menu_accessible_initialize;
97 gtk_menu_accessible_init (GtkMenuAccessible *accessible)