1 /* GTK+ - accessibility implementations
2 * Copyright 2001 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/>.
21 #include "gtkmenushellaccessible.h"
24 static void atk_selection_interface_init (AtkSelectionIface *iface);
26 G_DEFINE_TYPE_WITH_CODE (GtkMenuShellAccessible, gtk_menu_shell_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
27 G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
30 gtk_menu_shell_accessible_initialize (AtkObject *accessible,
33 ATK_OBJECT_CLASS (gtk_menu_shell_accessible_parent_class)->initialize (accessible, data);
35 accessible->role = ATK_ROLE_UNKNOWN;
39 gtk_menu_shell_accessible_class_init (GtkMenuShellAccessibleClass *klass)
41 AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
43 atk_object_class->initialize = gtk_menu_shell_accessible_initialize;
47 gtk_menu_shell_accessible_init (GtkMenuShellAccessible *menu_shell)
52 gtk_menu_shell_accessible_add_selection (AtkSelection *selection,
60 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
64 kids = gtk_container_get_children (GTK_CONTAINER (widget));
65 length = g_list_length (kids);
66 if (i < 0 || i > length)
72 item = g_list_nth_data (kids, i);
74 g_return_val_if_fail (GTK_IS_MENU_ITEM (item), FALSE);
75 gtk_menu_shell_select_item (GTK_MENU_SHELL (widget), item);
80 gtk_menu_shell_accessible_clear_selection (AtkSelection *selection)
85 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
89 shell = GTK_MENU_SHELL (widget);
91 gtk_menu_shell_deselect (shell);
96 gtk_menu_shell_accessible_ref_selection (AtkSelection *selection,
104 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
111 shell = GTK_MENU_SHELL (widget);
113 item = gtk_menu_shell_get_selected_item (shell);
116 obj = gtk_widget_get_accessible (item);
124 gtk_menu_shell_accessible_get_selection_count (AtkSelection *selection)
129 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
133 shell = GTK_MENU_SHELL (widget);
135 if (gtk_menu_shell_get_selected_item (shell) != NULL)
142 gtk_menu_shell_accessible_is_child_selected (AtkSelection *selection,
151 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
155 shell = GTK_MENU_SHELL (widget);
156 item = gtk_menu_shell_get_selected_item (shell);
160 kids = gtk_container_get_children (GTK_CONTAINER (shell));
161 j = g_list_index (kids, item);
168 gtk_menu_shell_accessible_remove_selection (AtkSelection *selection,
175 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
182 shell = GTK_MENU_SHELL (widget);
184 item = gtk_menu_shell_get_selected_item (shell);
185 if (item && gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)))
186 gtk_menu_shell_deselect (shell);
191 atk_selection_interface_init (AtkSelectionIface *iface)
193 iface->add_selection = gtk_menu_shell_accessible_add_selection;
194 iface->clear_selection = gtk_menu_shell_accessible_clear_selection;
195 iface->ref_selection = gtk_menu_shell_accessible_ref_selection;
196 iface->get_selection_count = gtk_menu_shell_accessible_get_selection_count;
197 iface->is_child_selected = gtk_menu_shell_accessible_is_child_selected;
198 iface->remove_selection = gtk_menu_shell_accessible_remove_selection;