60653465596fcb673b8acd117b7703ab9a2cccf2
[platform/upstream/atk.git] / atk / atkvalue.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 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 "atkvalue.h"
21
22 GType
23 atk_value_get_type ()
24 {
25   static GType type = 0;
26
27   if (!type) {
28     GTypeInfo tinfo =
29     {
30       sizeof (AtkValueIface),
31       (GBaseInitFunc) NULL,
32       (GBaseFinalizeFunc) NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkValue", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_value_get_current_value:
44  * @obj: a GObject instance that implements AtkValueIface
45  * @value: a #GValue representing the current accessible value
46  *
47  * Gets the value of this object.
48  **/
49 void
50 atk_value_get_current_value (AtkValue *obj,
51                              GValue   *value)
52 {
53   AtkValueIface *iface;
54
55   g_return_if_fail (value != NULL);
56   g_return_if_fail (ATK_IS_VALUE (obj));
57
58   iface = ATK_VALUE_GET_IFACE (obj);
59
60   if (iface->get_current_value)
61     (iface->get_current_value) (obj, value);
62 }
63
64 /**
65  * atk_value_get_maximum_value:
66  * @obj: a GObject instance that implements AtkValueIface
67  * @value: a #GValue representing the maximum accessible value
68  *
69  * Gets the maximum value of this object.
70  **/
71 void
72 atk_value_get_maximum_value  (AtkValue *obj,
73                               GValue   *value)
74 {
75   AtkValueIface *iface;
76
77   g_return_if_fail (value != NULL);
78   g_return_if_fail (ATK_IS_VALUE (obj));
79
80   iface = ATK_VALUE_GET_IFACE (obj);
81
82   if (iface->get_maximum_value)
83     (iface->get_maximum_value) (obj, value);
84 }
85
86 /**
87  * atk_value_get_minimum_value:
88  * @obj: a GObject instance that implements AtkValueIface
89  * @value: a #GValue representing the minimum accessible value
90  *
91  * Gets the minimum value of this object.
92  **/
93 void
94 atk_value_get_minimum_value (AtkValue *obj,
95                              GValue   *value)
96 {
97   AtkValueIface *iface;
98
99   g_return_if_fail (value != NULL);
100   g_return_if_fail (ATK_IS_VALUE (obj));
101
102   iface = ATK_VALUE_GET_IFACE (obj);
103
104   if (iface->get_minimum_value)
105     (iface->get_minimum_value) (obj, value);
106 }
107
108 /**
109  * atk_value_set_current_value:
110  * @obj: a GObject instance that implements AtkValueIface
111  * @value: a #GValue which is the desired new accessible value.
112  *
113  * Sets the value of this object.
114  *
115  * Returns: %TRUE if new value is successfully set, %FALSE otherwise.
116  **/
117 gboolean
118 atk_value_set_current_value (AtkValue       *obj, 
119                              const GValue   *value)
120 {
121   AtkValueIface *iface;
122
123   g_return_val_if_fail (ATK_IS_VALUE (obj), FALSE);
124   g_return_val_if_fail (G_IS_VALUE (value), FALSE);
125
126   iface = ATK_VALUE_GET_IFACE (obj);
127
128   if (iface->set_current_value)
129     return (iface->set_current_value) (obj, value);
130   else
131     return FALSE;
132 }