]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkprogressbaraccessible.c
Merge bgo593793-filechooser-recent-folders-master branch.
[~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, GTK_TYPE_WIDGET_ACCESSIBLE,
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     GTK_WIDGET_ACCESSIBLE_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   GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
62
63   widget_class->notify_gtk = gtk_progress_bar_accessible_notify_gtk;
64
65   class->initialize = gtk_progress_bar_accessible_initialize;
66 }
67
68 static void
69 gtk_progress_bar_accessible_init (GtkProgressBarAccessible *bar)
70 {
71 }
72
73 static void
74 gtk_progress_bar_accessible_get_current_value (AtkValue *obj,
75                                                GValue   *value)
76 {
77   GtkWidget *widget;
78
79   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
80
81   memset (value, 0, sizeof (GValue));
82   g_value_init (value, G_TYPE_DOUBLE);
83   g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
84 }
85
86 static void
87 gtk_progress_bar_accessible_get_maximum_value (AtkValue *obj,
88                                                GValue   *value)
89 {
90   memset (value, 0, sizeof (GValue));
91   g_value_init (value, G_TYPE_DOUBLE);
92   g_value_set_double (value, 1.0);
93 }
94
95 static void
96 gtk_progress_bar_accessible_get_minimum_value (AtkValue *obj,
97                                                GValue   *value)
98 {
99   memset (value, 0, sizeof (GValue));
100   g_value_init (value, G_TYPE_DOUBLE);
101   g_value_set_double (value, 0.0);
102 }
103
104 static void
105 atk_value_interface_init (AtkValueIface *iface)
106 {
107   iface->get_current_value = gtk_progress_bar_accessible_get_current_value;
108   iface->get_maximum_value = gtk_progress_bar_accessible_get_maximum_value;
109   iface->get_minimum_value = gtk_progress_bar_accessible_get_minimum_value;
110 }