atkrange.c 3.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ATK -  Accessibility Toolkit
 * Copyright 2014 Igalia S.L.
 *
 * Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

22
23
#include "config.h"

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include "atkvalue.h"

/**
 * SECTION:atkrange
 * @Short_description: A given range or subrange, to be used with #AtkValue
 * @Title:AtkRange
 *
 * #AtkRange are used on #AtkValue, in order to represent the full
 * range of a given component (for example an slider or a range
 * control), or to define each individual subrange this full range is
 * splitted if available. See #AtkValue documentation for further
 * details.
 */

struct _AtkRange {
  gdouble lower;
  gdouble upper;
  gchar *description;
};

/**
 * atk_range_copy:
 * @src: #AtkRange to copy
 *
 * Returns a new #AtkRange that is a exact copy of @src
 *
 * Since: 2.12
 *
 * Returns: (transfer full): a new #AtkRange copy of @src
 */
AtkRange *
atk_range_copy (AtkRange *src)
{
  g_return_val_if_fail (src != NULL, NULL);

  return atk_range_new (src->lower,
                        src->upper,
                        src->description);
}

/**
 * atk_range_free:
 * @range: #AtkRange to free
 *
 * Free @range
 *
 * Since: 2.12
 */
void
atk_range_free (AtkRange *range)
{
  g_return_if_fail (range != NULL);

  if (range->description)
    g_free (range->description);

  g_slice_free (AtkRange, range);
}

G_DEFINE_BOXED_TYPE (AtkRange, atk_range, atk_range_copy,
                     atk_range_free)


/**
 * atk_range_new:
 * @lower_limit: inferior limit for this range
 * @upper_limit: superior limit for this range
 * @description: human readable description of this range.
 *
 * Creates a new #AtkRange.
 *
 * Since: 2.12
 *
 * Returns: (transfer full): a new #AtkRange
 *
 */
AtkRange*
atk_range_new  (gdouble   lower_limit,
                gdouble   upper_limit,
                const gchar *description)
{
  AtkRange *range;

  range = g_slice_new0 (AtkRange);

  range->lower = lower_limit;
  range->upper = upper_limit;
  if (description != NULL)
    range->description = g_strdup (description);

  return range;
}

/**
 * atk_range_get_lower_limit:
 * @range: an #AtkRange
 *
 * Returns the lower limit of @range
 *
 * Since: 2.12
 *
 * Returns: the lower limit of @range
 */
gdouble
atk_range_get_lower_limit  (AtkRange *range)
{
  g_return_val_if_fail (range != NULL, 0);

  return range->lower;
}

/**
 * atk_range_get_upper_limit:
 * @range: an #AtkRange
 *
 * Returns the upper limit of @range
 *
 * Since: 2.12
 *
 * Returns: the upper limit of @range
 */
gdouble
atk_range_get_upper_limit (AtkRange *range)
{
  g_return_val_if_fail (range != NULL, 0);

  return range->upper;
}

/**
 * atk_range_get_description:
 * @range: an #AtkRange
 *
 * Returns the human readable description of @range
 *
 * Since: 2.12
 *
 * Returns: the human-readable description of @range
 */
const gchar*
atk_range_get_description  (AtkRange *range)
{
  g_return_val_if_fail (range != NULL, NULL);

  return range->description;
}