Debian Codegraph @

gtk/a11y/gtklistboxrowaccessible.c

raw
1 /*
2 * Copyright (C) 2013 Red Hat, Inc.
3 *
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.
8 *
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.
13 *
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/>.
16 */
17
18 #include "config.h"
19
20 #include "gtklistboxrowaccessible.h"
21
22 #include "gtk/gtklistbox.h"
23
24
25 G_DEFINE_TYPE (GtkListBoxRowAccessible, gtk_list_box_row_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
26
27 static void
28 gtk_list_box_row_accessible_init (GtkListBoxRowAccessible *accessible)
29 {
30 }
31
32 static void
33 gtk_list_box_row_accessible_initialize (AtkObject *obj,
34 gpointer data)
35 {
36 ATK_OBJECT_CLASS (gtk_list_box_row_accessible_parent_class)->initialize (obj, data);
37
38 obj->role = ATK_ROLE_LIST_ITEM;
39 }
40
41 static AtkStateSet*
42 gtk_list_box_row_accessible_ref_state_set (AtkObject *obj)
43 {
44 AtkStateSet *state_set;
45 GtkWidget *widget, *parent;
46
47 state_set = ATK_OBJECT_CLASS (gtk_list_box_row_accessible_parent_class)->ref_state_set (obj);
48
49 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
50 if (widget != NULL)
51 {
52 parent = gtk_widget_get_parent (widget);
53 if (parent != NULL &&
54 GTK_IS_LIST_BOX (parent) &&
55 gtk_list_box_get_selection_mode (GTK_LIST_BOX (parent)) != GTK_SELECTION_NONE)
56 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
57
58 if (gtk_list_box_row_is_selected (GTK_LIST_BOX_ROW (widget)))
59 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
60 }
61
62 return state_set;
63 }
64
65 static void
66 gtk_list_box_row_accessible_class_init (GtkListBoxRowAccessibleClass *klass)
67 {
68 AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
69
70 object_class->initialize = gtk_list_box_row_accessible_initialize;
71 object_class->ref_state_set = gtk_list_box_row_accessible_ref_state_set;
72 }