4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <setting-time.h>
23 #include <setting-cfg.h>
24 #include <unicode/uloc.h>
27 #define UG_MODULE_API __attribute__ ((visibility("default")))
31 * @callback handler for EVAS_CALLBACK_RESIZE
33 * @param data user data (SettingTimeUG *)
35 static void setting_time_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
39 SettingTimeUG *ad = (SettingTimeUG *) data;
40 setting_view_update(&setting_view_time_main, ad);
44 * @callback function called first while loading setting-time UG.
46 * @param ug ug object itself.
48 * @param data bundle (key, value pair) data as arguments into UG.
49 * @param priv SettingTimeUG context
53 static void *setting_time_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
54 app_control_h service, void *priv)
57 setting_retvm_if((!priv), NULL, "!priv");
59 SettingTimeUG *timeUG = priv;
61 timeUG->bundle_data = service;
62 timeUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
63 timeUG->win_get = (Evas_Object *) ug_get_window();
64 evas_object_show(timeUG->win_main_layout);
65 timeUG->evas = evas_object_evas_get(timeUG->win_main_layout);
67 timeUG->pop_progress = NULL;
68 /* Initialize Caller value */
69 timeUG->caller = NULL;
71 setting_retvm_if(timeUG->win_main_layout == NULL, NULL, "cannot get main window ");
74 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
76 /* register view node table */
77 setting_view_node_table_intialize();
78 setting_view_node_table_register(&setting_view_time_main, NULL);
80 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(timeUG->itc_1text_1icon));
81 setting_create_Gendial_itc("entry.main", &(timeUG->itc_layout));
82 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(timeUG->itc_2text_2));
83 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(timeUG->itc_2text_3_parent));
84 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(timeUG->itc_1icon_1text_sub));
86 timeUG->is_expand_time_format_list = 0;
88 char *viewtype = NULL;
89 app_control_get_extra_data(service, "viewtype", &viewtype);
90 if (!safeStrCmp(viewtype, "format_expand")) {
91 timeUG->is_expand_time_format_list = 1;
94 /* creating a view. */
95 setting_view_node_set_cur_view(&setting_view_time_main);
96 setting_view_create(&setting_view_time_main, (void *)timeUG);
97 evas_object_event_callback_add(timeUG->win_main_layout,
99 setting_time_ug_cb_resize, timeUG);
100 return timeUG->ly_main;
103 static void setting_time_ug_on_start(ui_gadget_h ug, app_control_h service,
110 static void setting_time_ug_on_pause(ui_gadget_h ug, app_control_h service,
117 static void setting_time_ug_on_resume(ui_gadget_h ug, app_control_h service,
123 static void setting_time_ug_on_destroy(ui_gadget_h ug, app_control_h service,
127 setting_retm_if((!priv), "!priv");
128 SettingTimeUG *timeUG = priv;
130 evas_object_event_callback_del(timeUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_time_ug_cb_resize); /* fix flash issue for gallery */
133 /* delete the allocated objects. */
134 setting_view_destroy(&setting_view_time_main, timeUG);
136 if (NULL != ug_get_layout(timeUG->ug)) {
137 evas_object_hide((Evas_Object *) ug_get_layout(timeUG->ug));
138 evas_object_del((Evas_Object *) ug_get_layout(timeUG->ug));
144 static void setting_time_ug_on_message(ui_gadget_h ug, app_control_h msg,
145 app_control_h service, void *priv)
150 static void setting_time_ug_on_event(ui_gadget_h ug, enum ug_event event,
151 app_control_h service, void *priv)
154 SettingTimeUG *ad = (SettingTimeUG *) priv;
157 case UG_EVENT_LOW_MEMORY:
159 case UG_EVENT_LOW_BATTERY:
161 case UG_EVENT_LANG_CHANGE: {
162 const char *pa_lang = vconf_get_str(VCONFKEY_LANGSET);
164 char *q = strchr(pa_lang, '.');
171 uloc_setDefault(pa_lang, &err);
173 setting_view_update(&setting_view_time_main, ad);
176 case UG_EVENT_ROTATE_PORTRAIT:
178 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
180 case UG_EVENT_ROTATE_LANDSCAPE:
182 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
184 case UG_EVENT_REGION_CHANGE:
192 * @brief key event handler for UG
194 static void setting_time_ug_on_key_event(ui_gadget_h ug,
195 enum ug_key_event event, app_control_h service,
199 SettingTimeUG *ad = (SettingTimeUG *) priv;
202 case UG_KEY_EVENT_END: {
204 if (0 == safeStrCmp(ad->caller, "pwlock")) {
205 /* Create Bundle and send message */
208 if (app_control_create(&svc))
211 app_control_add_extra_data(svc, "result", "lbutton_click");
212 ug_send_result(ad->ug, svc);
214 app_control_destroy(svc);
218 if (elm_naviframe_top_item_get(ad->navi_bar) ==
219 elm_naviframe_bottom_item_get(ad->navi_bar)) {
222 /* elm_naviframe_item_pop(ad->navi_bar); */
223 setting_view_cb_at_endKey(ad);
233 * @brief UG entry point - create the SettingTimeUG context
236 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
239 SettingTimeUG *timeUG = calloc(1, sizeof(SettingTimeUG));
240 setting_retvm_if(!timeUG, -1, "Create SettingTimeUG obj failed");
242 ops->create = setting_time_ug_on_create;
243 ops->start = setting_time_ug_on_start;
244 ops->pause = setting_time_ug_on_pause;
245 ops->resume = setting_time_ug_on_resume;
246 ops->destroy = setting_time_ug_on_destroy;
247 ops->message = setting_time_ug_on_message;
248 ops->event = setting_time_ug_on_event;
249 ops->key_event = setting_time_ug_on_key_event;
251 ops->opt = UG_OPT_INDICATOR_ENABLE;
257 * @brief UG finalizer - destroy the SettingTimeUG context
259 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
262 struct SettingTimeUG *timeUG;
263 setting_retm_if(!ops, "ops == NULL");
270 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv,
274 Setting_Cfg_Node_T *node;
275 Eina_List **pplist = priv;
277 const Setting_Cfg_Node_T search_configs[] = {
278 {DATE_TIME_STR_AUTOMATIC_UPDATE, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, DATE_TIME_STR_DATE_AND_TIME, NULL, NULL },
279 {DATE_TIME_STR_TIME_ZONE, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, DATE_TIME_STR_DATE_AND_TIME, NULL, NULL },
281 /* Duplicated title name : 'Date and time' with UG name : 'Date and time' */
282 {DATE_TIME_STR_DATE_AND_TIME, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, DATE_TIME_STR_DATE_AND_TIME, NULL, NULL },
283 {DATE_TIME_STR_TIME_FORMAT, NULL, "viewtype:format_expand", 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, DATE_TIME_STR_DATE_AND_TIME, NULL, NULL }
286 retv_if(NULL == priv, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
287 retv_if(NULL == applocale, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
289 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
291 size = sizeof(search_configs) / sizeof(Setting_Cfg_Node_T);
293 for (i = 0; i < size; i++) {
294 node = setting_plugin_search_item_subindex_add(
295 search_configs[i].key_name,
296 search_configs[i].ug_args,
298 search_configs[i].item_type,
299 search_configs[i].data,
300 search_configs[i].sub_index);
302 *pplist = eina_list_append(*pplist, node);