version update: m1
[profile/tv/apps/native/air_etg.git] / src / main.c
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <app.h>
18 #include <Elementary.h>
19 #include <app_debug.h>
20 #include <viewmgr.h>
21
22 #include "defs.h"
23 #include "view.h"
24
25 SET_TAG(PACKAGE);
26
27 struct _appdata {
28         const char *name;
29         Evas_Object *win;
30 };
31
32 static Evas_Object *_add_win(const char *name)
33 {
34         Evas_Object *win;
35
36         win = elm_win_add(NULL, name, ELM_WIN_BASIC);
37         if (!win)
38                 return NULL;
39
40         elm_win_title_set(win, name);
41         elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
42         evas_object_show(win);
43
44         return win;
45 }
46
47 static bool _create(void *user_data)
48 {
49         struct _appdata *ad;
50
51         if (!user_data) {
52                 _ERR("Invalid argument");
53                 return false;
54         }
55
56         ad = user_data;
57
58         elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
59
60         ad->win = _add_win(ad->name);
61         if (!ad->win) {
62                 _ERR("failed to create window");
63                 return false;
64         }
65
66         if (!viewmgr_create(ad->win)) {
67                 _ERR("failed to create viewmgr");
68                 evas_object_del(ad->win);
69                 ad->win = NULL;
70                 return false;
71         }
72
73         viewmgr_add_view(view_main_get_vclass(), NULL);
74
75         return true;
76 }
77
78 static void _terminate(void *user_data)
79 {
80         struct _appdata *ad;
81
82         if (!user_data)
83                 return;
84
85         ad = user_data;
86
87         if (ad->win) {
88                 viewmgr_destroy();
89                 evas_object_del(ad->win);
90         }
91 }
92
93 static void _pause(void *user_data)
94 {
95
96 }
97
98 static void _resume(void *user_data)
99 {
100
101 }
102
103 static void _control(app_control_h app_control, void *user_data)
104 {
105         struct _appdata *ad;
106
107         if (!user_data) {
108                 _ERR("Invalid argument");
109                 return;
110         }
111
112         ad = user_data;
113
114         if (ad->win) {
115                 elm_win_activate(ad->win);
116                 viewmgr_push_view(VIEW_MAIN);
117         }
118 }
119
120 int main(int argc, char **argv)
121 {
122         struct _appdata ad;
123
124         ui_app_lifecycle_callback_s event_callback = {0,};
125
126         event_callback.create = _create;
127         event_callback.terminate = _terminate;
128         event_callback.pause = _pause;
129         event_callback.resume = _resume;
130         event_callback.app_control = _control;
131
132         memset(&ad, 0x00, sizeof(ad));
133         ad.name = PACKAGE;
134
135         return ui_app_main(argc, argv, &event_callback, &ad);
136 }
137