]> Pileus Git - ~andy/gtk/blob - modules/other/gail/gailprogressbar.c
Do not disable deprecation guards
[~andy/gtk] / modules / other / gail / gailprogressbar.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 "gailprogressbar.h"
27 #include "gailadjustment.h"
28
29 static void      gail_progress_bar_class_init        (GailProgressBarClass *klass);
30 static void      gail_progress_bar_init              (GailProgressBar *bar);
31 static void      gail_progress_bar_real_initialize   (AtkObject      *obj,
32                                                       gpointer       data);
33
34 static void      atk_value_interface_init            (AtkValueIface  *iface);
35
36
37 static void      gail_progress_bar_real_notify_gtk   (GObject        *obj,
38                                                       GParamSpec     *pspec);
39
40 static void      gail_progress_bar_get_current_value (AtkValue       *obj,
41                                                       GValue         *value);
42 static void      gail_progress_bar_get_maximum_value (AtkValue       *obj,
43                                                       GValue         *value);
44 static void      gail_progress_bar_get_minimum_value (AtkValue       *obj,
45                                                       GValue         *value);
46
47 G_DEFINE_TYPE_WITH_CODE (GailProgressBar, gail_progress_bar, GAIL_TYPE_WIDGET,
48                          G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
49
50 static void
51 gail_progress_bar_class_init            (GailProgressBarClass *klass)
52 {
53   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
54   GailWidgetClass *widget_class;
55
56   widget_class = (GailWidgetClass*)klass;
57
58   widget_class->notify_gtk = gail_progress_bar_real_notify_gtk;
59
60   class->initialize = gail_progress_bar_real_initialize;
61 }
62
63 static void
64 gail_progress_bar_init (GailProgressBar *bar)
65 {
66 }
67
68 static void
69 gail_progress_bar_real_initialize (AtkObject *obj,
70                                    gpointer  data)
71 {
72   ATK_OBJECT_CLASS (gail_progress_bar_parent_class)->initialize (obj, data);
73
74   obj->role = ATK_ROLE_PROGRESS_BAR;
75 }
76
77 static void
78 atk_value_interface_init (AtkValueIface *iface)
79 {
80   iface->get_current_value = gail_progress_bar_get_current_value;
81   iface->get_maximum_value = gail_progress_bar_get_maximum_value;
82   iface->get_minimum_value = gail_progress_bar_get_minimum_value;
83 }
84
85 static void
86 gail_progress_bar_get_current_value (AtkValue   *obj,
87                                      GValue     *value)
88 {
89   GtkWidget *widget;
90
91   g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
92
93   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
94
95   g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
96 }
97
98 static void
99 gail_progress_bar_get_maximum_value (AtkValue   *obj,
100                                      GValue     *value)
101 {
102   g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
103
104   g_value_set_double (value, 1.0);
105 }
106
107 static void      
108 gail_progress_bar_get_minimum_value (AtkValue    *obj,
109                                      GValue      *value)
110 {
111   g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
112
113   g_value_set_double (value, 0.0);
114 }
115
116 static void
117 gail_progress_bar_real_notify_gtk (GObject           *obj,
118                                    GParamSpec        *pspec)
119 {
120   GtkWidget *widget = GTK_WIDGET (obj);
121   GailProgressBar *progress_bar = GAIL_PROGRESS_BAR (gtk_widget_get_accessible (widget));
122
123   if (strcmp (pspec->name, "fraction") == 0)
124     g_object_notify (G_OBJECT (progress_bar), "accessible-value");
125   else
126     GAIL_WIDGET_CLASS (gail_progress_bar_parent_class)->notify_gtk (obj, pspec);
127 }