2 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
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 License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 * @file eail_spinner.c
22 * @brief EailSpinner implementation
25 #include <Elementary.h>
27 #include "eail_spinner.h"
28 #include "eail_utils.h"
30 static void atk_value_interface_init(AtkValueIface *iface);
33 * @brief EailSpinner type definition
35 G_DEFINE_TYPE_WITH_CODE(EailSpinner,
38 G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE,
39 atk_value_interface_init));
42 * @brief handler for changed event
44 * @param data passed to callback
45 * @param obj object that raised event
46 * @param event_info additional event info
50 _eail_spinner_handle_changed_event(void *data,
55 (ATK_OBJECT(data), "visible-data-changed", ATK_TYPE_OBJECT);
59 * @brief EailSpinner interface initializer
61 * @param spinner EailSpinner instance
64 eail_spinner_init(EailSpinner *spinner)
69 * @brief EailSpinner initializer
71 * @param obj AtkObject instance
72 * @param data initialization data
75 eail_spinner_initialize(AtkObject *obj, gpointer data)
77 Evas_Object *nested_widget = NULL;
78 ATK_OBJECT_CLASS(eail_spinner_parent_class)->initialize(obj, data);
80 obj->role = ATK_ROLE_SPIN_BUTTON;
81 g_return_if_fail(EAIL_IS_WIDGET(obj));
83 nested_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
84 evas_object_smart_callback_add(nested_widget, "changed",
85 _eail_spinner_handle_changed_event, obj);
89 * @brief Gets the accessible name of the accessible
91 * @param accessible AtkObject instance
92 * @return string representing the accessible name of the accessible
95 eail_spinner_get_name(AtkObject *accessible)
100 name = ATK_OBJECT_CLASS(eail_spinner_parent_class)->get_name(accessible);
101 if (name) return name;
103 widget = eail_widget_get_widget(EAIL_WIDGET(accessible));
105 name = (const gchar*)elm_object_text_get(widget);
111 * @brief EailSpinner class initializer
113 * @param klass EailSpinnerClass instance
116 eail_spinner_class_init(EailSpinnerClass *klass)
118 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
120 atk_class->initialize = eail_spinner_initialize;
121 atk_class->get_name = eail_spinner_get_name;
125 * @brief Gets the current value of obj
127 * @param obj AtkValue instance
128 * @param [out] value obj's current value
131 eail_spinner_get_current_value(AtkValue *obj,
136 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
139 memset(value, 0, sizeof(GValue));
140 g_value_init(value, G_TYPE_DOUBLE);
141 g_value_set_double(value, elm_spinner_value_get(widget));
145 * @brief Gets the maximum value of obj
147 * @param obj AtkValue instance
148 * @param [out] value obj's maxiumum value
151 eail_spinner_get_maximum_value(AtkValue *obj,
157 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
160 memset(value, 0, sizeof(GValue));
161 g_value_init(value, G_TYPE_DOUBLE);
162 elm_spinner_min_max_get(widget, NULL, &max);
163 g_value_set_double(value, max);
167 * @brief Gets the minimum value of obj
169 * @param obj AtkValue instance
170 * @param [out] value obj's minimum value
173 eail_spinner_get_minimum_value(AtkValue *obj,
179 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
182 memset(value, 0, sizeof(GValue));
183 g_value_init(value, G_TYPE_DOUBLE);
184 elm_spinner_min_max_get(widget, &min, NULL);
185 g_value_set_double(value, min);
189 * @brief Sets the current value of obj
191 * @param obj AtkValue instance
192 * @param value obj's new value
193 * @return TRUE if new value was set successfully, FALSE otherwise
196 eail_spinner_set_current_value(AtkValue *obj,
200 double min, max, val;
202 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
203 if (!widget) return FALSE;
205 val = g_value_get_double(value);
206 elm_spinner_min_max_get(widget, &min, &max);
208 if (min > val || max < val)
211 elm_spinner_value_set(widget, val);
217 * @brief Gets the minimum increment of obj
219 * @param obj AtkValue instance
220 * @param [out] value obj's minimum increment
223 eail_spinner_get_minimum_increment(AtkValue *obj,
228 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
231 memset(value, 0, sizeof(GValue));
232 g_value_init(value, G_TYPE_DOUBLE);
233 g_value_set_double(value, elm_spinner_step_get(widget));
237 * @brief AtkValue interface initializer
239 * @param iface AtkValueIface instance
242 atk_value_interface_init(AtkValueIface *iface)
244 g_return_if_fail(iface != NULL);
246 iface->get_current_value = eail_spinner_get_current_value;
247 iface->get_maximum_value = eail_spinner_get_maximum_value;
248 iface->get_minimum_value = eail_spinner_get_minimum_value;
249 iface->set_current_value = eail_spinner_set_current_value;
250 iface->get_minimum_increment = eail_spinner_get_minimum_increment;