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);
34 static void atk_value_interface_init (AtkValueIface *iface);
35 static void gail_paned_get_current_value (AtkValue *obj,
37 static void gail_paned_get_maximum_value (AtkValue *obj,
39 static void gail_paned_get_minimum_value (AtkValue *obj,
41 static gboolean gail_paned_set_current_value (AtkValue *obj,
44 G_DEFINE_TYPE_WITH_CODE (GailPaned, gail_paned, GAIL_TYPE_CONTAINER,
45 G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
48 gail_paned_class_init (GailPanedClass *klass)
50 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
52 class->initialize = gail_paned_real_initialize;
56 gail_paned_init (GailPaned *paned)
61 gail_paned_real_initialize (AtkObject *obj,
64 ATK_OBJECT_CLASS (gail_paned_parent_class)->initialize (obj, data);
66 g_signal_connect (data,
68 G_CALLBACK (gail_paned_size_allocate_gtk),
71 obj->role = ATK_ROLE_SPLIT_PANE;
75 gail_paned_size_allocate_gtk (GtkWidget *widget,
76 GtkAllocation *allocation)
78 AtkObject *obj = gtk_widget_get_accessible (widget);
80 g_object_notify (G_OBJECT (obj), "accessible-value");
85 atk_value_interface_init (AtkValueIface *iface)
87 iface->get_current_value = gail_paned_get_current_value;
88 iface->get_maximum_value = gail_paned_get_maximum_value;
89 iface->get_minimum_value = gail_paned_get_minimum_value;
90 iface->set_current_value = gail_paned_set_current_value;
94 gail_paned_get_current_value (AtkValue *obj,
100 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
102 /* State is defunct */
105 current_value = gtk_paned_get_position (GTK_PANED (widget));
106 memset (value, 0, sizeof (GValue));
107 g_value_init (value, G_TYPE_INT);
108 g_value_set_int (value,current_value);
112 gail_paned_get_maximum_value (AtkValue *obj,
118 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
120 /* State is defunct */
123 g_object_get (GTK_PANED (widget),
124 "max-position", &maximum_value,
126 memset (value, 0, sizeof (GValue));
127 g_value_init (value, G_TYPE_INT);
128 g_value_set_int (value, maximum_value);
132 gail_paned_get_minimum_value (AtkValue *obj,
138 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
140 /* State is defunct */
143 g_object_get (GTK_PANED (widget),
144 "min-position", &minimum_value,
146 memset (value, 0, sizeof (GValue));
147 g_value_init (value, G_TYPE_INT);
148 g_value_set_int (value, minimum_value);
152 * Calling atk_value_set_current_value() is no guarantee that the value is
153 * acceptable; it is necessary to listen for accessible-value signals
154 * and check whether the current value has been changed or check what the
155 * maximum and minimum values are.
159 gail_paned_set_current_value (AtkValue *obj,
165 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
167 /* State is defunct */
170 if (G_VALUE_HOLDS_INT (value))
172 new_value = g_value_get_int (value);
173 gtk_paned_set_position (GTK_PANED (widget), new_value);