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 an AtkObject
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 object and allocated resources.
59 * @param obj a GObject
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 an EailHover
77 eail_hover_init(EailHover *hover)
79 hover->click_description = NULL;
83 * @brief EailHover class initializer.
85 * @param klass an EailHoverClass
88 eail_hover_class_init(EailHoverClass *klass)
90 AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
91 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
93 class->initialize = eail_hover_initialize;
95 gobject_class->finalize = eail_hover_finalize;
99 * @brief Performs i-th action.
101 * @param action an AtkAction
102 * @param i the action index corresponding to the 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 * @param action an AtkAction
130 * @return actions number
133 eail_hover_action_get_n_actions(AtkAction *action)
139 * @brief Gets i-th action description.
141 * @param action an AtkAction
142 * @param i action number
143 * @return action description string
146 eail_hover_action_get_description(AtkAction *action,
149 const char *action_description = NULL;
152 hover = EAIL_HOVER(action);
153 if (!hover) return NULL;
158 action_description = hover->click_description;
162 action_description = NULL;
166 return action_description;
170 * @brief Gets i-th action name.
172 * @param action an AtkAction
173 * @param i action number
174 * @return action description string
177 eail_hover_action_get_name(AtkAction *action,
180 const char* action_name = NULL;
185 action_name = "click";
197 * @brief Sets i-th action description.
199 * @param action an AtkAction
200 * @param i action number
201 * @param desc action description
202 * @return TRUE if description is set successfully, FALSE otherwise
205 eail_hover_action_set_description(AtkAction *action,
209 EailHover *hover = NULL;
212 hover = EAIL_HOVER(action);
213 if (!hover) return FALSE;
218 value = &hover->click_description;
229 *value = g_strdup(desc);
238 * @brief AtkAction interface initializer
240 * @param iface an AtkActionIface
243 atk_action_interface_init(AtkActionIface *iface)
245 g_return_if_fail(iface != NULL);
247 iface->do_action = eail_hover_action_do_action;
248 iface->get_n_actions = eail_hover_action_get_n_actions;
249 iface->get_description = eail_hover_action_get_description;
250 iface->get_name = eail_hover_action_get_name;
251 iface->set_description = eail_hover_action_set_description;