3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.tizenopensource.org/license
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 #include <appcore-efl.h>
21 #include <Elementary.h>
24 #include <unicode/utf8.h>
25 #include <unicode/ustring.h>
26 #include <unicode/ucol.h>
29 #include "worldclock.h"
30 #include "worldclock_dlog.h"
31 #include "worldclock_util.h"
32 #include "worldclock_data.h"
33 #include "worldclock_fwk_icu.h"
34 #include "worldclock_ug_add_view.h"
36 static Wcl_Return_Cb g_return_cb = NULL;
38 static void __ug_addview_launch_ug_destroy_cb(ui_gadget_h ug,
42 /* if(ug) ug_destroy(ug); */
43 /* restore the '<-' button on the navigate bar */
45 struct appdata *ad = (struct appdata *) priv;
54 static void __ug_addview_launch_ug_result_cb(ui_gadget_h ug,
55 service_h result, void *priv)
59 retm_if(priv == NULL, "Data parameter is NULL");
62 service_get_extra_data(result, "city", &city);
65 // create new structure to store new city
66 Wcl_CitySet *cs = calloc(1, sizeof(Wcl_CitySet));
67 retm_if(cs == NULL, "city set data calloc failed");
69 snprintf(cs->city, CITY_BUF_SIZE, "%s", city);
72 worldclock_data_get_city_status_from_db(cs);
75 g_return_cb(cs, EINA_TRUE);
82 static void __ug_addview_launch_ug_layout_cb(ui_gadget_h ug,
87 struct appdata *ad = (struct appdata *) priv;
90 ret_if (!ug || !priv);
92 base = (Evas_Object *) ug_get_layout(ug);
96 case UG_MODE_FULLVIEW:
97 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
99 elm_win_resize_object_add(ad->win, base);
100 evas_object_show(base);
109 * Create map view for append new city into the selection list of worldclock
111 * @param[in] parent Evas_Object which is the parent of map view
112 * @param[in] data data which used in this function
113 * @param[in] func Callback function which used for invoking when exit from map view
115 * @return FAILED if create map view failed.
116 * SUCCESS if create map view successfully.
118 int worldclock_ug_addview_add(Evas_Object *parent, void *data, Wcl_Return_Cb func)
121 retv_if(!data, FAILED);
122 retvm_if(data == NULL, FAILED, "Data parameter is NULL");
123 struct appdata *ad = (struct appdata *)data;
124 service_h service = NULL;
126 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
127 retvm_if(!cbs, FAILED, "ug callbacks calloc failed");
128 cbs->layout_cb = __ug_addview_launch_ug_layout_cb;
129 cbs->result_cb = __ug_addview_launch_ug_result_cb;
130 cbs->destroy_cb = __ug_addview_launch_ug_destroy_cb;
131 cbs->priv = (void *)ad;
133 if (WCL_PAGE_MAIN == ad->page) {
134 service_create(&service);
135 service_add_extra_data(service, "caller", "clock");
138 CLK_INFO("to load ug[%s]", "worldclock-efl");
139 ad->ug = ug_create(NULL, "worldclock-efl", UG_MODE_FULLVIEW, service, cbs);
140 if (NULL == ad->ug) {
142 CLK_ERR("failed to load ug[%s]", "worldclock-efl");
149 service_destroy(service);
154 * Release all resources which used in map view when exit from map view
156 * @param[in] data data which used in this function
160 void worldclock_ug_addview_free(void *data)
164 struct appdata *ad = (struct appdata *)data;