Debian Codegraph @

gtk/a11y/gtkheaderbaraccessible.c

raw
1 /* GTK+ - accessibility implementations
2 * Copyright 2001, 2002, 2003 Sun Microsystems 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 "gtkheaderbaraccessible.h"
21
22 #include "gtkcontainerprivate.h"
23
24 G_DEFINE_TYPE (GtkHeaderBarAccessible, gtk_header_bar_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
25
26 static void
27 count_widget (GtkWidget *widget,
28 gint *count)
29 {
30 (*count)++;
31 }
32
33 static gint
34 gtk_header_bar_accessible_get_n_children (AtkObject* obj)
35 {
36 GtkWidget *widget;
37 gint count = 0;
38
39 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
40 if (widget == NULL)
41 return 0;
42
43 gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) count_widget, &count);
44 return count;
45 }
46
47 static AtkObject *
48 gtk_header_bar_accessible_ref_child (AtkObject *obj,
49 gint i)
50 {
51 GList *children, *tmp_list;
52 AtkObject *accessible;
53 GtkWidget *widget;
54
55 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
56 if (widget == NULL)
57 return NULL;
58
59 children = gtk_container_get_all_children (GTK_CONTAINER (widget));
60 tmp_list = g_list_nth (children, i);
61 if (!tmp_list)
62 {
63 g_list_free (children);
64 return NULL;
65 }
66 accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
67
68 g_list_free (children);
69 g_object_ref (accessible);
70
71 return accessible;
72 }
73
74 static void
75 gtk_header_bar_accessible_class_init (GtkHeaderBarAccessibleClass *klass)
76 {
77 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
78
79 class->get_n_children = gtk_header_bar_accessible_get_n_children;
80 class->ref_child = gtk_header_bar_accessible_ref_child;
81 }
82
83 static void
84 gtk_header_bar_accessible_init (GtkHeaderBarAccessible *header_bar)
85 {
86 }
87