Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_scroller.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_scroller.c
22  * @brief EailScroller implementation
23  */
24
25 #include <Eina.h>
26 #include <Evas.h>
27 #include <Elementary.h>
28 #include "eail_scroller.h"
29
30 /**
31  * @brief Definition of EailScroller as GObject
32  *
33  * EailScroller is extended EAIL_TYPE_SCROLLABLE_WIDGET
34  */
35 G_DEFINE_TYPE(EailScroller, eail_scroller, EAIL_TYPE_SCROLLABLE_WIDGET);
36
37 /**
38  * @brief Initializer for AtkObjectClass
39  *
40  * @param obj AtkObject instance
41  * @param data initialization data
42  */
43 static void
44 eail_scroller_initialize(AtkObject *obj, gpointer data)
45 {
46     ATK_OBJECT_CLASS(eail_scroller_parent_class)->initialize(obj, data);
47
48     obj->role = ATK_ROLE_SCROLL_PANE;
49 }
50
51 /**
52  * @brief Prepares Eina_List filled with Evas_Object* objects
53  * representing content of the widget
54  *
55  * Call eina_list_free on the returned list when results processing has been finished.
56  *
57  * @param widget EailWidget instance
58  *
59  * @return Eina_List representing the list of the widget's children
60  */
61 static Eina_List *
62 eail_scroller_get_widget_children(EailWidget *widget)
63 {
64     Eina_List *list = NULL;
65     Evas_Object *content;
66     Evas_Object *obj = eail_widget_get_widget(EAIL_WIDGET(widget));
67
68     if(obj) {
69         content = elm_object_part_content_get(obj, "default");
70         if(content)
71             list = eina_list_append(list, content);
72     }
73
74     return list;
75 }
76
77 /**
78  * @brief Gets the accessible name of the accessible
79  *
80  * Implementation of AtkObject->get_name callback.
81  *
82  * @param obj AtkObject instance
83  *
84  * @returns string representing the accessible name of
85  * the accessible
86  */
87 static const gchar*
88 eail_scroller_get_name(AtkObject *obj)
89 {
90     const gchar *name;
91     Evas_Object *widget = NULL;
92
93     name = ATK_OBJECT_CLASS(eail_scroller_parent_class)->get_name(obj);
94     if(name != NULL)
95         return name;
96
97     widget = eail_widget_get_widget(EAIL_WIDGET(obj));
98     if(widget)
99         name = (const gchar*)elm_object_text_get(widget);
100
101     return name;
102 }
103
104 /**
105  * @brief EailFileselector GObject instance initializer
106  *
107  * @param scroller EailScroller instance
108  */
109 static void
110 eail_scroller_init(EailScroller *scroller)
111 {
112 }
113
114 /**
115  * @brief Initializer for EailScroller GObject class
116  *
117  * Defines callbacks for base AtkObject.
118  *
119  * @param klass EailScrollerClass instance
120  */
121 static void
122 eail_scroller_class_init(EailScrollerClass *klass)
123 {
124     AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
125     EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
126
127     widget_class->get_widget_children = eail_scroller_get_widget_children;
128
129     atk_class->initialize = eail_scroller_initialize;
130     atk_class->get_name = eail_scroller_get_name;
131 }