3 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
\r
5 * Licensed under the Apache License, Version 2.0 (the License);
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://www.apache.org/license/
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an AS IS BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
19 #include <Elementary.h>
\r
23 #include "ui_manager.h"
\r
26 _win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
\r
32 app_create(void *data)
\r
34 moment_info_s *moment_info = data;
\r
36 moment_info->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
\r
37 elm_win_conformant_set(moment_info->win, EINA_TRUE);
\r
38 elm_win_autodel_set(moment_info->win, EINA_TRUE);
\r
39 if (elm_win_wm_rotation_supported_get(moment_info->win)) {
\r
41 elm_win_wm_rotation_available_rotations_set(moment_info->win, (const int *)(&rots), 1);
\r
43 evas_object_smart_callback_add(moment_info->win, "delete,request", _win_delete_request_cb, NULL);
\r
44 elm_win_screen_size_get(moment_info->win, NULL, NULL, &moment_info->width, &moment_info->height);
\r
45 evas_object_show(moment_info->win);
\r
47 moment_info->conform = elm_conformant_add(moment_info->win);
\r
48 elm_win_indicator_mode_set(moment_info->win, ELM_WIN_INDICATOR_HIDE);
\r
49 evas_object_size_hint_weight_set(moment_info->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
50 elm_win_resize_object_add(moment_info->win, moment_info->conform);
\r
51 evas_object_show(moment_info->conform);
\r
53 _D("Window size (%d:%d)", moment_info->width, moment_info->height);
\r
55 moment_info->e = evas_object_evas_get(moment_info->win);
\r
61 app_control(app_control_h app_control, void *data)
\r
63 moment_info_s *moment_info = data;
\r
64 ret_if(!moment_info);
\r
65 ret_if(!mement_info->conformant);
\r
67 moment_info->ui_manager = ui_manager_create(moment_info->conformant, moment_info);
\r
68 ret_if(!moment_info->ui_manager);
\r
72 app_pause(void *data)
\r
74 /* Take necessary actions when application becomes invisible. */
\r
78 app_resume(void *data)
\r
80 /* Take necessary actions when application becomes visible. */
\r
84 app_terminate(void *data)
\r
86 moment_info_s *moment_info = data;
\r
88 if (moment_info->ui_manager)
\r
89 ui_manager_destroy(moment_info->ui_manager);
\r
91 if (moment_info->conform)
\r
92 evas_object_del(moment_info->conform);
\r
94 if (moment_info->win)
\r
95 evas_object_del(moment_info->win);
\r
99 ui_app_lang_changed(app_event_info_h event_info, void *user_data)
\r
101 /*APP_EVENT_LANGUAGE_CHANGED*/
\r
102 char *locale = NULL;
\r
103 system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
\r
104 elm_language_set(locale);
\r
110 ui_app_orient_changed(app_event_info_h event_info, void *user_data)
\r
112 /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
\r
117 ui_app_region_changed(app_event_info_h event_info, void *user_data)
\r
119 /*APP_EVENT_REGION_FORMAT_CHANGED*/
\r
123 ui_app_low_battery(app_event_info_h event_info, void *user_data)
\r
125 /*APP_EVENT_LOW_BATTERY*/
\r
129 ui_app_low_memory(app_event_info_h event_info, void *user_data)
\r
131 /*APP_EVENT_LOW_MEMORY*/
\r
135 main(int argc, char *argv[])
\r
137 moment_info_s moment_info = {0,};
\r
140 ui_app_lifecycle_callback_s event_callback = {0,};
\r
141 app_event_handler_h handlers[5] = {NULL, };
\r
143 event_callback.create = app_create;
\r
144 event_callback.terminate = app_terminate;
\r
145 event_callback.pause = app_pause;
\r
146 event_callback.resume = app_resume;
\r
147 event_callback.app_control = app_control;
\r
149 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &moment_info);
\r
150 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &moment_info);
\r
151 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &moment_info);
\r
152 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &moment_info);
\r
153 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &moment_info);
\r
154 ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
\r
156 ret = ui_app_main(argc, argv, &event_callback, &moment_info);
\r
157 if (ret != APP_ERROR_NONE) {
\r
158 dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_main() is failed. err = %d", ret);
\r