2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "timer_lib.h"
22 #include "timer_utils.h"
23 /**********************************************************************
24 ******************Global val , static global val*************************************
25 ***********************************************************************/
26 static struct appdata *g_ad;
29 * Create navigationbar for lib
31 * @param[in] parent parent for new navigationbar
33 * @return NULL if meet error
34 * Pointer to new navigationbar
36 static Evas_Object *__timer_create_navigation_layout(Evas_Object * parent)
39 Evas_Object *navi_bar;
41 retv_if(NULL == parent, NULL);
44 navi_bar = elm_naviframe_add(parent);
47 evas_object_show(navi_bar);
53 static void timer_view_back_btn_cb(void *data, Evas_Object * obj,
57 Evas_Object *win = (Evas_Object *) data;
61 /**********************************************************************
62 ******************Global function ref*************************************
63 ***********************************************************************/
66 * Debug function: to create and show view of timer.
67 * It will be called by Clock application and the standalone timer application.
68 * This function requires parent and cb as parameters
71 * @param[in] parent Pointer to the parent in which the new add layout will be placed
72 * @param[in] cb a Eina_Bool value to indicate whether the controlbar should be displayed
74 * @return Evas_Object*, the new created layout
76 EAPI Evas_Object *timer_view_add(Evas_Object * parent, Evas_Object * win,
77 timer_controlbar_visible cb)
80 Evas_Object *ret = NULL;
81 CLK_GOTO_IF_RUN(g_ad, End, ret = g_ad->layout_main, "g_ad is not null");
82 struct appdata *ad = CALLOC(1, struct appdata);
83 CLK_GOTO_IF_RUN(!ad, End, ret = NULL, "ad null");
86 ad->view_setting = CALLOC(1, setting_view);
87 CLK_GOTO_IF_RUN(!ad->view_setting, End, ret =
88 NULL, "ad->view_setting null");
90 ad->view_motion = CALLOC(1, motion_view);
91 CLK_GOTO_IF_RUN(!ad->view_motion, End, ret =
92 NULL, "ad->view_motion null");
93 /* init internationalization */
94 bindtextdomain(PACKAGE, LOCALEDIR);
98 ad->navi_bar = __timer_create_navigation_layout(parent);
99 ad->controlbar_cb = cb;
101 ad->timer_interval = 0.9;
102 /*ad->evas = evas_object_evas_get(ad->win_main); */
104 ad->layout_main = widget_create_layout_empty(parent);
105 ad->layout = load_edj(ad->layout_main, EDJ_NAME, GRP_MAIN);
106 CLK_GOTO_IF_RUN(!ad->layout, End, ret = NULL, "ad->layout null");
107 elm_object_part_content_set(ad->layout_main,
108 STRING_TIMER_ELM_SWALLOW_CONTENT,
110 ad->eo_effect = load_edj(ad->layout, EDJ_NAME, STRING_TIMER_EFFECT);
111 elm_object_part_content_set(ad->layout,
112 STRING_TIMER_ELM_SWALLOW_CONTENT,
115 nErr = alarmmgr_init(PKGNAME);
116 CLK_GOTO_IF_RUN(nErr != SUCCESS, End, ret =
117 NULL, "alarmmgr_init error");
118 nErr = alarmdb_init(NULL);
119 CLK_GOTO_IF_RUN(nErr != SUCCESS, End, ret = NULL, "alarmdb_init error");
121 ad->page = timer_utils_read_alarm_state(ad);
122 if (IS_EQUAL(ad->page, TIMER_VIEW_PAGE_MOTION)) {
123 timer_view_motion.create(ad);
124 elm_object_part_content_set(ad->eo_effect,
125 STRING_TIMER_ELM_SWALLOW_CENTER,
126 ad->view_motion->eo_content);
128 timer_view_setting.create(ad);
129 elm_object_part_content_set(ad->eo_effect,
130 STRING_TIMER_ELM_SWALLOW_CENTER,
131 ad->view_setting->eo_content);
135 widget_create_button(ad->layout,
136 STRING_TIMER_NAVIFRAME_END_BTN_DEFAULT, NULL,
137 NULL, timer_view_back_btn_cb, ad->win_main);
140 widget_naviframe_push(ad->navi_bar,
141 STRING_TIMER_IDS_COM_BODY_TIMER_S_,
142 ad->back_button, NULL, ad->layout_main,
144 elm_naviframe_item_title_visible_set(ad->ei_naviframe, EINA_FALSE);
146 ad->controlbar_cb(EINA_TRUE);
148 feedback_initialize();
151 timer_view_free(NULL);
157 * Debug function: to create and show view.
158 * It will show motion view if there is an alarm of timer in server. otherwise, setting view will be shown.
159 * This function doesn't requires any input parameter
161 * timer_view_reload()
165 EAPI void timer_view_reload()
167 retm_if(!g_ad, "g_ad null");
168 struct appdata *ad = g_ad;
170 g_ad->isTimerView = 1;
171 ad->controlbar_cb(EINA_TRUE);
172 timer_utils_view_update(g_ad);
173 if (IS_EQUAL(ad->page, TIMER_VIEW_PAGE_MOTION)) {
174 timer_repaint_time(g_ad);
179 * Debug function: to set a variable which indicates whether timer view is active in Clock application.
180 * This function doesn't requires any input parameter
182 * timer_view_reload()
186 EAPI void timer_view_unload()
188 retm_if(!g_ad, "g_ad null");
189 g_ad->isTimerView = 0; // timer view doesn't exist.
193 * Debug function: to free all objects in the view going to be distroyed
194 * This function requires data as parameters
197 * @param[in] obj Pointer to view which will be distroyed
201 EAPI void timer_view_free(Evas_Object * obj)
203 retm_if(NULL_CHECK(g_ad), "g_ad null");
204 struct appdata *ad = g_ad;
207 feedback_deinitialize();
208 timer_view_setting.destroy(ad);
209 timer_view_motion.destroy(ad);
210 EVAS_OBJECT_DELIF(ad->ly_parent);
211 FREEIF(ad->view_setting);
212 FREEIF(ad->view_motion);