]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkprogressbaraccessible.c
Change FSF Address
[~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, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "config.h"
19
20 #include <string.h>
21
22 #include <gtk/gtk.h>
23
24 #include "gtkprogressbaraccessible.h"
25
26
27 static void atk_value_interface_init (AtkValueIface  *iface);
28
29 G_DEFINE_TYPE_WITH_CODE (GtkProgressBarAccessible, _gtk_progress_bar_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
30                          G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
31
32 static void
33 gtk_progress_bar_accessible_initialize (AtkObject *obj,
34                                         gpointer   data)
35 {
36   ATK_OBJECT_CLASS (_gtk_progress_bar_accessible_parent_class)->initialize (obj, data);
37
38   obj->role = ATK_ROLE_PROGRESS_BAR;
39 }
40
41 static void
42 gtk_progress_bar_accessible_notify_gtk (GObject    *obj,
43                                         GParamSpec *pspec)
44 {
45   GtkWidget *widget = GTK_WIDGET (obj);
46   AtkObject *accessible;
47
48   accessible = gtk_widget_get_accessible (widget);
49
50   if (strcmp (pspec->name, "fraction") == 0)
51     g_object_notify (G_OBJECT (accessible), "accessible-value");
52   else
53     GTK_WIDGET_ACCESSIBLE_CLASS (_gtk_progress_bar_accessible_parent_class)->notify_gtk (obj, pspec);
54 }
55
56 static void
57 _gtk_progress_bar_accessible_class_init (GtkProgressBarAccessibleClass *klass)
58 {
59   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
60   GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
61
62   widget_class->notify_gtk = gtk_progress_bar_accessible_notify_gtk;
63
64   class->initialize = gtk_progress_bar_accessible_initialize;
65 }
66
67 static void
68 _gtk_progress_bar_accessible_init (GtkProgressBarAccessible *bar)
69 {
70 }
71
72 static void
73 gtk_progress_bar_accessible_get_current_value (AtkValue *obj,
74                                                GValue   *value)
75 {
76   GtkWidget *widget;
77
78   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
79
80   memset (value, 0, sizeof (GValue));
81   g_value_init (value, G_TYPE_DOUBLE);
82   g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
83 }
84
85 static void
86 gtk_progress_bar_accessible_get_maximum_value (AtkValue *obj,
87                                                GValue   *value)
88 {
89   memset (value, 0, sizeof (GValue));
90   g_value_init (value, G_TYPE_DOUBLE);
91   g_value_set_double (value, 1.0);
92 }
93
94 static void
95 gtk_progress_bar_accessible_get_minimum_value (AtkValue *obj,
96                                                GValue   *value)
97 {
98   memset (value, 0, sizeof (GValue));
99   g_value_init (value, G_TYPE_DOUBLE);
100   g_value_set_double (value, 0.0);
101 }
102
103 static void
104 atk_value_interface_init (AtkValueIface *iface)
105 {
106   iface->get_current_value = gtk_progress_bar_accessible_get_current_value;
107   iface->get_maximum_value = gtk_progress_bar_accessible_get_maximum_value;
108   iface->get_minimum_value = gtk_progress_bar_accessible_get_minimum_value;
109 }