Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_prefs.c
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 /**
21  * @file eail_prefs.c
22  * @brief EailPrefs implementation
23  */
24
25 #include <Elementary.h>
26
27 #include "eail_prefs.h"
28 #include "eail_factory.h"
29 #include "eail_priv.h"
30
31 /**
32  * @brief EailPrefs GObject type definition
33  *
34  * EailPrefs is extended EAIL_TYPE_WIDGET
35  */
36 G_DEFINE_TYPE(EailPrefs, eail_prefs, EAIL_TYPE_WIDGET);
37
38 /**
39  * @brief EailPrefs initializer
40  *
41  * @param obj AtkObject instance
42  * @param data initialization data
43  */
44 static void
45 eail_prefs_initialize(AtkObject *obj, gpointer data)
46 {
47    ATK_OBJECT_CLASS(eail_prefs_parent_class)->initialize(obj, data);
48    obj->role = ATK_ROLE_REDUNDANT_OBJECT;
49 }
50
51 /**
52  * @brief EailPrefs instance initializer
53  *
54  * @param prefs EailPrefs instance
55  */
56 static void
57 eail_prefs_init(EailPrefs *prefs)
58 {
59 }
60
61 /**
62  * @brief Gets the list of children of the prefs object
63  *
64  * @param parent parent widget
65  * @param [out] items list of object's children
66  */
67 static void eail_prefs_children_get(Evas_Object *parent,
68                                     Eina_List **items)
69 {
70    Eina_List *list;
71    Evas_Object *w;
72    int n;
73
74    list = evas_object_smart_members_get(parent);
75    if (!list) return;
76
77    for (n = 0; n < eina_list_count(list); ++n)
78      {
79         w = eina_list_nth(list, n);
80         if (elm_object_widget_check(w))
81           {
82              *items = eina_list_append(*items, w);
83           }
84
85         eail_prefs_children_get(w, items);
86      }
87
88    eina_list_free(list);
89 }
90
91 /**
92  * @brief Gets the list of children for the specified widget
93  *
94  * @param widget EailWidget instance
95  *
96  * @returns Eina_List representing the widget's children
97  * or NULL if the widget's has no children
98  */
99 static Eina_List *
100 eail_prefs_get_widget_children(EailWidget *widget)
101 {
102     Evas_Object *w;
103     Eina_List *list = NULL;
104
105     g_return_val_if_fail(EAIL_IS_PREFS(widget), NULL);
106
107     w = eail_widget_get_widget(widget);
108     if (!widget) return NULL;
109
110     eail_prefs_children_get(w, &list);
111
112     return list;
113 }
114
115 /**
116  * @brief EailPrefs class initializer
117  *
118  * Definition of basic callbacks for AtkObject.
119  *
120  * @param klass EailPrefsClass instance
121  */
122 static void
123 eail_prefs_class_init(EailPrefsClass *klass)
124 {
125    AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
126    EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
127
128    atk_class->initialize = eail_prefs_initialize;
129    widget_class->get_widget_children = eail_prefs_get_widget_children;
130 }
131