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 EailHover implementation.
25 #include <Elementary.h>
27 #include "eail_hover.h"
28 #include "eail_factory.h"
30 static void atk_action_interface_init(AtkActionIface *iface);
33 * @brief EailHover type definition
35 G_DEFINE_TYPE_WITH_CODE(EailHover,
38 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
39 atk_action_interface_init));
42 * @brief EailHover initializer
44 * @param obj AtkObject instance
45 * @param data initialization data
48 eail_hover_initialize(AtkObject *obj, gpointer data)
50 ATK_OBJECT_CLASS(eail_hover_parent_class)->initialize(obj, data);
51 obj->role = ATK_ROLE_GLASS_PANE;
55 * @brief EailHover finalizer.
57 * Destroys the object and allocated resources.
59 * @param obj GObject instance
62 eail_hover_finalize(GObject *obj)
64 EailHover *hover = EAIL_HOVER(obj);
66 if (hover->click_description) free(hover->click_description);
68 G_OBJECT_CLASS(eail_hover_parent_class)->finalize(obj);
72 * @brief EailHover instance initializer
74 * @param hover EailHover instance
77 eail_hover_init(EailHover *hover)
79 hover->click_description = NULL;
83 * @brief EailHover class initializer.
85 * @param klass EailHoverClass instance
88 eail_hover_class_init(EailHoverClass *klass)
90 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
91 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
93 atk_class->initialize = eail_hover_initialize;
95 gobject_class->finalize = eail_hover_finalize;
99 * @brief Performs the specified action on the object.
101 * @param action AtkAction instance
102 * @param i index of an action to be performed
103 * @return TRUE on success, FALSE otherwise
106 eail_hover_action_do_action(AtkAction *action,
109 Evas_Object *widget = NULL;
110 const char *action_name = NULL;
112 widget = eail_widget_get_widget(EAIL_WIDGET(action));
113 if (!widget) return FALSE;
115 if ((elm_object_disabled_get(widget)) || (!evas_object_visible_get(widget)))
118 action_name = atk_action_get_name(action, i);
119 if (!action_name) return FALSE;
121 evas_object_smart_callback_call(widget, "clicked", NULL);
127 * @brief Gets number of actions available on the object.
129 * If there are more than one, the first one is considered the "default" action of the object.
131 * Implementation of get_n_actions from AtkAction interface.
133 * @param action AtkAction instance
134 * @return integer containing the number of implemented actions
137 eail_hover_action_get_n_actions(AtkAction *action)
143 * @brief Gets the description of the specified action of the object.
145 * Implementation of get_description from AtkAction interface.
147 * @param action AtkAction instance
148 * @param i action number
149 * @return string representing the description of the specified action
152 eail_hover_action_get_description(AtkAction *action,
155 const char *action_description = NULL;
158 hover = EAIL_HOVER(action);
159 if (!hover) return NULL;
164 action_description = hover->click_description;
168 action_description = NULL;
172 return action_description;
176 * @brief Gets the name of the specified action of the object.
178 * Implementation of get_name from AtkAction interface.
180 * @param action AtkAction instance
181 * @param i action number
182 * @return string containing the name of the specified action
185 eail_hover_action_get_name(AtkAction *action,
188 const char* action_name = NULL;
193 action_name = "click";
205 * @brief Sets a description of the specified action of the object.
207 * Implementation of set_description from AtkAction interface.
209 * @param action AtkAction instance
210 * @param i action number
211 * @param desc action description
212 * @return TRUE if description was set successfully, FALSE otherwise
215 eail_hover_action_set_description(AtkAction *action,
219 EailHover *hover = NULL;
222 hover = EAIL_HOVER(action);
223 if (!hover) return FALSE;
228 value = &hover->click_description;
239 *value = g_strdup(desc);
248 * @brief AtkAction interface initializer
250 * @param iface AtkActionIface instance
253 atk_action_interface_init(AtkActionIface *iface)
255 g_return_if_fail(iface != NULL);
257 iface->do_action = eail_hover_action_do_action;
258 iface->get_n_actions = eail_hover_action_get_n_actions;
259 iface->get_description = eail_hover_action_get_description;
260 iface->get_name = eail_hover_action_get_name;
261 iface->set_description = eail_hover_action_set_description;