/* * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include "define.h" #include "utils.h" #include "view.h" SET_TAG(PACKAGE); struct _appdata { Evas_Object *win; const char *name; }; static bool _create(void *data) { struct _appdata *ad; Evas_Object *win; if (!data) { _ERR("Get data failed."); return false; } ad = data; elm_app_base_scale_set(APP_BASE_SCALE); elm_theme_overlay_add(NULL, THEMEFILE); win = utils_add_window(ad->name); if (!win) { _ERR("Add window failed."); return false; } if (ug_init_efl(win, UG_OPT_INDICATOR_ENABLE) < 0) { _ERR("Fail to init ug"); evas_object_del(win); return false; } if (!viewmgr_create(win)) { _ERR("Create viewmgr failed."); evas_object_del(win); return false; } if (!viewmgr_add_view(view_base_get_vclass(), NULL)) { _ERR("Add view failed."); viewmgr_destroy(); evas_object_del(win); return false; } if (!viewmgr_add_view(view_action_menu_get_vclass(), NULL)) { _ERR("Add view faild."); viewmgr_destroy(); evas_object_del(win); return false; } if (!viewmgr_add_view(view_pin_get_vclass(), NULL)) { _ERR("Add view faild."); viewmgr_destroy(); evas_object_del(win); return false; } ad->win = win; return true; } static void _terminate(void *data) { struct _appdata *ad; if (!data) { _ERR("Get data failed."); return; } ad = data; if (ad->win) { evas_object_del(ad->win); ad->win = NULL; } viewmgr_remove_view(VIEW_BASE); viewmgr_remove_view(VIEW_ACTION_MENU); viewmgr_remove_view(VIEW_PIN); viewmgr_destroy(); } static void _app_control(app_control_h control, void *data) { struct _appdata *ad; char *category; int r; if (!data) { _ERR("Get data failed."); return; } ad = data; if (ad->win) elm_win_activate(ad->win); r = app_control_get_extra_data(control, PARAM_CATEGORY, &category); if (r != APP_CONTROL_ERROR_NONE) category = NULL; if (category) viewmgr_update_view(VIEW_BASE, UPDATE_MENU, category); if (!viewmgr_push_view(VIEW_BASE)) _ERR("Push view failed."); } static void _pause(void *data) { view_state state; state = viewmgr_get_view_state(VIEW_ACTION_MENU); if (state == VIEW_STATE_VISIBLE) viewmgr_hide_view(VIEW_ACTION_MENU); state = viewmgr_get_view_state(VIEW_PIN); if (state == VIEW_STATE_VISIBLE) viewmgr_hide_view(VIEW_PIN); inputmgr_enable(EINA_FALSE); } static void _resume(void *data) { inputmgr_enable(EINA_TRUE); } int main(int argc, char *argv[]) { struct _appdata ad; ui_app_lifecycle_callback_s cbs = { .create = _create, .terminate = _terminate, .app_control = _app_control, .pause = _pause, .resume = _resume, }; memset(&ad, 0x00, sizeof(ad)); ad.name = PACKAGE; return ui_app_main(argc, argv, &cbs, &ad); }