1 /* GAIL - The GNOME Accessibility Enabling Library
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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 #include "gailpaned.h"
24 static void gail_paned_class_init (GailPanedClass *klass);
26 static void gail_paned_init (GailPaned *paned);
28 static void gail_paned_real_initialize (AtkObject *obj,
30 static void gail_paned_size_allocate_gtk (GtkWidget *widget,
31 GtkAllocation *allocation);
33 static AtkStateSet* gail_paned_ref_state_set (AtkObject *accessible);
35 static void atk_value_interface_init (AtkValueIface *iface);
36 static void gail_paned_get_current_value (AtkValue *obj,
38 static void gail_paned_get_maximum_value (AtkValue *obj,
40 static void gail_paned_get_minimum_value (AtkValue *obj,
42 static gboolean gail_paned_set_current_value (AtkValue *obj,
45 G_DEFINE_TYPE_WITH_CODE (GailPaned, gail_paned, GAIL_TYPE_CONTAINER,
46 G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
49 gail_paned_class_init (GailPanedClass *klass)
51 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
53 class->ref_state_set = gail_paned_ref_state_set;
54 class->initialize = gail_paned_real_initialize;
58 gail_paned_init (GailPaned *paned)
63 gail_paned_new (GtkWidget *widget)
66 AtkObject *accessible;
68 g_return_val_if_fail (GTK_IS_PANED (widget), NULL);
70 object = g_object_new (GAIL_TYPE_PANED, NULL);
72 accessible = ATK_OBJECT (object);
73 atk_object_initialize (accessible, widget);
79 gail_paned_ref_state_set (AtkObject *accessible)
81 AtkStateSet *state_set;
84 state_set = ATK_OBJECT_CLASS (gail_paned_parent_class)->ref_state_set (accessible);
85 widget = GTK_ACCESSIBLE (accessible)->widget;
90 if (GTK_IS_VPANED (widget))
91 atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
92 else if (GTK_IS_HPANED (widget))
93 atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
99 gail_paned_real_initialize (AtkObject *obj,
102 ATK_OBJECT_CLASS (gail_paned_parent_class)->initialize (obj, data);
104 g_signal_connect (data,
106 G_CALLBACK (gail_paned_size_allocate_gtk),
109 obj->role = ATK_ROLE_SPLIT_PANE;
113 gail_paned_size_allocate_gtk (GtkWidget *widget,
114 GtkAllocation *allocation)
116 AtkObject *obj = gtk_widget_get_accessible (widget);
118 g_object_notify (G_OBJECT (obj), "accessible-value");
123 atk_value_interface_init (AtkValueIface *iface)
125 iface->get_current_value = gail_paned_get_current_value;
126 iface->get_maximum_value = gail_paned_get_maximum_value;
127 iface->get_minimum_value = gail_paned_get_minimum_value;
128 iface->set_current_value = gail_paned_set_current_value;
132 gail_paned_get_current_value (AtkValue *obj,
138 widget = GTK_ACCESSIBLE (obj)->widget;
140 /* State is defunct */
143 current_value = gtk_paned_get_position (GTK_PANED (widget));
144 memset (value, 0, sizeof (GValue));
145 g_value_init (value, G_TYPE_INT);
146 g_value_set_int (value,current_value);
150 gail_paned_get_maximum_value (AtkValue *obj,
156 widget = GTK_ACCESSIBLE (obj)->widget;
158 /* State is defunct */
161 maximum_value = GTK_PANED (widget)->max_position;
162 memset (value, 0, sizeof (GValue));
163 g_value_init (value, G_TYPE_INT);
164 g_value_set_int (value, maximum_value);
168 gail_paned_get_minimum_value (AtkValue *obj,
174 widget = GTK_ACCESSIBLE (obj)->widget;
176 /* State is defunct */
179 minimum_value = GTK_PANED (widget)->min_position;
180 memset (value, 0, sizeof (GValue));
181 g_value_init (value, G_TYPE_INT);
182 g_value_set_int (value, minimum_value);
186 * Calling atk_value_set_current_value() is no guarantee that the value is
187 * acceptable; it is necessary to listen for accessible-value signals
188 * and check whether the current value has been changed or check what the
189 * maximum and minimum values are.
193 gail_paned_set_current_value (AtkValue *obj,
199 widget = GTK_ACCESSIBLE (obj)->widget;
201 /* State is defunct */
204 if (G_VALUE_HOLDS_INT (value))
206 new_value = g_value_get_int (value);
207 gtk_paned_set_position (GTK_PANED (widget), new_value);