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 "gtkpanedaccessible.h"
24 static void atk_value_interface_init (AtkValueIface *iface);
26 G_DEFINE_TYPE_WITH_CODE (GtkPanedAccessible, gtk_paned_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
27 G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
30 gtk_paned_accessible_size_allocate_gtk (GtkWidget *widget,
31 GtkAllocation *allocation)
33 AtkObject *obj = gtk_widget_get_accessible (widget);
35 g_object_notify (G_OBJECT (obj), "accessible-value");
39 gtk_paned_accessible_initialize (AtkObject *obj,
42 ATK_OBJECT_CLASS (gtk_paned_accessible_parent_class)->initialize (obj, data);
44 g_signal_connect (data, "size-allocate",
45 G_CALLBACK (gtk_paned_accessible_size_allocate_gtk), NULL);
47 obj->role = ATK_ROLE_SPLIT_PANE;
51 gtk_paned_accessible_class_init (GtkPanedAccessibleClass *klass)
53 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
55 class->initialize = gtk_paned_accessible_initialize;
59 gtk_paned_accessible_init (GtkPanedAccessible *paned)
64 gtk_paned_accessible_get_current_value (AtkValue *obj,
70 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
74 current_value = gtk_paned_get_position (GTK_PANED (widget));
75 memset (value, 0, sizeof (GValue));
76 g_value_init (value, G_TYPE_INT);
77 g_value_set_int (value,current_value);
81 gtk_paned_accessible_get_maximum_value (AtkValue *obj,
87 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
91 g_object_get (GTK_PANED (widget),
92 "max-position", &maximum_value,
94 memset (value, 0, sizeof (GValue));
95 g_value_init (value, G_TYPE_INT);
96 g_value_set_int (value, maximum_value);
100 gtk_paned_accessible_get_minimum_value (AtkValue *obj,
106 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
110 g_object_get (GTK_PANED (widget),
111 "min-position", &minimum_value,
113 memset (value, 0, sizeof (GValue));
114 g_value_init (value, G_TYPE_INT);
115 g_value_set_int (value, minimum_value);
118 /* Calling atk_value_set_current_value() is no guarantee that the value
119 * is acceptable; it is necessary to listen for accessible-value signals
120 * and check whether the current value has been changed or check what the
121 * maximum and minimum values are.
124 gtk_paned_accessible_set_current_value (AtkValue *obj,
130 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
134 if (G_VALUE_HOLDS_INT (value))
136 new_value = g_value_get_int (value);
137 gtk_paned_set_position (GTK_PANED (widget), new_value);
146 atk_value_interface_init (AtkValueIface *iface)
148 iface->get_current_value = gtk_paned_accessible_get_current_value;
149 iface->get_maximum_value = gtk_paned_accessible_get_maximum_value;
150 iface->get_minimum_value = gtk_paned_accessible_get_minimum_value;
151 iface->set_current_value = gtk_paned_accessible_set_current_value;