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.
22 * @brief EailSlider implementation
25 #include <Elementary.h>
27 #include "eail_slider.h"
28 #include "eail_utils.h"
31 * Implementation of the *AtkObject* interface
35 * @brief Initialization of AtkValue interface
37 * @param iface AtkValueIface instance
39 static void atk_value_interface_init(AtkValueIface *iface);
42 * @brief Define EailSlider GObject type
44 G_DEFINE_TYPE_WITH_CODE(EailSlider,
47 G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE,
48 atk_value_interface_init));
51 * @brief Handler for changed event
53 * @param data passed to callback
54 * @param obj Evas_Object that raised event
55 * @param event_info additional event info
58 _eail_slider_handle_changed_event(void *data,
63 (ATK_OBJECT(data), "visible-data-changed", ATK_TYPE_OBJECT);
67 * @brief EailSlider object initialization
69 * @param obj AtkObject instance
70 * @param data user set additional initialization data
73 eail_slider_initialize(AtkObject *obj, gpointer data)
75 Evas_Object *nested_widget = NULL;
76 ATK_OBJECT_CLASS(eail_slider_parent_class)->initialize(obj, data);
78 obj->role = ATK_ROLE_SLIDER;
79 g_return_if_fail(EAIL_IS_WIDGET(obj));
81 nested_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
82 evas_object_smart_callback_add(nested_widget, "changed",
83 _eail_slider_handle_changed_event, obj);
87 * @brief Gets the list of child widgets
89 * @param widget EailWidget instance
91 * @return Eina_List representing the list of widget's children
94 eail_slider_get_widget_children(EailWidget *widget)
96 Eina_List *list = NULL;
97 Evas_Object *child, *obj;
99 obj = eail_widget_get_widget(EAIL_WIDGET(widget));
102 child = elm_object_part_content_get(obj, "icon");
103 if (child && elm_object_widget_check(child))
104 list = eina_list_append(list, child);
106 child = elm_object_part_content_get(obj, "end");
107 if (child && elm_object_widget_check(child))
108 list = eina_list_append(list, child);
115 * @brief Gets the name of the slider
117 * @param obj AtkObject instance
119 * @returns string representing the name of the slider
122 eail_slider_get_name(AtkObject *obj)
127 name = ATK_OBJECT_CLASS(eail_slider_parent_class)->get_name(obj);
128 if (name) return name;
130 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
132 name = (const gchar*)elm_object_text_get(widget);
138 * @brief EailSlider instance initialization
140 * @param slider EailSlider instance
143 eail_slider_init(EailSlider *slider)
148 * @brief GObject type initialization function
150 * @param klass EailSliderClass instance
153 eail_slider_class_init(EailSliderClass *klass)
155 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
156 EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
158 widget_class->get_widget_children = eail_slider_get_widget_children;
159 atk_class->initialize = eail_slider_initialize;
160 atk_class->get_name = eail_slider_get_name;
164 * Implementation of the *AtkValue* interface
168 * @brief Gets the current value of obj
170 * @param obj AtkValue instance
171 * @param [out] value obj's current value
174 eail_slider_get_current_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 g_value_set_double(value, elm_slider_value_get(widget));
188 * @brief Gets the maxiumum value of obj
190 * @param obj AtkValue instance
191 * @param [out] value obj's maxiumum value
194 eail_slider_get_maximum_value(AtkValue *obj,
200 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
203 memset(value, 0, sizeof(GValue));
204 g_value_init(value, G_TYPE_DOUBLE);
205 elm_slider_min_max_get(widget, NULL, &max);
206 g_value_set_double(value, max);
210 * @brief Gets the minimum value of obj
212 * @param obj AtkValue instance
213 * @param [out] value obj's minimum value
216 eail_slider_get_minimum_value(AtkValue *obj,
222 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
225 memset(value, 0, sizeof(GValue));
226 g_value_init(value, G_TYPE_DOUBLE);
227 elm_slider_min_max_get(widget, &min, NULL);
228 g_value_set_double(value, min);
232 * @brief Sets the value of obj
234 * @param obj AtkValue instance
235 * @param value obj's new value
236 * @return TRUE if new value was set successfully, FALSE otherwise
239 eail_slider_set_current_value(AtkValue *obj,
243 double min, max, val;
245 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
246 if (!widget) return FALSE;
248 val = g_value_get_double(value);
249 elm_slider_min_max_get(widget, &min, &max);
251 if (min > val || max < val)
254 elm_slider_value_set(widget, val);
260 * @brief Gets the minimum increment of obj
262 * @param obj AtkValue instance
263 * @param [out] value obj's minimum increment
266 eail_slider_get_minimum_increment(AtkValue *obj,
271 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
274 memset(value, 0, sizeof(GValue));
275 g_value_init(value, G_TYPE_DOUBLE);
276 g_value_set_double(value, 0);
280 * @brief AtkValue interface initializer
282 * @param iface AtkValueIface instance
285 atk_value_interface_init(AtkValueIface *iface)
287 g_return_if_fail(iface != NULL);
289 iface->get_current_value = eail_slider_get_current_value;
290 iface->get_maximum_value = eail_slider_get_maximum_value;
291 iface->get_minimum_value = eail_slider_get_minimum_value;
292 iface->set_current_value = eail_slider_set_current_value;
293 iface->get_minimum_increment = eail_slider_get_minimum_increment;