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 EailPlug implementation
25 #include <Elementary.h>
27 #include "eail_plug.h"
29 static void atk_action_interface_init(AtkActionIface *iface);
32 * @brief Definition of EailPlug as GObject
34 * EailPlug is extended EailWidget with AtkAction interface implemented
36 G_DEFINE_TYPE_WITH_CODE(EailPlug,
39 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
40 atk_action_interface_init));
43 * Implementation of the *AtkObject* interface
47 * @brief EailPlug object initialization
49 * @param obj AtkObject instance
50 * @param data user set additional initialization data
53 eail_plug_initialize(AtkObject *obj, gpointer data)
55 ATK_OBJECT_CLASS(eail_plug_parent_class)->initialize(obj, data);
57 obj->role = ATK_ROLE_IMAGE;
61 * @brief Class destructor
63 * @param object GObject instance
66 eail_plug_finalize(GObject *object)
68 EailPlug *plug = EAIL_PLUG(object);
70 if (plug->click_description) free(plug->click_description);
72 G_OBJECT_CLASS(eail_plug_parent_class)->finalize(object);
76 * @brief EailPlug instance initialization
78 * @param plug EailPlug instance
81 eail_plug_init(EailPlug *plug)
83 plug->click_description = NULL;
87 * @brief GObject type initialization function
89 * @param klass EailPlugClass instance
92 eail_plug_class_init(EailPlugClass *klass)
94 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
95 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
97 atk_class->initialize = eail_plug_initialize;
98 gobject_class->finalize = eail_plug_finalize;
102 * Implementation of the *AtkAction* interface
106 * @brief Gets the number of accessible actions available on the object
108 * If there are more than one, the first one is considered
109 * the "default" action of the object.
111 * Implementation of get_n_actions from AtkAction interface.
113 * @param action AtkAction instance
115 * @returns integer representing the number of actions supported by EailPlug
118 eail_plug_n_actions_get(AtkAction *action)
124 * @brief Gets the description of specified action of the object
126 * Implementation of get_description from AtkAction interface.
128 * @param action AtkAction instance
129 * @param i action index
131 * @return string representing the description of the specified action
134 eail_plug_description_get(AtkAction *action,
137 const char *action_description;
138 EailPlug *plug = EAIL_PLUG(action);
143 action_description = plug->click_description;
146 action_description = NULL;
150 return action_description;
154 * @brief Sets a description of the specified action of the object
156 * Implementation of set_description from AtkAction interface.
158 * @param action AtkAction instance
159 * @param i action index
160 * @param description action description
162 * @return TRUE on success, FALSE otherwise
165 eail_plug_description_set(AtkAction *action,
167 const char *description)
169 EailPlug *plug = EAIL_PLUG(action);
175 value = &plug->click_description;
185 *value = g_strdup(description);
193 * @brief Gets the name of the specified action of the object
195 * Implementation of get_name from AtkAction interface.
197 * @param action AtkAction instance
198 * @param i action index
200 * @return string representing the name of the specified action
203 eail_plug_action_name_get(AtkAction *action,
206 const char* action_name;
211 action_name = "click";
222 * @brief Performs the specified action on the object
224 * Implementation of do_action from AtkAction interface.
226 * @param action AtkAction instance
227 * @param i action index
229 * @return TRUE on success, FALSE otherwise
232 eail_plug_do_action(AtkAction *action,
235 const char *action_name;
238 widget = eail_widget_get_widget(EAIL_WIDGET(action));
239 if (!widget) return FALSE;
241 if ((elm_object_disabled_get(widget)) || (!evas_object_visible_get(widget)))
244 action_name = atk_action_get_name(action, i);
245 if (!action_name) return FALSE;
247 if (!g_strcmp0(action_name, "click"))
248 evas_object_smart_callback_call(widget, "clicked", NULL);
256 * @brief AtkAction interface initializer
258 * @param iface AtkAction interface
261 atk_action_interface_init(AtkActionIface *iface)
263 g_return_if_fail(iface != NULL);
265 iface->get_n_actions = eail_plug_n_actions_get;
266 iface->get_description = eail_plug_description_get;
267 iface->set_description = eail_plug_description_set;
268 iface->get_name = eail_plug_action_name_get;
269 iface->do_action = eail_plug_do_action;