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 Elementary application implementation
25 #include <Elementary.h>
28 #include "eail_factory.h"
29 #include "eail_dynamic_content.h"
30 #include "eail_utils.h"
31 #include "eail_priv.h"
33 /** @brief This is defined and filled in elementary.*/
34 extern Eina_List *_elm_win_list;
36 static void eail_dynamic_content_interface_init(EailDynamicContentIface *iface);
39 * @brief Definition of EailApp as GObject
41 * EailApp is extended ATK_TYPE_OBJECT with EAIL_TYPE_DYNAMIC_CONTENT iface
45 G_DEFINE_TYPE_WITH_CODE(EailApp, eail_app, ATK_TYPE_OBJECT,
46 G_IMPLEMENT_INTERFACE(EAIL_TYPE_DYNAMIC_CONTENT,
47 eail_dynamic_content_interface_init));
50 * @brief Initializer for AtkObjectClass
52 * @param obj AtkObject instance to be initialized
53 * @param data additional initialization data (Evas_Object*)
56 eail_app_initialize(AtkObject *obj, gpointer data)
60 EailApp *eail_app = NULL;
62 ATK_OBJECT_CLASS(eail_app_parent_class)->initialize(obj, data);
64 ecore_app_args_get(&argc, &argv);
65 obj->name = argv ? g_strdup((gchar *)ecore_file_file_get(argv[0])) : NULL;
66 obj->role = ATK_ROLE_APPLICATION;
67 obj->accessible_parent = NULL;
69 /* storing last numbers of children to be for checking if children-changed
70 * signal has to be propagated */
71 eail_app = EAIL_APP(obj);
72 eail_app->child_count_last = atk_object_get_n_accessible_children(obj);
76 * @brief Destructor for EailApp object
77 * @param obj GObject to be freed
80 eail_app_class_finalize(GObject *obj)
82 G_OBJECT_CLASS(eail_app_parent_class)->finalize(obj);
86 * @brief Gets the number of accessible children of the accessible
88 * Implementation of AtkObject->get_n_children callback.
90 * @param obj AtkObject instance
92 * @returns integer representing the number of accessible children of
96 eail_app_get_n_children(AtkObject *obj)
98 return eina_list_count(_elm_win_list);
102 * @brief Gets a reference to the specified accessible child of the object.
104 * The accessible children are 0-based so the first accessible child is at index 0,
105 * the second at index 1 and so on.
107 * Implementation of AtkObject->ref_child callback.
109 * @param obj AtkObject instance
110 * @param i index number
112 * @returns AtkObject representing the specified accessible child of the
116 eail_app_ref_child(AtkObject *obj, gint i)
118 AtkObject *child = NULL;
120 if (eina_list_count(_elm_win_list) > i)
122 Evas_Object *tmp = eina_list_nth(_elm_win_list, i);
123 child = eail_factory_get_accessible(tmp);
131 * @brief Initializer for GObject class
132 * @param app EailApp instance to be initialized
135 eail_app_init(EailApp *app)
140 * @brief Initializer for GObject EailAppClass class
142 * Defines callbacks for base AtkObject.
144 * @param klass EailAppClass instance to be filled
147 eail_app_class_init(EailAppClass *klass)
149 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
150 GObjectClass *g_object_class = G_OBJECT_CLASS(klass);
152 atk_class->initialize = eail_app_initialize;
153 atk_class->get_n_children = eail_app_get_n_children;
154 atk_class->ref_child = eail_app_ref_child;
156 g_object_class->finalize = eail_app_class_finalize;
160 * @param dynamic_content_holder an EailDynamicContent object (EailApp)
163 eail_app_update_descendants(EailDynamicContent *dynamic_content_holder)
168 if (!EAIL_IS_APP(dynamic_content_holder))
170 DBG("No EailApp found. Returning");
174 app = EAIL_APP(dynamic_content_holder);
176 n_children = atk_object_get_n_accessible_children(ATK_OBJECT(app));
177 if (n_children && n_children > app->child_count_last)
179 DBG("emit changed add");
180 eail_emit_children_changed(TRUE, ATK_OBJECT(app), n_children - 1);
182 else if (n_children < app->child_count_last)
184 DBG("emit changed remove");
185 eail_emit_children_changed
186 (FALSE, ATK_OBJECT(app), app->child_count_last);
189 app->child_count_last = n_children;
193 * @brief Initializer for dynamic content interface, used for handling objects
194 * children hierarchy changes
196 * @param iface an EailDynamicContentIface
199 eail_dynamic_content_interface_init(EailDynamicContentIface *iface)
201 iface->update_hierarchy = eail_app_update_descendants;