2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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.
19 #include <appcore-efl.h>
20 #include <Elementary.h>
26 #include "worldclock_lib.h"
28 #include "worldclock.h"
29 #include "worldclock_data.h"
30 #include "worldclock_noti.h"
31 #include "worldclock_dlog.h"
32 #include "worldclock_main_view.h"
33 #include "worldclock_add_view.h"
34 #include "worldclock_edit_view.h"
35 static struct appdata *g_ad;
38 * Create navigationbar for lib
40 * @param[in] parent parent for new navigationbar
42 * @return NULL if meet error
43 * Pointer to new navigationbar
45 static Evas_Object *__worldclock_navibar_add(Evas_Object *parent)
48 Evas_Object *navi_bar;
50 retv_if(NULL == parent, NULL);
53 navi_bar = elm_naviframe_add(parent);
54 //elm_object_part_content_set( parent, "elm.swallow.content", navi_bar );
55 edje_object_part_swallow(_EDJ(parent), "elm.swallow.content", navi_bar);
57 evas_object_show(navi_bar);
64 * Create new view of lib
66 * @param[in] parent Parent of new view
67 * @param[in] cb Callback function register by caller to show & hide controlbar
68 * @param[in] icap Callback function register by caller for idle capture
70 * @return NULL if meet error
73 EAPI Evas_Object *worldclock_view_add(Evas_Object * parent, Evas_Object * win,
74 Wcl_Ctrlbar_Visible_Set cb,
75 Wcl_Idle_Capture icap)
78 retv_if(parent == NULL, NULL);
83 (struct appdata *)calloc(1, sizeof(struct appdata));
89 ad->layout_main = load_edj(parent, WCL_EDJ_NAME, GRP_LIB);
90 elm_object_part_content_set(parent, "elm.swallow.content",
94 bindtextdomain(PACKAGE, LOCALEDIR);
97 worldclock_noti_reg_vconf_changed(ad);
100 ad->navi_bar = __worldclock_navibar_add(ad->layout_main);
101 retv_if(ad->navi_bar == NULL, NULL);
104 if (EINA_FALSE == worldclock_data_open_database()) {
106 ("\nworldclock db not work well, please check it !!!!!!!!!!!!!!!!!!\n");
111 ad->caller = WCL_CALLER_IS_SHARED_LIBRARY;
112 // set selection flag
113 ad->selectionFlag = WCL_SELECT_IN_ALL; //the selection flag
114 ad->controlbar_cb = cb;
116 worldclock_mainview_add(ad->navi_bar, ad, NULL);
117 // set callback function for show & hide controlbar
118 // set callback function for idle capture
119 ad->idle_capture_cb = icap;
123 return g_ad->layout_main;
127 * Free view of worldclock lib
129 * @param[in] obj Pointer for view of worldclock lib
131 * @return SUCCESS exit worldclock
134 EAPI int worldclock_view_free(Evas_Object * obj)
138 if (g_ad && (g_ad->layout_main == obj)) {
141 worldclock_addview_free(g_ad);
145 worldclock_editview_free(g_ad);
149 worldclock_mainview_free(g_ad);
150 // free navigationbar
151 EVAS_OBJECT_DELIF(g_ad->navi_bar);
154 worldclock_data_close_database();
170 * reload view of worldclock lib
174 EAPI void worldclock_view_reload()
178 struct appdata *ad = g_ad;
179 if(ad->edit_selectioninfo) {
180 evas_object_show(ad->edit_selectioninfo);
182 if (IS_EQUAL(ad->page, WCL_PAGE_ADD)) {
183 ad->controlbar_cb(EINA_FALSE);
185 ad->controlbar_cb(EINA_TRUE);
187 worldclock_mainview_update(ad);
188 worldclock_editview_update(ad);
196 * unload view of worldclock lib
200 EAPI void worldclock_view_unload()
204 struct appdata *ad = g_ad;
205 if(ad->edit_selectioninfo) {
206 evas_object_hide(ad->edit_selectioninfo);
208 worldclock_ctxpopup_delete();