Correct return value. Fixes bug #116621. Problem reported by Mario Lang.
[atk.git] / atk / atkvalue.c
blob22d1b6d9e39170b554f0713d87f1099a7e1d765b
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
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.
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.
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.
20 #include <string.h>
21 #include "atkvalue.h"
23 GType
24 atk_value_get_type ()
26 static GType type = 0;
28 if (!type) {
29 GTypeInfo tinfo =
31 sizeof (AtkValueIface),
32 (GBaseInitFunc) NULL,
33 (GBaseFinalizeFunc) NULL,
37 type = g_type_register_static (G_TYPE_INTERFACE, "AtkValue", &tinfo, 0);
40 return type;
43 /**
44 * atk_value_get_current_value:
45 * @obj: a GObject instance that implements AtkValueIface
46 * @value: a #GValue representing the current accessible value
48 * Gets the value of this object.
49 **/
50 void
51 atk_value_get_current_value (AtkValue *obj,
52 GValue *value)
54 AtkValueIface *iface;
56 g_return_if_fail (value != NULL);
57 g_return_if_fail (ATK_IS_VALUE (obj));
59 iface = ATK_VALUE_GET_IFACE (obj);
61 if (iface->get_current_value)
63 if (G_IS_VALUE (value))
64 g_value_unset (value);
65 else
66 memset (value, 0, sizeof (*value));
68 (iface->get_current_value) (obj, value);
72 /**
73 * atk_value_get_maximum_value:
74 * @obj: a GObject instance that implements AtkValueIface
75 * @value: a #GValue representing the maximum accessible value
77 * Gets the maximum value of this object.
78 **/
79 void
80 atk_value_get_maximum_value (AtkValue *obj,
81 GValue *value)
83 AtkValueIface *iface;
85 g_return_if_fail (value != NULL);
86 g_return_if_fail (ATK_IS_VALUE (obj));
88 iface = ATK_VALUE_GET_IFACE (obj);
90 if (iface->get_maximum_value)
92 if (G_IS_VALUE (value))
93 g_value_unset (value);
94 else
95 memset (value, 0, sizeof (*value));
97 (iface->get_maximum_value) (obj, value);
102 * atk_value_get_minimum_value:
103 * @obj: a GObject instance that implements AtkValueIface
104 * @value: a #GValue representing the minimum accessible value
106 * Gets the minimum value of this object.
108 void
109 atk_value_get_minimum_value (AtkValue *obj,
110 GValue *value)
112 AtkValueIface *iface;
114 g_return_if_fail (value != NULL);
115 g_return_if_fail (ATK_IS_VALUE (obj));
117 iface = ATK_VALUE_GET_IFACE (obj);
119 if (iface->get_minimum_value)
121 if (G_IS_VALUE (value))
122 g_value_unset (value);
123 else
124 memset (value, 0, sizeof (*value));
126 (iface->get_minimum_value) (obj, value);
131 * atk_value_set_current_value:
132 * @obj: a GObject instance that implements AtkValueIface
133 * @value: a #GValue which is the desired new accessible value.
135 * Sets the value of this object.
137 * Returns: %TRUE if new value is successfully set, %FALSE otherwise.
139 gboolean
140 atk_value_set_current_value (AtkValue *obj,
141 const GValue *value)
143 AtkValueIface *iface;
145 g_return_val_if_fail (ATK_IS_VALUE (obj), FALSE);
146 g_return_val_if_fail (G_IS_VALUE (value), FALSE);
148 iface = ATK_VALUE_GET_IFACE (obj);
150 if (iface->set_current_value)
151 return (iface->set_current_value) (obj, value);
152 else
153 return FALSE;