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_action_slider.c
22 * @brief EailActionSlider implementation
25 #include <Elementary.h>
27 #include "eail_action_slider.h"
28 #include "eail_utils.h"
31 * @brief Initialization of AtkValue interface
33 * @param iface EailActionSlider object
35 static void atk_value_interface_init(AtkValueIface *iface);
38 * @brief Define EailActionSlider GObject type
40 G_DEFINE_TYPE_WITH_CODE(EailActionSlider,
43 G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE,
44 atk_value_interface_init));
47 * Implementation of the *AtkObject* interface
51 * @brief Handler for pos_changed event
53 * @param data data passed to callback
54 * @param obj object that raised event
55 * @param event_info additional event info
58 _eail_action_slider_handle_pos_changed_event(void *data,
63 (ATK_OBJECT(data), "visible-data-changed", ATK_TYPE_OBJECT);
67 * @brief EailActionSlider object initialization
69 * @param obj EailActionSlider object
70 * @param data additional initialization data
73 eail_action_slider_initialize(AtkObject *obj, gpointer data)
75 Evas_Object *nested_widget = NULL;
77 ATK_OBJECT_CLASS(eail_action_slider_parent_class)->initialize(obj, data);
78 obj->role = ATK_ROLE_SLIDER;
80 g_return_if_fail(EAIL_IS_WIDGET(obj));
82 nested_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
83 evas_object_smart_callback_add(nested_widget, "pos_changed",
84 _eail_action_slider_handle_pos_changed_event, obj);
89 * @brief EailActionSlider instance initialization
91 * @param action_slider EailActionSlider instance
94 eail_action_slider_init(EailActionSlider *action_slider)
99 * @brief GObject type initialization function
101 * @param klass EailActionSliderClass instance
104 eail_action_slider_class_init(EailActionSliderClass *klass)
106 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
108 atk_class->initialize = eail_action_slider_initialize;
112 * Implementation of the *AtkValue* interface
116 * @brief Gets obj's current value
118 * @param obj EailActionSlider instance
119 * @param [out] value obj's current value
122 eail_action_slider_get_current_value(AtkValue *obj,
127 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
130 memset(value, 0, sizeof(GValue));
131 g_value_init(value, G_TYPE_UINT);
132 g_value_set_uint(value, elm_actionslider_indicator_pos_get(widget));
136 * @brief Gets obj's maxiumum value
138 * @param obj EailActionSlider instance
139 * @param [out] value obj's maxiumum value
142 eail_action_slider_get_maximum_value(AtkValue *obj,
147 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
150 memset(value, 0, sizeof(GValue));
151 g_value_init(value, G_TYPE_UINT);
152 g_value_set_uint(value, elm_actionslider_enabled_pos_get(widget));
156 * @brief Gets obj's minimum value
158 * @param obj EailActionSlider instance
159 * @param [out] value obj's minimum value
162 eail_action_slider_get_minimum_value(AtkValue *obj,
167 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
170 memset(value, 0, sizeof(GValue));
171 g_value_init(value, G_TYPE_UINT);
172 g_value_set_uint(value, ELM_ACTIONSLIDER_NONE);
176 * @brief Sets obj's value
178 * @param obj EailActionSlider instance
179 * @param value obj's new value
180 * @return TRUE if new value was set successfully, FALSE otherwise
183 eail_action_slider_set_current_value(AtkValue *obj,
189 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
190 if (!widget) return FALSE;
192 enum_val = elm_actionslider_enabled_pos_get(widget) &
193 g_value_get_uint(value);
197 case ELM_ACTIONSLIDER_LEFT:
198 case ELM_ACTIONSLIDER_CENTER:
199 case ELM_ACTIONSLIDER_RIGHT:
200 elm_actionslider_indicator_pos_set(widget, enum_val);
212 * @brief Gets obj's minimum increment
214 * @param obj EailActionSlider instance
215 * @param [out] value obj's minimum increment
218 eail_action_slider_get_minimum_increment(AtkValue *obj,
223 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
226 memset(value, 0, sizeof(GValue));
227 g_value_init(value, G_TYPE_UINT);
228 g_value_set_uint(value, ELM_ACTIONSLIDER_NONE);
233 atk_value_interface_init(AtkValueIface *iface)
235 iface->get_current_value = eail_action_slider_get_current_value;
236 iface->get_maximum_value = eail_action_slider_get_maximum_value;
237 iface->get_minimum_value = eail_action_slider_get_minimum_value;
238 iface->set_current_value = eail_action_slider_set_current_value;
239 iface->get_minimum_increment = eail_action_slider_get_minimum_increment;