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