120776b00213133da17101ee37cdcba011f7ef70
[platform/core/uifw/eail.git] / eail / eail / eail_notify.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_notify.c
22  * @brief Implementation of notify widget
23  */
24
25 #include <atk/atk.h>
26 #include <Elementary.h>
27
28 #include "eail_notify.h"
29 #include "eail_factory.h"
30 #include "eail_priv.h"
31
32 /**
33  * @brief Definition of EailPopup as GObject
34  *
35  * EailNotify is extended EAIL_TYPE_WIDGET
36  */
37 G_DEFINE_TYPE(EailNotify, eail_notify, EAIL_TYPE_WIDGET);
38
39
40 /**
41  * @brief Initializer for AtkObject
42  *
43  * @param obj an AtkObject
44  * @param data initialization data
45  */
46 static void
47 eail_notify_initialize(AtkObject *obj, gpointer data)
48 {
49    ATK_OBJECT_CLASS(eail_notify_parent_class) ->initialize(obj, data);
50    obj->role = ATK_ROLE_NOTIFICATION;
51 }
52
53 /**
54  * @brief Initializer for GObject EailNotify instance
55  *
56  * @param button an EailNotify
57  */
58 static void
59 eail_notify_init(EailNotify *button)
60 {
61
62 }
63
64 /**
65  * @brief Helper function for getting nested content in notify widget
66  *
67  * @param obj an AtkObject
68  *
69  * @returns nested widget content from notify widget
70  */
71 static Evas_Object *
72 _eail_get_nested_widget(AtkObject *obj)
73 {
74    Evas_Object *notify_widget = NULL, *nested_widget = NULL;
75    /* getting widget of notify class */
76    notify_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
77    if (!notify_widget)
78      {
79         ERR("No widget found for notification object!");
80      }
81
82    nested_widget = elm_object_part_content_get(notify_widget, "default");
83
84    return nested_widget;
85 }
86
87 /**
88  * @brief Implementation AtkObject->get_n_children callback
89  *
90  * ATK doc says:\n
91  * Gets the number of accessible children of the accessible.
92  * @param obj an AtkObject
93  *
94  * @returns an integer representing the number of accessible children of
95  * the accessible
96  */
97 static gint
98 eail_notify_get_n_children(AtkObject *obj)
99 {
100    Evas_Object *nested_widget = NULL;
101
102    nested_widget = _eail_get_nested_widget(obj);
103    if (nested_widget)
104      return 1;
105
106    return 0;
107 }
108
109 /**
110  * @brief Implementation AtkObject->ref_child callback
111  *
112  * ATK doc says:\n
113  * Gets a reference to the specified accessible child of the object. The
114  * accessible children are 0-based so the first accessible child is at index 0,
115  * the second at index 1 and so on.
116  *
117  * @param obj an AtkObject
118  * @param i index of child to ref
119  *
120  * @returns an AtkObject representing the specified accessible child of the
121  * accessible.
122  */
123 static AtkObject *
124 eail_notify_ref_child(AtkObject *obj, gint i)
125 {
126    Evas_Object *nested_widget = NULL;
127    AtkObject *atk_obj;
128
129    nested_widget = _eail_get_nested_widget(obj);
130    atk_obj = eail_factory_get_accessible(nested_widget);
131
132    if (atk_obj)
133      g_object_ref(atk_obj);
134
135    return atk_obj;
136 }
137
138 /**
139  * @brief Destructor for EailNotify object
140  *
141  * @param object GObject instance to be finalized
142  */
143 static void
144 eail_notify_finalize(GObject *object)
145 {
146    G_OBJECT_CLASS(eail_notify_parent_class)->finalize(object);
147 }
148
149 /**
150  * @brief Initializer for EailNotify GObject class (defines callbacks for
151  * base AtkObject)
152  *
153  * @param klass an EailNotify class
154  */
155 static void
156 eail_notify_class_init(EailNotifyClass *klass)
157 {
158    AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
159    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
160    class->initialize = eail_notify_initialize;
161    class->get_n_children = eail_notify_get_n_children;
162    class->ref_child = eail_notify_ref_child;
163    gobject_class->finalize = eail_notify_finalize;
164
165
166 }