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 "gtkpanedaccessible.h"
26 static void atk_value_interface_init (AtkValueIface *iface);
28 G_DEFINE_TYPE_WITH_CODE (GtkPanedAccessible, _gtk_paned_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
29 G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
32 gtk_paned_accessible_size_allocate_gtk (GtkWidget *widget,
33 GtkAllocation *allocation)
35 AtkObject *obj = gtk_widget_get_accessible (widget);
37 g_object_notify (G_OBJECT (obj), "accessible-value");
41 gtk_paned_accessible_initialize (AtkObject *obj,
44 ATK_OBJECT_CLASS (_gtk_paned_accessible_parent_class)->initialize (obj, data);
46 g_signal_connect (data, "size-allocate",
47 G_CALLBACK (gtk_paned_accessible_size_allocate_gtk), NULL);
49 obj->role = ATK_ROLE_SPLIT_PANE;
53 _gtk_paned_accessible_class_init (GtkPanedAccessibleClass *klass)
55 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
57 class->initialize = gtk_paned_accessible_initialize;
61 _gtk_paned_accessible_init (GtkPanedAccessible *paned)
66 gtk_paned_accessible_get_current_value (AtkValue *obj,
72 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
76 current_value = gtk_paned_get_position (GTK_PANED (widget));
77 memset (value, 0, sizeof (GValue));
78 g_value_init (value, G_TYPE_INT);
79 g_value_set_int (value,current_value);
83 gtk_paned_accessible_get_maximum_value (AtkValue *obj,
89 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
93 g_object_get (GTK_PANED (widget),
94 "max-position", &maximum_value,
96 memset (value, 0, sizeof (GValue));
97 g_value_init (value, G_TYPE_INT);
98 g_value_set_int (value, maximum_value);
102 gtk_paned_accessible_get_minimum_value (AtkValue *obj,
108 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
112 g_object_get (GTK_PANED (widget),
113 "min-position", &minimum_value,
115 memset (value, 0, sizeof (GValue));
116 g_value_init (value, G_TYPE_INT);
117 g_value_set_int (value, minimum_value);
120 /* Calling atk_value_set_current_value() is no guarantee that the value
121 * is acceptable; it is necessary to listen for accessible-value signals
122 * and check whether the current value has been changed or check what the
123 * maximum and minimum values are.
126 gtk_paned_accessible_set_current_value (AtkValue *obj,
132 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
136 if (G_VALUE_HOLDS_INT (value))
138 new_value = g_value_get_int (value);
139 gtk_paned_set_position (GTK_PANED (widget), new_value);
148 atk_value_interface_init (AtkValueIface *iface)
150 iface->get_current_value = gtk_paned_accessible_get_current_value;
151 iface->get_maximum_value = gtk_paned_accessible_get_maximum_value;
152 iface->get_minimum_value = gtk_paned_accessible_get_minimum_value;
153 iface->set_current_value = gtk_paned_accessible_set_current_value;