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_progressbar.c
22 * @brief EailProgressbar implementation
25 #include <Elementary.h>
27 #include "eail_progressbar.h"
28 #include "eail_utils.h"
30 static void atk_value_interface_init(AtkValueIface *iface);
33 * @brief Define EailProgressbar GObject type
35 G_DEFINE_TYPE_WITH_CODE(EailProgressbar,
38 G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE,
39 atk_value_interface_init));
42 * Implementation of the *AtkObject* interface
46 * @brief Handler for changed event
48 * @param data data passed to callback
49 * @param obj Evas_Object that raised event
50 * @param event_info additional event info
53 _eail_progressbar_handle_changed_event(void *data,
58 (ATK_OBJECT(data), "visible-data-changed", ATK_TYPE_OBJECT);
62 * @brief EailProgressbar object initialization
64 * @param obj AtkObject instance
65 * @param data user set additional initialization data
68 eail_progressbar_initialize(AtkObject *obj, gpointer data)
70 Evas_Object *nested_widget = NULL;
72 ATK_OBJECT_CLASS(eail_progressbar_parent_class)->initialize(obj, data);
74 obj->role = ATK_ROLE_PROGRESS_BAR;
75 g_return_if_fail(EAIL_IS_WIDGET(obj));
77 nested_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
78 evas_object_smart_callback_add(nested_widget, "changed",
79 _eail_progressbar_handle_changed_event, obj);
84 * @brief Gets the list of child widgets
86 * @param widget EailWidget object
88 * @return Eina_List representing the list of widget's children
89 * or NULL if widget has no children
92 eail_progressbar_get_widget_children(EailWidget *widget)
94 Eina_List *list = NULL;
95 Evas_Object *child, *obj;
97 obj = eail_widget_get_widget(EAIL_WIDGET(widget));
100 child = elm_object_part_content_get(obj, "icon");
101 if (child && elm_object_widget_check(child))
102 list = eina_list_append(list, child);
109 * @brief Gets the slider's name
111 * @param obj AtkObject instance
112 * @returns string representing the accessible name of the slider
115 eail_progressbar_get_name(AtkObject *obj)
120 name = ATK_OBJECT_CLASS(eail_progressbar_parent_class)->get_name(obj);
121 if (name) return name;
123 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
125 name = (const gchar*)elm_object_text_get(widget);
131 * @brief EailProgressbar instance initialization
133 * @param progressbar EailProgressbar instance
136 eail_progressbar_init(EailProgressbar *progressbar)
141 * @brief GObject type initialization function
143 * @param klass EailProgressbarClass instance
146 eail_progressbar_class_init(EailProgressbarClass *klass)
148 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
149 EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
151 atk_class->initialize = eail_progressbar_initialize;
152 atk_class->get_name = eail_progressbar_get_name;
153 widget_class->get_widget_children = eail_progressbar_get_widget_children;
157 * Implementation of the *AtkValue* interface
161 * @brief Gets the current value of obj
163 * @param obj AtkValue instance
164 * @param [out] value obj's current value
167 eail_progressbar_get_current_value(AtkValue *obj,
172 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
175 memset(value, 0, sizeof(GValue));
176 g_value_init(value, G_TYPE_DOUBLE);
177 g_value_set_double(value, elm_progressbar_value_get(widget));
181 * @brief Gets the maxiumum value of obj
183 * @param obj AtkValue instance
184 * @param [out] value obj's maxiumum value
187 eail_progressbar_get_maximum_value(AtkValue *obj,
192 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
195 memset(value, 0, sizeof(GValue));
196 g_value_init(value, G_TYPE_DOUBLE);
197 g_value_set_double(value, 1.0);
201 * @brief Gets the minimum value of obj
203 * @param obj AtkValue instance
204 * @param [out] value obj's minimum value
207 eail_progressbar_get_minimum_value(AtkValue *obj,
212 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
215 memset(value, 0, sizeof(GValue));
216 g_value_init(value, G_TYPE_DOUBLE);
217 g_value_set_double(value, 0.0);
221 * @brief Sets the value of obj
223 * @param obj AtkValue instance
224 * @param value obj's new value
225 * @return TRUE if new value is set successfully, FALSE otherwise
228 eail_progressbar_set_current_value(AtkValue *obj,
234 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
235 if (!widget) return FALSE;
237 val = g_value_get_double(value);
239 if (0.0 > val || 1.0 < val)
242 elm_progressbar_value_set(widget, val);
248 * @brief Gets the minimum increment of obj
250 * @param obj AtkValue instance
251 * @param [out] value obj's minimum increment
254 eail_progressbar_get_minimum_increment(AtkValue *obj,
259 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
262 memset(value, 0, sizeof(GValue));
263 g_value_init(value, G_TYPE_DOUBLE);
264 g_value_set_double(value, G_MINDOUBLE);
268 * @brief AtkValue interface initializer
270 * @param iface AtkValueIface instance
273 atk_value_interface_init(AtkValueIface *iface)
275 g_return_if_fail(iface != NULL);
277 iface->get_current_value = eail_progressbar_get_current_value;
278 iface->get_maximum_value = eail_progressbar_get_maximum_value;
279 iface->get_minimum_value = eail_progressbar_get_minimum_value;
280 iface->set_current_value = eail_progressbar_set_current_value;
281 iface->get_minimum_increment = eail_progressbar_get_minimum_increment;