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 Implementation of EailBubble
25 #include <Elementary.h>
27 #include "eail_bubble.h"
29 static void atk_action_interface_init(AtkActionIface *iface);
32 * @brief Definition of EailBubble type
34 G_DEFINE_TYPE_WITH_CODE(EailBubble,
37 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
38 atk_action_interface_init));
41 * Implementation of the *AtkObject* interface
45 * @brief EailBubble object initialization
47 * @param obj EailBubble object
48 * @param data user set additional initialization data
51 eail_bubble_initialize(AtkObject *obj, gpointer data)
53 ATK_OBJECT_CLASS(eail_bubble_parent_class)->initialize(obj, data);
55 obj->role = ATK_ROLE_FILLER;
59 * @brief Class destructor
61 * @param object object instance
64 eail_bubble_finalize(GObject *object)
66 EailBubble *bubble = EAIL_BUBBLE(object);
68 if (bubble->click_description) free(bubble->click_description);
70 G_OBJECT_CLASS(eail_bubble_parent_class)->finalize(object);
74 * @brief EailBubble instance initialization
76 * @param bubble EailBubble instance
79 eail_bubble_init(EailBubble *bubble)
81 bubble->click_description = NULL;
85 * @brief Gets list of child widget
87 * @param widget EailWidget object
89 * @return list of child, NULL if no children
92 eail_bubble_get_widget_children(EailWidget *widget)
94 Eina_List *list = NULL;
95 Evas_Object *child, *obj;
97 obj = eail_widget_get_widget(EAIL_WIDGET(widget));
101 child = elm_object_part_content_get(obj, "default");
102 if (child && elm_object_widget_check(child))
103 list = eina_list_append(list, child);
105 child = elm_object_part_content_get(obj, "icon");
106 if (child && elm_object_widget_check(child))
107 list = eina_list_append(list, child);
114 * @brief GObject type initialization function
116 * @param klass EailBubble class
119 eail_bubble_class_init(EailBubbleClass *klass)
121 AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
122 EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
123 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
125 class->initialize = eail_bubble_initialize;
126 widget_class->get_widget_children = eail_bubble_get_widget_children;
127 gobject_class->finalize = eail_bubble_finalize;
131 * Implementation of the *AtkAction* interface
135 * @brief Implementation of get_n_actions from AtkAction interface
137 * @param action EailBubble instance
139 * @returns number of actions
142 eail_bubble_n_actions_get(AtkAction *action)
148 * @brief Implementation of get_description from AtkAction interface
150 * @param action EailBubble instance
151 * @param i action index
153 * @return action description
156 eail_bubble_description_get(AtkAction *action,
160 const char *action_description;
162 bubble = EAIL_BUBBLE(action);
163 if (!bubble) return NULL;
168 action_description = bubble->click_description;
171 action_description = NULL;
175 return action_description;
179 * @brief Implementation of set_descritpion from AtkAction interface
181 * @param action EailBubble instance
182 * @param i action index
183 * @param description action description
185 * @return TRUE on success, FALSE otherwise
188 eail_bubble_description_set(AtkAction *action,
190 const char *description)
195 bubble = EAIL_BUBBLE(action);
196 if (!bubble) return FALSE;
201 value = &bubble->click_description;
211 *value = g_strdup(description);
219 * @brief Implementation of get_name from AtkAction interface
221 * @param action EailBubble instance
222 * @param i action index
224 * @return action name
227 eail_bubble_action_name_get(AtkAction *action,
230 const char* action_name;
235 action_name = "click";
246 * @brief Implementation of do_action from AtkAction interface
248 * @param action EailBubble instance
249 * @param i action index
251 * @return TRUE on success, FALSE otherwise
254 eail_bubble_do_action(AtkAction *action,
259 widget = eail_widget_get_widget(EAIL_WIDGET(action));
260 if (!widget) return FALSE;
262 if ((elm_object_disabled_get(widget)) || (!evas_object_visible_get(widget)))
265 const char *action_name = atk_action_get_name(action, i);
266 if (!action_name) return FALSE;
268 evas_object_smart_callback_call(widget, "clicked", NULL);
274 * @brief AtkAction interface initializer
276 * @param iface action interface to be filled
279 atk_action_interface_init(AtkActionIface *iface)
281 g_return_if_fail(iface != NULL);
283 iface->get_n_actions = eail_bubble_n_actions_get;
284 iface->get_description = eail_bubble_description_get;
285 iface->set_description = eail_bubble_description_set;
286 iface->get_name = eail_bubble_action_name_get;
287 iface->do_action = eail_bubble_do_action;