| 1 |
/* GTK+ - accessibility implementations |
| 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 |
gtk_progress_bar_accessible_get_value_and_text (AtkValue *obj, |
| 105 |
gdouble *value, |
| 106 |
gchar **text) |
| 107 |
{ |
| 108 |
GtkWidget *widget; |
| 109 |
|
| 110 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 111 |
|
| 112 |
*value = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)); |
| 113 |
*text = NULL; |
| 114 |
} |
| 115 |
|
| 116 |
static AtkRange * |
| 117 |
gtk_progress_bar_accessible_get_range (AtkValue *obj) |
| 118 |
{ |
| 119 |
return atk_range_new (0.0, 1.0, NULL); |
| 120 |
} |
| 121 |
|
| 122 |
static void |
| 123 |
atk_value_interface_init (AtkValueIface *iface) |
| 124 |
{ |
| 125 |
iface->get_current_value = gtk_progress_bar_accessible_get_current_value; |
| 126 |
iface->get_maximum_value = gtk_progress_bar_accessible_get_maximum_value; |
| 127 |
iface->get_minimum_value = gtk_progress_bar_accessible_get_minimum_value; |
| 128 |
|
| 129 |
iface->get_value_and_text = gtk_progress_bar_accessible_get_value_and_text; |
| 130 |
iface->get_range = gtk_progress_bar_accessible_get_range; |
| 131 |
} |