2 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
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.
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.
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.
21 * @file eail_dayselector.c
22 * @brief EailDayselector implementation
25 #include <Elementary.h>
27 #include "eail_dayselector.h"
28 #include "eail_check.h"
30 /** @brief Number of days displayed in dayselector widget */
31 #define EAIL_DAYSELECTOR_NUM_OF_DAYS 7
32 /** @brief Content part name definition for dayselector widget */
33 #define EAIL_CONTENT_PART_FORMAT "day%d"
36 * @brief GObject definition for EailDayselector widget
38 * It extends EAIL_TYPE_WIDGET
40 G_DEFINE_TYPE(EailDayselector, eail_dayselector, EAIL_TYPE_WIDGET);
43 * @brief Initializer for AtkObjectClass
45 * @param obj AtkObject instance
46 * @param data initialization data
49 eail_dayselector_initialize(AtkObject *obj, gpointer data)
51 ATK_OBJECT_CLASS(eail_dayselector_parent_class)->initialize(obj, data);
52 obj->role = ATK_ROLE_PANEL;
56 * @brief GObject-initializer for EailDayselector
58 * @param button EailDayselector instance
61 eail_dayselector_init(EailDayselector *button)
66 * @brief Gets the number of accessible children of the accessible.
68 * Implementation of AtkObject->get_n_children callback.
70 * @param obj AtkObject instance
72 * @returns integer representing the number of accessible children of
76 eail_dayselector_get_n_children(AtkObject *obj)
78 return EAIL_DAYSELECTOR_NUM_OF_DAYS;
82 * @brief Helper function for generating content string name for given day number
83 * @param day_num integer which represents a particular day of the week
85 * @returns Eina_Strbuf object filled with content day-name
88 _eail_dayselector_gen_day_str(int day_num)
90 Eina_Strbuf *str_buf = NULL;
92 str_buf = eina_strbuf_new();
93 eina_strbuf_append_printf(str_buf, EAIL_CONTENT_PART_FORMAT, day_num);
99 * @brief Helper function for creating the content of dayselector's child
101 * Unref it when it is no longer needed.
103 * @param day_check_widget check widget that represents a day in dayselector
106 * @returns AtkObject representing a given day in dayselector.
109 _eail_create_dayselector_child(Evas_Object *day_check_widget)
111 AtkObject *child = NULL;
112 child = g_object_new(EAIL_TYPE_CHECK, NULL);
113 atk_object_initialize(child, day_check_widget);
120 * @brief Gets a reference to the specified accessible child of the object.
122 * The accessible children are 0-based so the first accessible child is at index 0,
123 * the second at index 1 and so on.
125 * Implementation of AtkObject->ref_child callback.
127 * @param obj AtkObject instance
128 * @param i child index
130 * @returns AtkObject representing the specified accessible child of the
134 eail_dayselector_ref_child(AtkObject *obj, gint i)
136 AtkObject *child = NULL;
137 Eina_Strbuf *part_name = NULL;
138 Evas_Object *ds_widget = NULL, *day_check = NULL;
140 g_return_val_if_fail (EAIL_IS_WIDGET(obj), NULL);
142 ds_widget = eail_widget_get_widget(EAIL_WIDGET(obj) );
143 part_name = _eail_dayselector_gen_day_str(i);
144 day_check = elm_object_part_content_get
145 (ds_widget, eina_strbuf_string_get(part_name));
147 /* dayselector consists of objects with type CHECK-widget */
148 child = _eail_create_dayselector_child(day_check);
150 eina_strbuf_free(part_name);
155 * @brief Destructor for GObject Dayselector implementation
157 * @param object GObject object to be finalized
160 eail_dayselector_finalize(GObject *object)
162 G_OBJECT_CLASS(eail_dayselector_parent_class)->finalize(object);
166 * @brief Initializer for GObject EailDayselectorClass class
168 * Defines callbacks for base AtkObject.
170 * @param klass EailDayselectorClass instance
173 eail_dayselector_class_init(EailDayselectorClass *klass)
175 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
176 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
177 atk_class->initialize = eail_dayselector_initialize;
178 atk_class->get_n_children = eail_dayselector_get_n_children;
179 atk_class->ref_child = eail_dayselector_ref_child;
180 gobject_class->finalize = eail_dayselector_finalize;