]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkprogressbaraccessible.c
Nuke GailAdjustment
[~andy/gtk] / gtk / a11y / gtkprogressbaraccessible.c
1 /* GAIL - The GNOME Accessibility Implementation Library
2  * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #include "config.h"
21
22 #include <string.h>
23
24 #include <gtk/gtk.h>
25
26 #include "gtkprogressbaraccessible.h"
27
28
29 static void atk_value_interface_init (AtkValueIface  *iface);
30
31 G_DEFINE_TYPE_WITH_CODE (GtkProgressBarAccessible, gtk_progress_bar_accessible, GAIL_TYPE_WIDGET,
32                          G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
33
34 static void
35 gtk_progress_bar_accessible_initialize (AtkObject *obj,
36                                         gpointer   data)
37 {
38   ATK_OBJECT_CLASS (gtk_progress_bar_accessible_parent_class)->initialize (obj, data);
39
40   obj->role = ATK_ROLE_PROGRESS_BAR;
41 }
42
43 static void
44 gtk_progress_bar_accessible_notify_gtk (GObject    *obj,
45                                         GParamSpec *pspec)
46 {
47   GtkWidget *widget = GTK_WIDGET (obj);
48   AtkObject *accessible;
49
50   accessible = gtk_widget_get_accessible (widget);
51
52   if (strcmp (pspec->name, "fraction") == 0)
53     g_object_notify (G_OBJECT (accessible), "accessible-value");
54   else
55     GAIL_WIDGET_CLASS (gtk_progress_bar_accessible_parent_class)->notify_gtk (obj, pspec);
56 }
57 static void
58 gtk_progress_bar_accessible_class_init (GtkProgressBarAccessibleClass *klass)
59 {
60   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
61   GailWidgetClass *widget_class;
62
63   widget_class = (GailWidgetClass*)klass;
64
65   widget_class->notify_gtk = gtk_progress_bar_accessible_notify_gtk;
66
67   class->initialize = gtk_progress_bar_accessible_initialize;
68 }
69
70 static void
71 gtk_progress_bar_accessible_init (GtkProgressBarAccessible *bar)
72 {
73 }
74
75 static void
76 gtk_progress_bar_accessible_get_current_value (AtkValue *obj,
77                                                GValue   *value)
78 {
79   GtkWidget *widget;
80
81   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
82
83   memset (value, 0, sizeof (GValue));
84   g_value_init (value, G_TYPE_DOUBLE);
85   g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
86 }
87
88 static void
89 gtk_progress_bar_accessible_get_maximum_value (AtkValue *obj,
90                                                GValue   *value)
91 {
92   memset (value, 0, sizeof (GValue));
93   g_value_init (value, G_TYPE_DOUBLE);
94   g_value_set_double (value, 1.0);
95 }
96
97 static void
98 gtk_progress_bar_accessible_get_minimum_value (AtkValue *obj,
99                                                GValue   *value)
100 {
101   memset (value, 0, sizeof (GValue));
102   g_value_init (value, G_TYPE_DOUBLE);
103   g_value_set_double (value, 0.0);
104 }
105
106 static void
107 atk_value_interface_init (AtkValueIface *iface)
108 {
109   iface->get_current_value = gtk_progress_bar_accessible_get_current_value;
110   iface->get_maximum_value = gtk_progress_bar_accessible_get_maximum_value;
111   iface->get_minimum_value = gtk_progress_bar_accessible_get_minimum_value;
112 }