Merge branch 'wip/tintou/atkimplementor-gir' into 'master'
[atk.git] / atk / atkrange.c
blobbb69ca5ca12382c67871271e49e2eeea648e7a28
1 /* ATK - Accessibility Toolkit
2 * Copyright 2014 Igalia S.L.
4 * Author: Alejandro PiƱeiro Iglesias <apinheiro@igalia.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "config.h"
24 #include "atkvalue.h"
26 /**
27 * SECTION:atkrange
28 * @Short_description: A given range or subrange, to be used with #AtkValue
29 * @Title:AtkRange
31 * #AtkRange are used on #AtkValue, in order to represent the full
32 * range of a given component (for example an slider or a range
33 * control), or to define each individual subrange this full range is
34 * splitted if available. See #AtkValue documentation for further
35 * details.
38 struct _AtkRange {
39 gdouble lower;
40 gdouble upper;
41 gchar *description;
44 /**
45 * atk_range_copy:
46 * @src: #AtkRange to copy
48 * Returns a new #AtkRange that is a exact copy of @src
50 * Since: 2.12
52 * Returns: (transfer full): a new #AtkRange copy of @src
54 AtkRange *
55 atk_range_copy (AtkRange *src)
57 g_return_val_if_fail (src != NULL, NULL);
59 return atk_range_new (src->lower,
60 src->upper,
61 src->description);
64 /**
65 * atk_range_free:
66 * @range: #AtkRange to free
68 * Free @range
70 * Since: 2.12
72 void
73 atk_range_free (AtkRange *range)
75 g_return_if_fail (range != NULL);
77 if (range->description)
78 g_free (range->description);
80 g_slice_free (AtkRange, range);
83 G_DEFINE_BOXED_TYPE (AtkRange, atk_range, atk_range_copy,
84 atk_range_free)
87 /**
88 * atk_range_new:
89 * @lower_limit: inferior limit for this range
90 * @upper_limit: superior limit for this range
91 * @description: human readable description of this range.
93 * Creates a new #AtkRange.
95 * Since: 2.12
97 * Returns: (transfer full): a new #AtkRange
100 AtkRange*
101 atk_range_new (gdouble lower_limit,
102 gdouble upper_limit,
103 const gchar *description)
105 AtkRange *range;
107 range = g_slice_new0 (AtkRange);
109 range->lower = lower_limit;
110 range->upper = upper_limit;
111 if (description != NULL)
112 range->description = g_strdup (description);
114 return range;
118 * atk_range_get_lower_limit:
119 * @range: an #AtkRange
121 * Returns the lower limit of @range
123 * Since: 2.12
125 * Returns: the lower limit of @range
127 gdouble
128 atk_range_get_lower_limit (AtkRange *range)
130 g_return_val_if_fail (range != NULL, 0);
132 return range->lower;
136 * atk_range_get_upper_limit:
137 * @range: an #AtkRange
139 * Returns the upper limit of @range
141 * Since: 2.12
143 * Returns: the upper limit of @range
145 gdouble
146 atk_range_get_upper_limit (AtkRange *range)
148 g_return_val_if_fail (range != NULL, 0);
150 return range->upper;
154 * atk_range_get_description:
155 * @range: an #AtkRange
157 * Returns the human readable description of @range
159 * Since: 2.12
161 * Returns: the human-readable description of @range
163 const gchar*
164 atk_range_get_description (AtkRange *range)
166 g_return_val_if_fail (range != NULL, NULL);
168 return range->description;