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.
24 #include "gailpaned.h"
26 static void gail_paned_class_init (GailPanedClass *klass);
28 static void gail_paned_init (GailPaned *paned);
30 static void gail_paned_real_initialize (AtkObject *obj,
32 static void gail_paned_size_allocate_gtk (GtkWidget *widget,
33 GtkAllocation *allocation);
35 static AtkStateSet* gail_paned_ref_state_set (AtkObject *accessible);
37 static void atk_value_interface_init (AtkValueIface *iface);
38 static void gail_paned_get_current_value (AtkValue *obj,
40 static void gail_paned_get_maximum_value (AtkValue *obj,
42 static void gail_paned_get_minimum_value (AtkValue *obj,
44 static gboolean gail_paned_set_current_value (AtkValue *obj,
47 G_DEFINE_TYPE_WITH_CODE (GailPaned, gail_paned, GAIL_TYPE_CONTAINER,
48 G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
51 gail_paned_class_init (GailPanedClass *klass)
53 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
55 class->ref_state_set = gail_paned_ref_state_set;
56 class->initialize = gail_paned_real_initialize;
60 gail_paned_init (GailPaned *paned)
65 gail_paned_ref_state_set (AtkObject *accessible)
67 AtkStateSet *state_set;
70 state_set = ATK_OBJECT_CLASS (gail_paned_parent_class)->ref_state_set (accessible);
71 widget = GTK_ACCESSIBLE (accessible)->widget;
76 if (GTK_IS_VPANED (widget))
77 atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
78 else if (GTK_IS_HPANED (widget))
79 atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
85 gail_paned_real_initialize (AtkObject *obj,
88 ATK_OBJECT_CLASS (gail_paned_parent_class)->initialize (obj, data);
90 g_signal_connect (data,
92 G_CALLBACK (gail_paned_size_allocate_gtk),
95 obj->role = ATK_ROLE_SPLIT_PANE;
99 gail_paned_size_allocate_gtk (GtkWidget *widget,
100 GtkAllocation *allocation)
102 AtkObject *obj = gtk_widget_get_accessible (widget);
104 g_object_notify (G_OBJECT (obj), "accessible-value");
109 atk_value_interface_init (AtkValueIface *iface)
111 iface->get_current_value = gail_paned_get_current_value;
112 iface->get_maximum_value = gail_paned_get_maximum_value;
113 iface->get_minimum_value = gail_paned_get_minimum_value;
114 iface->set_current_value = gail_paned_set_current_value;
118 gail_paned_get_current_value (AtkValue *obj,
124 widget = GTK_ACCESSIBLE (obj)->widget;
126 /* State is defunct */
129 current_value = gtk_paned_get_position (GTK_PANED (widget));
130 memset (value, 0, sizeof (GValue));
131 g_value_init (value, G_TYPE_INT);
132 g_value_set_int (value,current_value);
136 gail_paned_get_maximum_value (AtkValue *obj,
142 widget = GTK_ACCESSIBLE (obj)->widget;
144 /* State is defunct */
147 maximum_value = GTK_PANED (widget)->max_position;
148 memset (value, 0, sizeof (GValue));
149 g_value_init (value, G_TYPE_INT);
150 g_value_set_int (value, maximum_value);
154 gail_paned_get_minimum_value (AtkValue *obj,
160 widget = GTK_ACCESSIBLE (obj)->widget;
162 /* State is defunct */
165 minimum_value = GTK_PANED (widget)->min_position;
166 memset (value, 0, sizeof (GValue));
167 g_value_init (value, G_TYPE_INT);
168 g_value_set_int (value, minimum_value);
172 * Calling atk_value_set_current_value() is no guarantee that the value is
173 * acceptable; it is necessary to listen for accessible-value signals
174 * and check whether the current value has been changed or check what the
175 * maximum and minimum values are.
179 gail_paned_set_current_value (AtkValue *obj,
185 widget = GTK_ACCESSIBLE (obj)->widget;
187 /* State is defunct */
190 if (G_VALUE_HOLDS_INT (value))
192 new_value = g_value_get_int (value);
193 gtk_paned_set_position (GTK_PANED (widget), new_value);