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.
21 #include <setting-flightmode.h>
24 #define UG_MODULE_API __attribute__ ((visibility("default")))
27 static void setting_flightmode_ug_cb_resize(void *data, Evas *e,
28 Evas_Object *obj, void *event_info)
30 SettingFlightModeUG *ad = (SettingFlightModeUG *) data;
31 setting_view_update(&setting_view_flightmode_main, ad);
34 setting_view *__get_flightmode_view_to_load(void *data, app_control_h service)
37 setting_retvm_if((!data), NULL, "data is NULL");
39 setting_view_node_table_intialize();
42 setting_view_node_table_register(&setting_view_flightmode_main, NULL);
43 return &setting_view_flightmode_main;
46 static void *setting_flightmode_ug_on_create(ui_gadget_h ug,
47 enum ug_mode mode, app_control_h service,
51 setting_retvm_if((!priv), NULL, "!priv");
52 SettingFlightModeUG *flightmodeUG = priv;
53 flightmodeUG->ug = ug;
54 flightmodeUG->bundle_data = service;
55 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
57 flightmodeUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
58 flightmodeUG->win_get = (Evas_Object *) ug_get_window();
60 evas_object_show(flightmodeUG->win_main_layout);
61 flightmodeUG->evas = evas_object_evas_get(flightmodeUG->win_main_layout);
63 setting_retvm_if(flightmodeUG->win_main_layout == NULL, NULL,
64 "cannot get main window ");
66 /* register view node table */
67 flightmodeUG->view_to_load = __get_flightmode_view_to_load(flightmodeUG, service);
68 setting_retvm_if(NULL == flightmodeUG->view_to_load, NULL, "NULL == flightmodeUG->view_to_load");
70 setting_create_Gendial_itc("dialogue/1text.2icon", &(flightmodeUG->itc_1text_2icon));
72 /* creating a view. */
73 setting_view_node_set_cur_view(flightmodeUG->view_to_load);
74 setting_view_create(flightmodeUG->view_to_load, (void *)flightmodeUG);
76 evas_object_event_callback_add(flightmodeUG->win_main_layout,
78 setting_flightmode_ug_cb_resize, flightmodeUG);
80 /*---------------------------------------------------------------- */
82 /*---------------------------------------------------------------- */
83 return flightmodeUG->ly_main;
86 static void setting_flightmode_ug_on_start(ui_gadget_h ug, app_control_h service,
91 static void setting_flightmode_ug_on_pause(ui_gadget_h ug, app_control_h service,
96 static void setting_flightmode_ug_on_resume(ui_gadget_h ug, app_control_h service,
101 static void setting_flightmode_ug_on_destroy(ui_gadget_h ug, app_control_h service,
105 setting_retm_if((!priv), "!priv");
106 SettingFlightModeUG *flightmodeUG = priv;
107 evas_object_event_callback_del(flightmodeUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_flightmode_ug_cb_resize); /*fix flash issue for gallery */
108 flightmodeUG->ug = ug;
109 if (flightmodeUG->bg) {
110 evas_object_del(flightmodeUG->bg);
112 flightmodeUG->bg = NULL;
114 /* called when this shared gadget is terminated. similar with app_exit */
115 setting_view_destroy(&setting_view_flightmode_main, flightmodeUG);
117 if (NULL != ug_get_layout(flightmodeUG->ug)) {
118 evas_object_hide((Evas_Object *) ug_get_layout(flightmodeUG->ug));
119 evas_object_del((Evas_Object *) ug_get_layout(flightmodeUG->ug));
123 static void setting_flightmode_ug_on_message(ui_gadget_h ug, app_control_h msg,
124 app_control_h service, void *priv)
129 static void setting_flightmode_ug_on_event(ui_gadget_h ug,
130 enum ug_event event, app_control_h service,
135 case UG_EVENT_LOW_MEMORY:
137 case UG_EVENT_LOW_BATTERY:
139 case UG_EVENT_LANG_CHANGE:
141 case UG_EVENT_ROTATE_PORTRAIT:
143 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
145 case UG_EVENT_ROTATE_LANDSCAPE:
147 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
149 case UG_EVENT_REGION_CHANGE:
156 static void setting_flightmode_ug_on_key_event(ui_gadget_h ug,
157 enum ug_key_event event,
158 app_control_h service, void *priv)
161 SettingFlightModeUG *ad = (SettingFlightModeUG *) priv;
164 case UG_KEY_EVENT_END: {
165 if (elm_naviframe_top_item_get(ad->navi_bar) ==
166 elm_naviframe_bottom_item_get(ad->
171 setting_view_cb_at_endKey(ad);
180 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
183 SettingFlightModeUG *flightmodeUG = calloc(1, sizeof(SettingFlightModeUG));
184 setting_retvm_if(!flightmodeUG, -1, "Create SettingFlightModeUG obj failed");
186 ops->create = setting_flightmode_ug_on_create;
187 ops->start = setting_flightmode_ug_on_start;
188 ops->pause = setting_flightmode_ug_on_pause;
189 ops->resume = setting_flightmode_ug_on_resume;
190 ops->destroy = setting_flightmode_ug_on_destroy;
191 ops->message = setting_flightmode_ug_on_message;
192 ops->event = setting_flightmode_ug_on_event;
193 ops->key_event = setting_flightmode_ug_on_key_event;
194 ops->priv = flightmodeUG;
195 ops->opt = UG_OPT_INDICATOR_ENABLE;
199 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
202 struct SettingFlightModeUG *flightmodeUG;
203 setting_retm_if(!ops, "ops == NULL");
205 flightmodeUG = ops->priv;
211 /* ***************************************************
215 ** **************************************************/
218 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG