| 1 |
/* GAIL - The GNOME Accessibility Implementation Library |
| 2 |
* Copyright 2001, 2002, 2003 Sun Microsystems Inc. |
| 3 |
* Copyright 2013 SUSE LLC. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "config.h" |
| 20 |
|
| 21 |
#include <string.h> |
| 22 |
#include <gtk/gtk.h> |
| 23 |
#include "gtklevelbaraccessible.h" |
| 24 |
|
| 25 |
|
| 26 |
static void atk_value_interface_init (AtkValueIface *iface); |
| 27 |
|
| 28 |
G_DEFINE_TYPE_WITH_CODE (GtkLevelBarAccessible, gtk_level_bar_accessible, GTK_TYPE_WIDGET_ACCESSIBLE, |
| 29 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init)) |
| 30 |
|
| 31 |
static void |
| 32 |
gtk_level_bar_accessible_initialize (AtkObject *obj, |
| 33 |
gpointer data) |
| 34 |
{ |
| 35 |
ATK_OBJECT_CLASS (gtk_level_bar_accessible_parent_class)->initialize (obj, data); |
| 36 |
|
| 37 |
obj->role = ATK_ROLE_LEVEL_BAR; |
| 38 |
} |
| 39 |
|
| 40 |
static void |
| 41 |
gtk_level_bar_accessible_notify_gtk (GObject *obj, |
| 42 |
GParamSpec *pspec) |
| 43 |
{ |
| 44 |
GtkWidget *widget = GTK_WIDGET (obj); |
| 45 |
GtkLevelBarAccessible *level_bar = GTK_LEVEL_BAR_ACCESSIBLE (gtk_widget_get_accessible (widget)); |
| 46 |
|
| 47 |
if (strcmp (pspec->name, "value") == 0) |
| 48 |
{ |
| 49 |
g_object_notify (G_OBJECT (level_bar), "accessible-value"); |
| 50 |
} |
| 51 |
else |
| 52 |
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_level_bar_accessible_parent_class)->notify_gtk (obj, pspec); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
static void |
| 58 |
gtk_level_bar_accessible_class_init (GtkLevelBarAccessibleClass *klass) |
| 59 |
{ |
| 60 |
AtkObjectClass *class = ATK_OBJECT_CLASS (klass); |
| 61 |
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass; |
| 62 |
|
| 63 |
widget_class->notify_gtk = gtk_level_bar_accessible_notify_gtk; |
| 64 |
|
| 65 |
class->initialize = gtk_level_bar_accessible_initialize; |
| 66 |
} |
| 67 |
|
| 68 |
static void |
| 69 |
gtk_level_bar_accessible_init (GtkLevelBarAccessible *button) |
| 70 |
{ |
| 71 |
} |
| 72 |
|
| 73 |
static void |
| 74 |
gtk_level_bar_accessible_get_current_value (AtkValue *obj, |
| 75 |
GValue *value) |
| 76 |
{ |
| 77 |
GtkWidget *widget; |
| 78 |
GtkLevelBar *level_bar; |
| 79 |
|
| 80 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 81 |
level_bar = GTK_LEVEL_BAR (widget); |
| 82 |
|
| 83 |
memset (value, 0, sizeof (GValue)); |
| 84 |
g_value_init (value, G_TYPE_DOUBLE); |
| 85 |
g_value_set_double (value, gtk_level_bar_get_value (level_bar)); |
| 86 |
} |
| 87 |
|
| 88 |
static void |
| 89 |
gtk_level_bar_accessible_get_maximum_value (AtkValue *obj, |
| 90 |
GValue *value) |
| 91 |
{ |
| 92 |
GtkWidget *widget; |
| 93 |
GtkLevelBar *level_bar; |
| 94 |
|
| 95 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 96 |
level_bar = GTK_LEVEL_BAR (widget); |
| 97 |
|
| 98 |
memset (value, 0, sizeof (GValue)); |
| 99 |
g_value_init (value, G_TYPE_DOUBLE); |
| 100 |
g_value_set_double (value, gtk_level_bar_get_max_value (level_bar)); |
| 101 |
} |
| 102 |
|
| 103 |
static void |
| 104 |
gtk_level_bar_accessible_get_minimum_value (AtkValue *obj, |
| 105 |
GValue *value) |
| 106 |
{ |
| 107 |
GtkWidget *widget; |
| 108 |
GtkLevelBar *level_bar; |
| 109 |
|
| 110 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 111 |
level_bar = GTK_LEVEL_BAR (widget); |
| 112 |
|
| 113 |
memset (value, 0, sizeof (GValue)); |
| 114 |
g_value_init (value, G_TYPE_DOUBLE); |
| 115 |
g_value_set_double (value, gtk_level_bar_get_min_value (level_bar)); |
| 116 |
} |
| 117 |
|
| 118 |
static gboolean |
| 119 |
gtk_level_bar_accessible_set_current_value (AtkValue *obj, |
| 120 |
const GValue *value) |
| 121 |
{ |
| 122 |
GtkWidget *widget; |
| 123 |
GtkLevelBar *level_bar; |
| 124 |
|
| 125 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 126 |
level_bar = GTK_LEVEL_BAR (widget); |
| 127 |
|
| 128 |
gtk_level_bar_set_value (level_bar, g_value_get_double (value)); |
| 129 |
|
| 130 |
return TRUE; |
| 131 |
} |
| 132 |
|
| 133 |
static void |
| 134 |
gtk_level_bar_accessible_get_value_and_text (AtkValue *obj, |
| 135 |
gdouble *value, |
| 136 |
gchar **text) |
| 137 |
{ |
| 138 |
GtkWidget *widget; |
| 139 |
GtkLevelBar *level_bar; |
| 140 |
|
| 141 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 142 |
level_bar = GTK_LEVEL_BAR (widget); |
| 143 |
|
| 144 |
*value = gtk_level_bar_get_value (level_bar); |
| 145 |
*text = NULL; |
| 146 |
} |
| 147 |
|
| 148 |
static AtkRange * |
| 149 |
gtk_level_bar_accessible_get_range (AtkValue *obj) |
| 150 |
{ |
| 151 |
GtkWidget *widget; |
| 152 |
GtkLevelBar *level_bar; |
| 153 |
|
| 154 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 155 |
level_bar = GTK_LEVEL_BAR (widget); |
| 156 |
|
| 157 |
return atk_range_new (gtk_level_bar_get_min_value (level_bar), |
| 158 |
gtk_level_bar_get_max_value (level_bar), |
| 159 |
NULL); |
| 160 |
} |
| 161 |
|
| 162 |
static void |
| 163 |
gtk_level_bar_accessible_set_value (AtkValue *obj, |
| 164 |
const gdouble value) |
| 165 |
{ |
| 166 |
GtkWidget *widget; |
| 167 |
GtkLevelBar *level_bar; |
| 168 |
|
| 169 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
| 170 |
level_bar = GTK_LEVEL_BAR (widget); |
| 171 |
|
| 172 |
gtk_level_bar_set_value (level_bar, value); |
| 173 |
} |
| 174 |
|
| 175 |
static void |
| 176 |
atk_value_interface_init (AtkValueIface *iface) |
| 177 |
{ |
| 178 |
iface->get_current_value = gtk_level_bar_accessible_get_current_value; |
| 179 |
iface->get_maximum_value = gtk_level_bar_accessible_get_maximum_value; |
| 180 |
iface->get_minimum_value = gtk_level_bar_accessible_get_minimum_value; |
| 181 |
iface->set_current_value = gtk_level_bar_accessible_set_current_value; |
| 182 |
|
| 183 |
iface->get_value_and_text = gtk_level_bar_accessible_get_value_and_text; |
| 184 |
iface->get_range = gtk_level_bar_accessible_get_range; |
| 185 |
iface->set_value = gtk_level_bar_accessible_set_value; |
| 186 |
} |