2
* Copyright (C) 2013 Red Hat, 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/>.
18
#include "egg-list-box.h"
19
#include "egg-list-box-accessible.h"
21
static void atk_selection_interface_init (AtkSelectionIface *iface);
23
G_DEFINE_TYPE_WITH_CODE (EggListBoxAccessible, egg_list_box_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
24
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
27
egg_list_box_accessible_init (EggListBoxAccessible *accessible)
32
egg_list_box_accessible_initialize (AtkObject *obj,
35
ATK_OBJECT_CLASS (egg_list_box_accessible_parent_class)->initialize (obj, data);
37
obj->role = ATK_ROLE_LIST_BOX;
41
egg_list_box_accessible_ref_state_set (AtkObject *obj)
43
AtkStateSet *state_set;
46
state_set = ATK_OBJECT_CLASS (egg_list_box_accessible_parent_class)->ref_state_set (obj);
47
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
50
atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
56
egg_list_box_accessible_class_init (EggListBoxAccessibleClass *klass)
58
AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
60
object_class->initialize = egg_list_box_accessible_initialize;
61
object_class->ref_state_set = egg_list_box_accessible_ref_state_set;
65
egg_list_box_accessible_add_selection (AtkSelection *selection,
72
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
76
children = gtk_container_get_children (GTK_CONTAINER (box));
77
child = g_list_nth_data (children, idx);
78
g_list_free (children);
81
egg_list_box_select_child (EGG_LIST_BOX (box), child);
88
egg_list_box_accessible_clear_selection (AtkSelection *selection)
92
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
96
egg_list_box_select_child (EGG_LIST_BOX (box), NULL);
101
egg_list_box_accessible_ref_selection (AtkSelection *selection,
106
AtkObject *accessible;
111
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
115
widget = egg_list_box_get_selected_child (EGG_LIST_BOX (box));
119
accessible = gtk_widget_get_accessible (widget);
120
g_object_ref (accessible);
125
egg_list_box_accessible_get_selection_count (AtkSelection *selection)
130
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
134
widget = egg_list_box_get_selected_child (EGG_LIST_BOX (box));
142
egg_list_box_accessible_is_child_selected (AtkSelection *selection,
150
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
154
widget = egg_list_box_get_selected_child (EGG_LIST_BOX (box));
158
children = gtk_container_get_children (GTK_CONTAINER (box));
159
child = g_list_nth_data (children, idx);
160
g_list_free (children);
161
return child == widget;
164
static void atk_selection_interface_init (AtkSelectionIface *iface)
166
iface->add_selection = egg_list_box_accessible_add_selection;
167
iface->clear_selection = egg_list_box_accessible_clear_selection;
168
iface->ref_selection = egg_list_box_accessible_ref_selection;
169
iface->get_selection_count = egg_list_box_accessible_get_selection_count;
170
iface->is_child_selected = egg_list_box_accessible_is_child_selected;
174
_egg_list_box_accessible_update_selected (EggListBox *box,
177
AtkObject *accessible;
178
accessible = gtk_widget_get_accessible (GTK_WIDGET (box));
179
g_signal_emit_by_name (accessible, "selection-changed");
183
_egg_list_box_accessible_update_cursor (EggListBox *box,
186
AtkObject *accessible;
187
AtkObject *descendant;
188
accessible = gtk_widget_get_accessible (GTK_WIDGET (box));
189
descendant = child ? gtk_widget_get_accessible (child) : NULL;
190
g_signal_emit_by_name (accessible, "active-descendant-changed", descendant);