1 /* GAIL - The GNOME Accessibility Implementation Library
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"
24 G_DEFINE_TYPE (GtkMenuAccessible, _gtk_menu_accessible, GTK_TYPE_MENU_SHELL_ACCESSIBLE)
27 gtk_menu_accessible_initialize (AtkObject *obj,
30 ATK_OBJECT_CLASS (_gtk_menu_accessible_parent_class)->initialize (obj, data);
32 obj->role = ATK_ROLE_MENU;
34 GTK_WIDGET_ACCESSIBLE (obj)->layer = ATK_LAYER_POPUP;
38 gtk_menu_accessible_get_parent (AtkObject *accessible)
41 GtkWidget *widget, *parent_widget;
43 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
47 parent = accessible->accessible_parent;
51 /* If the menu is attached to a menu item or a button (Gnome Menu)
52 * report the menu item as parent.
54 parent_widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
56 if (!GTK_IS_MENU_ITEM (parent_widget) &&
57 !GTK_IS_BUTTON (parent_widget) &&
58 !GTK_IS_COMBO_BOX (parent_widget))
59 parent_widget = gtk_widget_get_parent (widget);
61 if (parent_widget == NULL)
64 parent = gtk_widget_get_accessible (parent_widget);
65 atk_object_set_parent (accessible, parent);
71 gtk_menu_accessible_get_index_in_parent (AtkObject *accessible)
75 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
79 if (gtk_menu_get_attach_widget (GTK_MENU (widget)))
82 return ATK_OBJECT_CLASS (_gtk_menu_accessible_parent_class)->get_index_in_parent (accessible);
86 _gtk_menu_accessible_class_init (GtkMenuAccessibleClass *klass)
88 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
90 class->get_parent = gtk_menu_accessible_get_parent;
91 class->get_index_in_parent = gtk_menu_accessible_get_index_in_parent;
92 class->initialize = gtk_menu_accessible_initialize;
96 _gtk_menu_accessible_init (GtkMenuAccessible *accessible)