1 /* GAIL - The GNOME Accessibility Implementation Library
2 * Copyright 2008 Jan Arne Petersen
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.
23 #include "gtkscalebuttonaccessible.h"
28 static void atk_action_interface_init (AtkActionIface *iface);
29 static void atk_value_interface_init (AtkValueIface *iface);
31 G_DEFINE_TYPE_WITH_CODE (GtkScaleButtonAccessible, _gtk_scale_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE,
32 G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
33 G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init));
36 gtk_scale_button_accessible_value_changed (GtkAdjustment *adjustment,
39 g_object_notify (G_OBJECT (data), "accessible-value");
43 gtk_scale_button_accessible_initialize (AtkObject *obj,
46 GtkAdjustment *adjustment;
48 ATK_OBJECT_CLASS (_gtk_scale_button_accessible_parent_class)->initialize (obj, data);
50 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (data));
52 g_signal_connect (adjustment,
54 G_CALLBACK (gtk_scale_button_accessible_value_changed),
57 obj->role = ATK_ROLE_SLIDER;
61 gtk_scale_button_accessible_notify_gtk (GObject *obj,
64 GtkScaleButton *scale_button;
65 GtkScaleButtonAccessible *accessible;
67 scale_button = GTK_SCALE_BUTTON (obj);
68 accessible = GTK_SCALE_BUTTON_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (scale_button)));
70 if (strcmp (pspec->name, "adjustment") == 0)
72 GtkAdjustment* adjustment;
74 adjustment = gtk_scale_button_get_adjustment (scale_button);
75 g_signal_connect (adjustment,
77 G_CALLBACK (gtk_scale_button_accessible_value_changed),
82 GTK_WIDGET_ACCESSIBLE_CLASS (_gtk_scale_button_accessible_parent_class)->notify_gtk (obj, pspec);
87 _gtk_scale_button_accessible_class_init (GtkScaleButtonAccessibleClass *klass)
89 AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
90 GtkWidgetAccessibleClass *widget_class = GTK_WIDGET_ACCESSIBLE_CLASS (klass);
92 atk_object_class->initialize = gtk_scale_button_accessible_initialize;
94 widget_class->notify_gtk = gtk_scale_button_accessible_notify_gtk;
98 _gtk_scale_button_accessible_init (GtkScaleButtonAccessible *button)
103 gtk_scale_button_accessible_do_action (AtkAction *action,
108 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
112 if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
118 g_signal_emit_by_name (widget, "popup");
121 g_signal_emit_by_name (widget, "popdown");
129 gtk_scale_button_accessible_get_n_actions (AtkAction *action)
135 gtk_scale_button_accessible_get_description (AtkAction *action,
142 gtk_scale_button_accessible_action_get_name (AtkAction *action,
157 atk_action_interface_init (AtkActionIface *iface)
159 iface->do_action = gtk_scale_button_accessible_do_action;
160 iface->get_n_actions = gtk_scale_button_accessible_get_n_actions;
161 iface->get_description = gtk_scale_button_accessible_get_description;
162 iface->get_name = gtk_scale_button_accessible_action_get_name;
166 gtk_scale_button_accessible_get_current_value (AtkValue *obj,
170 GtkAdjustment *adjustment;
172 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
173 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
174 if (adjustment == NULL)
177 memset (value, 0, sizeof (GValue));
178 g_value_init (value, G_TYPE_DOUBLE);
179 g_value_set_double (value, gtk_adjustment_get_value (adjustment));
183 gtk_scale_button_accessible_get_maximum_value (AtkValue *obj,
187 GtkAdjustment *adjustment;
189 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
190 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
191 if (adjustment == NULL)
194 memset (value, 0, sizeof (GValue));
195 g_value_init (value, G_TYPE_DOUBLE);
196 g_value_set_double (value, gtk_adjustment_get_upper (adjustment));
200 gtk_scale_button_accessible_get_minimum_value (AtkValue *obj,
204 GtkAdjustment *adjustment;
206 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
207 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
208 if (adjustment == NULL)
211 memset (value, 0, sizeof (GValue));
212 g_value_init (value, G_TYPE_DOUBLE);
213 g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
217 gtk_scale_button_accessible_get_minimum_increment (AtkValue *obj,
221 GtkAdjustment *adjustment;
223 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
224 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
225 if (adjustment == NULL)
228 memset (value, 0, sizeof (GValue));
229 g_value_init (value, G_TYPE_DOUBLE);
230 g_value_set_double (value, gtk_adjustment_get_minimum_increment (adjustment));
234 gtk_scale_button_accessible_set_current_value (AtkValue *obj,
238 GtkAdjustment *adjustment;
240 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
241 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
242 if (adjustment == NULL)
245 gtk_adjustment_set_value (adjustment, g_value_get_double (value));
251 atk_value_interface_init (AtkValueIface *iface)
253 iface->get_current_value = gtk_scale_button_accessible_get_current_value;
254 iface->get_maximum_value = gtk_scale_button_accessible_get_maximum_value;
255 iface->get_minimum_value = gtk_scale_button_accessible_get_minimum_value;
256 iface->get_minimum_increment = gtk_scale_button_accessible_get_minimum_increment;
257 iface->set_current_value = gtk_scale_button_accessible_set_current_value;