Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_web.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_web.c
22  * @brief EailWeb implementation
23  */
24
25 #include <atk/atk.h>
26 #include <Elementary.h>
27
28 #include "eail_web.h"
29 #include "eail_priv.h"
30
31 /**
32  * @brief EailWeb GObject definition
33  *
34  * It extends EAIL_TYPE_WIDGET class
35  */
36 G_DEFINE_TYPE(EailWeb, eail_web, EAIL_TYPE_WIDGET);
37
38 /**
39  * @brief Initializer for AtkObject
40  *
41  * @param obj AtkObject instance
42  * @param data initializer data
43  */
44 static void
45 eail_web_initialize(AtkObject *obj, gpointer data)
46 {
47    ATK_OBJECT_CLASS(eail_web_parent_class) ->initialize(obj, data);
48    obj->role = ATK_ROLE_HTML_CONTAINER;
49 }
50
51 /**
52  * @brief EailWeb instance initializer
53  *
54  * @param web EailWeb instance
55  */
56 static void
57 eail_web_init(EailWeb *web)
58 {
59
60 }
61
62 /**
63  * @brief Gets the number of accessible children of the accessible
64  *
65  * Implementation of AtkObject->get_n_children callback.
66  *
67  * @param obj AtkObject instance
68  *
69  * @returns integer representing the number of accessible children of
70  * the accessible
71  */
72 static gint
73 eail_web_get_n_children(AtkObject *obj)
74 {
75    /* impossible to get content so returning 0 */
76    return 0;
77 }
78
79 /**
80  * @brief Gets a reference to the specified accessible child of the object.
81  *
82  * The accessible children are 0-based so the first accessible child is at index 0,
83  * the second at index 1 and so on.
84  *
85  * Implementation of AtkObject->ref_child callback
86  *
87  * @param obj AtkObject instance
88  * @param i index of a child
89  *
90  * @returns AtkObject representing the specified accessible child of the
91  * accessible
92  */
93 static AtkObject *
94 eail_web_ref_child(AtkObject *obj, gint i)
95 {
96    /* impossible to get content so returning NULL */
97    return NULL;
98 }
99
100 /**
101  * @brief Destructor of EailWeb object
102  *
103  * @param object GObject instance
104  */
105 static void
106 eail_web_finalize(GObject *object)
107 {
108    G_OBJECT_CLASS(eail_web_parent_class)->finalize(object);
109 }
110
111 /**
112  * @brief Gets the accessible name of the accessible
113  *
114  * Implementation of get_name from AtkObject.
115  *
116  * @param object AtkObject instance
117  * @returns a string representing the first attribute from the
118  * following list which is not null:
119  * accessible name, uri, title, or NULL if all strings were NULL
120  */
121 static const gchar*
122 eail_web_get_name(AtkObject *object)
123 {
124    Evas_Object *web;
125    const gchar *atk_name = NULL;
126
127    g_return_val_if_fail(EAIL_IS_WEB(object), NULL);
128
129    atk_name = ATK_OBJECT_CLASS(eail_web_parent_class)->get_name(object);
130    if (atk_name) return atk_name;
131
132    web = eail_widget_get_widget(EAIL_WIDGET(object));
133    if (!web) return NULL;
134
135    atk_name = elm_web_url_get(web);
136    if (atk_name) return atk_name;
137
138    atk_name = elm_web_title_get(web);
139    if (atk_name) return atk_name;
140
141    return atk_name;
142 }
143
144 /**
145  * @brief Initializer for EailWeb GObject class
146  *
147  * Defines callbacks for base AtkObject.
148  *
149  * @param klass EailWebClass instance
150  */
151 static void
152 eail_web_class_init(EailWebClass *klass)
153 {
154    AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
155    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
156    class->initialize = eail_web_initialize;
157    class->get_name = eail_web_get_name;
158    class->get_n_children = eail_web_get_n_children;
159    class->ref_child = eail_web_ref_child;
160    gobject_class->finalize = eail_web_finalize;
161 }