Modifies Live-tv application for displaying background image on Home
[profile/tv/apps/native/air_livetv.git] / src / main.c
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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 <viewmgr.h>
20 #include <app_debug.h>
21 #include <app_define.h>
22 #include <efl_util.h>
23
24 #include "define.h"
25 #include "view.h"
26
27 SET_TAG(PACKAGE)
28
29 struct _appdata {
30         const char *name;
31         Evas_Object *win;
32 };
33
34 static Evas_Object *_add_win(const char *name)
35 {
36         Evas_Object *win;
37
38         win = elm_win_add(NULL, name, ELM_WIN_BASIC);
39         if (!win) {
40                 _ERR("elm_win_add failed");
41                 return NULL;
42         }
43         elm_win_title_set(win, PACKAGE);
44         elm_win_focus_highlight_enabled_set(win, EINA_FALSE);
45         elm_win_focus_highlight_style_set(win, "invisible");
46         efl_util_set_window_opaque_state(win, 1);
47
48         evas_object_show(win);
49
50         return win;
51 }
52
53 static bool _create(void *data)
54 {
55         struct _appdata *ad;
56         Evas_Object *win;
57
58         if (!data) {
59                 _ERR("failed to get data");
60                 return false;
61         }
62
63         ad = data;
64
65         elm_app_base_scale_set(APP_BASE_SCALE);
66
67         win = _add_win(ad->name);
68         if (!win) {
69                 _ERR("failed to create win object");
70                 return false;
71         }
72
73         if (!viewmgr_create(win)) {
74                 _ERR("failed to initialize viewmgr");
75                 evas_object_del(win);
76                 return false;
77         }
78
79         viewmgr_add_view(view_bgimage_get_vclass(), NULL);
80         ad->win = win;
81
82         viewmgr_show_view(VIEW_BGIMAGE);
83
84         return true;
85 }
86
87 static void _terminate(void *data)
88 {
89         struct _appdata *ad;
90
91         if (!data) {
92                 _ERR("failed to get data");
93                 return;
94         }
95
96         ad = data;
97
98         if (ad->win) {
99                 viewmgr_remove_view(VIEW_BGIMAGE);
100                 evas_object_del(ad->win);
101                 ad->win = NULL;
102         }
103 }
104
105 int main(int argc, char *argv[])
106 {
107         struct _appdata ad;
108         ui_app_lifecycle_callback_s cbs = {
109                 .create = _create,
110                 .terminate = _terminate,
111         };
112
113         memset(&ad, 0x00, sizeof(ad));
114         ad.name = PACKAGE;
115
116         return ui_app_main(argc, argv, &cbs, &ad);
117 }