1 /* GTK+ - accessibility implementations
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, see <http://www.gnu.org/licenses/>.
22 #include "gtkstatusbaraccessible.h"
25 G_DEFINE_TYPE (GtkStatusbarAccessible, gtk_statusbar_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
28 text_changed (GtkStatusbar *statusbar,
34 g_object_notify (G_OBJECT (obj), "accessible-name");
35 g_signal_emit_by_name (obj, "visible-data-changed");
39 gtk_statusbar_accessible_initialize (AtkObject *obj,
42 GtkWidget *statusbar = data;
44 ATK_OBJECT_CLASS (gtk_statusbar_accessible_parent_class)->initialize (obj, data);
46 g_signal_connect_after (statusbar, "text-pushed",
47 G_CALLBACK (text_changed), obj);
48 g_signal_connect_after (statusbar, "text-popped",
49 G_CALLBACK (text_changed), obj);
51 obj->role = ATK_ROLE_STATUSBAR;
55 find_label_child (GtkContainer *container)
57 GList *children, *tmp_list;
60 children = gtk_container_get_children (container);
63 for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next)
65 if (GTK_IS_LABEL (tmp_list->data))
67 child = GTK_WIDGET (tmp_list->data);
70 else if (GTK_IS_CONTAINER (tmp_list->data))
72 child = find_label_child (GTK_CONTAINER (tmp_list->data));
77 g_list_free (children);
83 get_label_from_statusbar (GtkStatusbar *statusbar)
87 box = gtk_statusbar_get_message_area (statusbar);
89 return find_label_child (GTK_CONTAINER (box));
93 gtk_statusbar_accessible_get_name (AtkObject *obj)
99 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
103 name = ATK_OBJECT_CLASS (gtk_statusbar_accessible_parent_class)->get_name (obj);
107 label = get_label_from_statusbar (GTK_STATUSBAR (widget));
108 if (GTK_IS_LABEL (label))
109 return gtk_label_get_label (GTK_LABEL (label));
115 gtk_statusbar_accessible_get_n_children (AtkObject *obj)
121 gtk_statusbar_accessible_ref_child (AtkObject *obj,
128 gtk_statusbar_accessible_class_init (GtkStatusbarAccessibleClass *klass)
130 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
131 GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass;
133 class->get_name = gtk_statusbar_accessible_get_name;
134 class->get_n_children = gtk_statusbar_accessible_get_n_children;
135 class->ref_child = gtk_statusbar_accessible_ref_child;
136 class->initialize = gtk_statusbar_accessible_initialize;
138 * As we report the statusbar as having no children
139 * we are not interested in add and remove signals
141 container_class->add_gtk = NULL;
142 container_class->remove_gtk = NULL;
146 gtk_statusbar_accessible_init (GtkStatusbarAccessible *bar)