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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 #include "gtkmenuaccessible.h"
26 G_DEFINE_TYPE (GtkMenuAccessible, _gtk_menu_accessible, GTK_TYPE_MENU_SHELL_ACCESSIBLE)
29 gtk_menu_accessible_initialize (AtkObject *obj,
32 ATK_OBJECT_CLASS (_gtk_menu_accessible_parent_class)->initialize (obj, data);
34 obj->role = ATK_ROLE_MENU;
36 GTK_WIDGET_ACCESSIBLE (obj)->layer = ATK_LAYER_POPUP;
40 gtk_menu_accessible_get_parent (AtkObject *accessible)
43 GtkWidget *widget, *parent_widget;
45 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
49 parent = accessible->accessible_parent;
53 /* If the menu is attached to a menu item or a button (Gnome Menu)
54 * report the menu item as parent.
56 parent_widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
58 if (!GTK_IS_MENU_ITEM (parent_widget) &&
59 !GTK_IS_BUTTON (parent_widget) &&
60 !GTK_IS_COMBO_BOX (parent_widget))
61 parent_widget = gtk_widget_get_parent (widget);
63 if (parent_widget == NULL)
66 parent = gtk_widget_get_accessible (parent_widget);
67 atk_object_set_parent (accessible, parent);
73 gtk_menu_accessible_get_index_in_parent (AtkObject *accessible)
77 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
81 if (gtk_menu_get_attach_widget (GTK_MENU (widget)))
84 return ATK_OBJECT_CLASS (_gtk_menu_accessible_parent_class)->get_index_in_parent (accessible);
88 _gtk_menu_accessible_class_init (GtkMenuAccessibleClass *klass)
90 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
92 class->get_parent = gtk_menu_accessible_get_parent;
93 class->get_index_in_parent = gtk_menu_accessible_get_index_in_parent;
94 class->initialize = gtk_menu_accessible_initialize;
98 _gtk_menu_accessible_init (GtkMenuAccessible *accessible)