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-plugin.h>
25 #define SETTING_BRIGHTNESS_LEVEL_FOR_EMUL 24
28 #define UG_MODULE_API __attribute__ ((visibility("default")))
31 static void setting_plugin_ug_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
33 SettingPluginUG *ad = (SettingPluginUG *) data;
34 setting_view_update(ad->view_to_load, ad);
38 static char* _gl_text_handler(void* data, Evas_Object* obj, const char* part)
40 SETTING_TRACE("%s ", part);
41 if (!safeStrCmp(part, "elm.text") || !safeStrCmp(part, "elm.text.1")) { /* title */
42 return (char *)g_strdup("elm_text or elm.text.1");
43 } else if (!safeStrCmp(part, "elm.text.2")) {
44 return (char *)g_strdup("elm.text.2");
46 return (char *)g_strdup("hello world");
50 static Evas_Object* _gl_content_handler(void* data, Evas_Object* obj, const char* part)
52 SETTING_TRACE("%s ", part);
53 //--------------------
55 //--------------------
57 if (!safeStrCmp(part, "elm.icon") || !safeStrCmp(part, "elm.icon.1"))
61 else if (!safeStrCmp(part, "elm.icon.2"))
65 else if (!safeStrCmp(part, "elm.swallow.end"))
70 // create an elm_datefield
71 Evas_Object* datetimefield = elm_datetime_add(obj/* parent */);
72 evas_object_size_hint_weight_set(datetimefield, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73 evas_object_size_hint_align_set(datetimefield, EVAS_HINT_FILL, 0.5);
74 evas_object_show(datetimefield);
76 const char* time_format = NULL;
79 time_format = "%I : %M %p";
81 time_format = "%H : %M";
83 elm_datetime_field_visible_set(datetimefield, ELM_DATETIME_AMPM, EINA_TRUE);
84 elm_datetime_format_set(datetimefield, "%d/%b /%y/ %H:%M");
86 // min : 1970 1, 01, Thursday 00:00:00
88 memset(&ts_ret, 0, sizeof(struct tm));
92 elm_datetime_value_max_set(datetimefield, &ts_ret);
94 // max : 2038 1, 19, Thursday 03:14:07
98 elm_datetime_value_min_set(datetimefield, &ts_ret);
101 time_t ctime = time(NULL);
102 struct tm *ts = localtime_r(&ctime, &ts_ret);
105 elm_datetime_value_set(datetimefield, &ts_ret);
108 return datetimefield;
112 static void _gl_del_handler(void* data, Evas_Object* obj)
118 static void _init_itc(void* data)
120 SettingPluginUG *pluginUG = (SettingPluginUG *)data;
122 //----------------------------------------------------------------
123 // dialogue/separator/21/with_line
124 //----------------------------------------------------------------
125 pluginUG->itc_seperator.item_style = "dialogue/separator";
126 pluginUG->itc_seperator.func.text_get = NULL;
127 pluginUG->itc_seperator.func.content_get = NULL;
128 pluginUG->itc_seperator.func.state_get = NULL;
129 pluginUG->itc_seperator.func.del = NULL;
132 //----------------------------------------------------------------
135 //----------------------------------------------------------------
136 pluginUG->itc_layout.item_style = "dialogue/1icon";
137 pluginUG->itc_layout.func.text_get = _gl_text_handler;
138 pluginUG->itc_layout.func.content_get = _gl_content_handler;
139 pluginUG->itc_layout.func.state_get = NULL;
140 pluginUG->itc_layout.func.del = _gl_del_handler;
143 static void *setting_plugin_ug_on_create(ui_gadget_h ug,
144 enum ug_mode mode, service_h service,
147 setting_retvm_if((!priv), NULL, "!priv");
149 SettingPluginUG *pluginUG = priv;
151 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
153 pluginUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
154 pluginUG->win_get = (Evas_Object *) ug_get_window();
155 evas_object_show(pluginUG->win_main_layout);
157 pluginUG->evas = evas_object_evas_get(pluginUG->win_main_layout);
159 setting_retvm_if(pluginUG->win_main_layout == NULL, NULL, "cannot get main window ");
162 /* register view node table */
163 setting_view_node_table_intialize();
165 /* creating a view. */
167 setting_view_node_table_register(&setting_view_test_main, NULL);
168 testUG->view_to_load = &setting_view_test_main;
169 setting_view_node_set_cur_view(testUG->view_to_load);
170 setting_view_create(testUG->view_to_load, (void *)testUG);
171 evas_object_event_callback_add(testUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_test_ug_cb_resize, testUG);
173 // init ITC for Gen-List
176 return pluginUG->ly_main;
179 static void setting_plugin_ug_on_start(ui_gadget_h ug, service_h service,
184 static void setting_plugin_ug_on_pause(ui_gadget_h ug, service_h service,
189 static void setting_plugin_ug_on_resume(ui_gadget_h ug, service_h service,
194 static void setting_plugin_ug_on_destroy(ui_gadget_h ug, service_h service,
198 setting_retm_if((!priv), "!priv");
199 SettingPluginUG *pluginUG = priv;
201 /* fix flash issue for gallery */
202 evas_object_event_callback_del(pluginUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_plugin_ug_cb_resize);
205 /* called when this shared gadget is terminated. similar with app_exit */
206 if (&setting_view_plugin_main == pluginUG->view_to_load) {
207 setting_view_destroy(&setting_view_plugin_main, pluginUG);
210 if (NULL != ug_get_layout(pluginUG->ug)) {
211 evas_object_hide((Evas_Object *) ug_get_layout(pluginUG->ug));
212 evas_object_del((Evas_Object *) ug_get_layout(pluginUG->ug));
218 static void setting_plugin_ug_on_message(ui_gadget_h ug, service_h msg,
219 service_h service, void *priv)
224 static void setting_plugin_ug_on_event(ui_gadget_h ug,
225 enum ug_event event, service_h service,
230 case UG_EVENT_LOW_MEMORY:
232 case UG_EVENT_LOW_BATTERY:
234 case UG_EVENT_LANG_CHANGE:
236 case UG_EVENT_ROTATE_PORTRAIT:
238 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
240 case UG_EVENT_ROTATE_LANDSCAPE:
242 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
244 case UG_EVENT_REGION_CHANGE:
251 static void setting_plugin_ug_on_key_event(ui_gadget_h ug,
252 enum ug_key_event event,
253 service_h service, void *priv)
256 SettingPluginUG *ad = (SettingPluginUG *) priv;
259 case UG_KEY_EVENT_END:
261 if (elm_naviframe_top_item_get(ad->navi_bar) ==
262 elm_naviframe_bottom_item_get(ad->navi_bar)) {
265 setting_view_cb_at_endKey(ad);
274 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
277 SettingPluginUG *pluginUG = calloc(1, sizeof(SettingPluginUG));
278 setting_retvm_if(!pluginUG, -1, "Create SettingPluginUG obj failed");
280 ops->create = setting_plugin_ug_on_create;
281 ops->start = setting_plugin_ug_on_start;
282 ops->pause = setting_plugin_ug_on_pause;
283 ops->resume = setting_plugin_ug_on_resume;
284 ops->destroy = setting_plugin_ug_on_destroy;
285 ops->message = setting_plugin_ug_on_message;
286 ops->event = setting_plugin_ug_on_event;
287 ops->key_event = setting_plugin_ug_on_key_event;
288 ops->priv = pluginUG;
289 ops->opt = UG_OPT_INDICATOR_ENABLE;
294 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
297 struct SettingPluginUG *pluginUG;
298 setting_retm_if(!ops, "ops == NULL");
300 pluginUG = ops->priv;
306 /* ***************************************************
310 ***************************************************/
312 void setting_plugin_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
315 SettingPluginUG *ad = (SettingPluginUG *) priv;
322 base = (Evas_Object *) ug_get_layout(ug);
327 case UG_MODE_FULLVIEW:
328 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
330 //elm_win_resize_object_add(ad->win_get, base);
331 evas_object_show(base);
341 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)