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.
23 * @brief EailFlip implementation
26 #include <Elementary.h>
28 #include "eail_flip.h"
29 #include "eail_utils.h"
30 #include "eail_priv.h"
32 static void atk_action_interface_init(AtkActionIface *iface);
35 * @brief Define EailFlip GObject type
37 G_DEFINE_TYPE_WITH_CODE(EailFlip,
40 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
41 atk_action_interface_init));
44 * @brief Handler for event which is raised when flip's visible data is changed
46 * @param data data passed to callback
47 * @param obj Evas_Object that raised event
48 * @param event_info additional event info
51 _eail_flip_handle_changed_event(void *data,
56 (ATK_OBJECT(data), "visible-data-changed", ATK_TYPE_OBJECT);
60 * @brief EailFlip object initialization
62 * @param obj AtkObject instance
63 * @param data user set additional initialization data
66 eail_flip_initialize(AtkObject *obj, gpointer data)
68 Evas_Object *nested_widget = NULL;
69 ATK_OBJECT_CLASS(eail_flip_parent_class)->initialize(obj, data);
71 obj->role = ATK_ROLE_PAGE_TAB_LIST;
73 g_return_if_fail(EAIL_IS_WIDGET(obj));
74 nested_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
77 ERR("No evas object inside EailWidget was found");
81 evas_object_smart_callback_add(nested_widget, "animate,done",
82 _eail_flip_handle_changed_event, obj);
86 * @brief Class destructor
88 * @param object GObject instance
91 eail_flip_finalize(GObject *object)
93 EailFlip *flip = EAIL_FLIP(object);
95 if (flip->flip_description) free(flip->flip_description);
97 G_OBJECT_CLASS(eail_flip_parent_class)->finalize(object);
101 * @brief EailFlip instance initialization
103 * @param flip EailFlip instance
106 eail_flip_init(EailFlip *flip)
108 flip->flip_description = NULL;
112 * @brief Gets widget's children
114 * @param widget EailWidget instance
116 * @return Eina_List representing the list of children,
117 * or NULL if widget has no children
120 eail_flip_get_widget_children(EailWidget *widget)
122 Eina_List *list = NULL;
123 Evas_Object *child, *obj;
125 obj = eail_widget_get_widget(EAIL_WIDGET(widget));
129 if (EINA_TRUE == elm_flip_front_visible_get(obj))
130 child = elm_object_part_content_get(obj, "front");
132 child = elm_object_part_content_get(obj, "back");
134 if (child && elm_object_widget_check(child))
135 list = eina_list_append(list, child);
142 * @brief GObject type initialization function
144 * @param klass EailFlipClass instance
147 eail_flip_class_init(EailFlipClass *klass)
149 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
150 EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
151 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
153 atk_class->initialize = eail_flip_initialize;
154 widget_class->get_widget_children = eail_flip_get_widget_children;
155 gobject_class->finalize = eail_flip_finalize;
159 * Implementation of the *AtkAction* interface
163 * @brief Gets the number of accessible actions available on the object
165 * If there are more than one, the first one is considered the "default" action of the object.
167 * Implementation of get_n_actions from AtkAction interface.
169 * @param action AtkAction instance
170 * @returns integer representing the number of implemented actions
173 eail_flip_n_actions_get(AtkAction *action)
179 * @brief Gets the description string of the specified action
181 * Implementation of get_description from AtkAction interface.
183 * @param action AtkAction instance
184 * @param i action index
186 * @return string representing the specified action's description
189 eail_flip_description_get(AtkAction *action,
193 const char *action_description;
195 flip = EAIL_FLIP(action);
196 if (!flip) return NULL;
201 action_description = flip->flip_description;
204 action_description = NULL;
208 return action_description;
212 * @brief Sets a description of the specified action of the object
214 * Implementation of set_description from AtkAction interface.
216 * @param action AtkAction instance
217 * @param i action index
218 * @param description action's description
220 * @return TRUE on success, FALSE otherwise
223 eail_flip_description_set(AtkAction *action,
225 const char *description)
230 flip = EAIL_FLIP(action);
231 if (!flip) return FALSE;
236 value = &flip->flip_description;
246 *value = g_strdup(description);
254 * @brief Gets the name string of the specified action
256 * Implementation of get_name from AtkAction interface.
258 * @param action AtkAction instance
259 * @param i action index
261 * @return string representing the specified action's name
264 eail_flip_action_name_get(AtkAction *action,
267 const char* action_name;
272 action_name = "flip";
283 * @brief Performs the specified action on the object
285 * Implementation of do_action from AtkAction interface.
287 * @param action AtkAction instance
288 * @param i action index
290 * @return TRUE on success, FALSE otherwise
293 eail_flip_do_action(AtkAction *action,
298 widget = eail_widget_get_widget(EAIL_WIDGET(action));
299 if (!widget) return FALSE;
301 if ((elm_object_disabled_get(widget)) || (!evas_object_visible_get(widget)))
304 const char *action_name = atk_action_get_name(action, i);
305 if (!action_name) return FALSE;
307 if (EINA_TRUE == elm_flip_front_visible_get(widget))
308 elm_flip_go_to(widget, EINA_FALSE, ELM_FLIP_CUBE_DOWN); // turn down
310 elm_flip_go_to(widget, EINA_TRUE, ELM_FLIP_CUBE_UP); // turn up
316 * @brief AtkAction interface initializer
318 * @param iface AtkActionIface instance
321 atk_action_interface_init(AtkActionIface *iface)
323 g_return_if_fail(iface != NULL);
325 iface->get_n_actions = eail_flip_n_actions_get;
326 iface->get_description = eail_flip_description_get;
327 iface->set_description = eail_flip_description_set;
328 iface->get_name = eail_flip_action_name_get;
329 iface->do_action = eail_flip_do_action;