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, see <http://www.gnu.org/licenses/>.
21 #include "gtkscalebuttonaccessible.h"
26 static void atk_action_interface_init (AtkActionIface *iface);
27 static void atk_value_interface_init (AtkValueIface *iface);
29 G_DEFINE_TYPE_WITH_CODE (GtkScaleButtonAccessible, _gtk_scale_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE,
30 G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
31 G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init));
34 gtk_scale_button_accessible_value_changed (GtkAdjustment *adjustment,
37 g_object_notify (G_OBJECT (data), "accessible-value");
41 gtk_scale_button_accessible_initialize (AtkObject *obj,
44 GtkAdjustment *adjustment;
46 ATK_OBJECT_CLASS (_gtk_scale_button_accessible_parent_class)->initialize (obj, data);
48 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (data));
50 g_signal_connect (adjustment,
52 G_CALLBACK (gtk_scale_button_accessible_value_changed),
55 obj->role = ATK_ROLE_SLIDER;
59 gtk_scale_button_accessible_notify_gtk (GObject *obj,
62 GtkScaleButton *scale_button;
63 GtkScaleButtonAccessible *accessible;
65 scale_button = GTK_SCALE_BUTTON (obj);
66 accessible = GTK_SCALE_BUTTON_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (scale_button)));
68 if (strcmp (pspec->name, "adjustment") == 0)
70 GtkAdjustment* adjustment;
72 adjustment = gtk_scale_button_get_adjustment (scale_button);
73 g_signal_connect (adjustment,
75 G_CALLBACK (gtk_scale_button_accessible_value_changed),
80 GTK_WIDGET_ACCESSIBLE_CLASS (_gtk_scale_button_accessible_parent_class)->notify_gtk (obj, pspec);
85 _gtk_scale_button_accessible_class_init (GtkScaleButtonAccessibleClass *klass)
87 AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
88 GtkWidgetAccessibleClass *widget_class = GTK_WIDGET_ACCESSIBLE_CLASS (klass);
90 atk_object_class->initialize = gtk_scale_button_accessible_initialize;
92 widget_class->notify_gtk = gtk_scale_button_accessible_notify_gtk;
96 _gtk_scale_button_accessible_init (GtkScaleButtonAccessible *button)
101 gtk_scale_button_accessible_do_action (AtkAction *action,
106 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
110 if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
116 g_signal_emit_by_name (widget, "popup");
119 g_signal_emit_by_name (widget, "popdown");
127 gtk_scale_button_accessible_get_n_actions (AtkAction *action)
133 gtk_scale_button_accessible_get_description (AtkAction *action,
140 gtk_scale_button_accessible_action_get_name (AtkAction *action,
155 atk_action_interface_init (AtkActionIface *iface)
157 iface->do_action = gtk_scale_button_accessible_do_action;
158 iface->get_n_actions = gtk_scale_button_accessible_get_n_actions;
159 iface->get_description = gtk_scale_button_accessible_get_description;
160 iface->get_name = gtk_scale_button_accessible_action_get_name;
164 gtk_scale_button_accessible_get_current_value (AtkValue *obj,
168 GtkAdjustment *adjustment;
170 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
171 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
172 if (adjustment == NULL)
175 memset (value, 0, sizeof (GValue));
176 g_value_init (value, G_TYPE_DOUBLE);
177 g_value_set_double (value, gtk_adjustment_get_value (adjustment));
181 gtk_scale_button_accessible_get_maximum_value (AtkValue *obj,
185 GtkAdjustment *adjustment;
187 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
188 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
189 if (adjustment == NULL)
192 memset (value, 0, sizeof (GValue));
193 g_value_init (value, G_TYPE_DOUBLE);
194 g_value_set_double (value, gtk_adjustment_get_upper (adjustment));
198 gtk_scale_button_accessible_get_minimum_value (AtkValue *obj,
202 GtkAdjustment *adjustment;
204 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
205 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
206 if (adjustment == NULL)
209 memset (value, 0, sizeof (GValue));
210 g_value_init (value, G_TYPE_DOUBLE);
211 g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
215 gtk_scale_button_accessible_get_minimum_increment (AtkValue *obj,
219 GtkAdjustment *adjustment;
221 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
222 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
223 if (adjustment == NULL)
226 memset (value, 0, sizeof (GValue));
227 g_value_init (value, G_TYPE_DOUBLE);
228 g_value_set_double (value, gtk_adjustment_get_minimum_increment (adjustment));
232 gtk_scale_button_accessible_set_current_value (AtkValue *obj,
236 GtkAdjustment *adjustment;
238 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
239 adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
240 if (adjustment == NULL)
243 gtk_adjustment_set_value (adjustment, g_value_get_double (value));
249 atk_value_interface_init (AtkValueIface *iface)
251 iface->get_current_value = gtk_scale_button_accessible_get_current_value;
252 iface->get_maximum_value = gtk_scale_button_accessible_get_maximum_value;
253 iface->get_minimum_value = gtk_scale_button_accessible_get_minimum_value;
254 iface->get_minimum_increment = gtk_scale_button_accessible_get_minimum_increment;
255 iface->set_current_value = gtk_scale_button_accessible_set_current_value;