Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_table.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_table.c
22  * @brief EailTable implementation
23  */
24 #include <Elementary.h>
25
26 #include "eail_table.h"
27
28 /**
29  * @brief Smart type used by elm_table to get internal content of the widget
30  */
31 #define TABLE_SMART_TYPE "Evas_Object_Table"
32
33 /**
34  * @brief GObject definition of EailTable
35  *
36  * EailTable is extended EailWidget
37  * */
38 G_DEFINE_TYPE(EailTable, eail_table, EAIL_TYPE_WIDGET);
39
40 /**
41  * @brief Initialize EailTable
42  *
43  * Initialization of parent object, role etc.
44  *
45  * @param object AtkObject instance
46  * @param data user data passed to initialize
47  */
48 static void
49 eail_table_initialize(AtkObject *object, gpointer data)
50 {
51    ATK_OBJECT_CLASS(eail_table_parent_class)->initialize(object, data);
52
53    object->role = ATK_ROLE_FILLER;
54 }
55
56 /**
57  * @brief EailTable initialization
58  *
59  * @param table EailTable instance
60  */
61 static void
62 eail_table_init(EailTable *table)
63 {
64 }
65
66 /**
67  * @brief Gets a list of accessible children of widget
68  *
69  * Implementation of get_widget_children from EailWidget.
70  *
71  * @param widget EailTable instance
72  *
73  * @returns Eina_List representing the list of widget's children
74  */
75 static Eina_List *
76 eail_table_children_get(EailWidget *widget)
77 {
78    Evas_Object *table, *object;
79    Eina_List *smart_members;
80
81    g_return_val_if_fail(EAIL_IS_TABLE(widget), NULL);
82
83    object = eail_widget_get_widget(widget);
84
85    if (!object) return NULL;
86
87    smart_members = evas_object_smart_members_get(object);
88    /*table has one smart member it is Evas_Object_Table*/
89    table = eina_list_nth(smart_members, 0);
90    eina_list_free(smart_members);
91
92    if (evas_object_smart_type_check(table, TABLE_SMART_TYPE))
93      {
94         return evas_object_table_children_get(table);
95      }
96
97    return NULL;
98 }
99
100 /**
101  * @brief EailTable class initialization
102  *
103  * @param klass EailTableClass instance
104  */
105 static void
106 eail_table_class_init(EailTableClass *klass)
107 {
108    AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
109    EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
110
111    widget_class->get_widget_children = eail_table_children_get;
112
113    atk_class->initialize = eail_table_initialize;
114 }
115