2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <Elementary.h>
20 #include "homescreen.h"
28 struct homescreen *hscr;
34 * Creates transparent window as BASIC type.
36 * @param name The name of package
37 * @return window object or NULL otherwise
39 static Evas_Object *_add_win(const char *name)
43 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
45 _ERR("failed to create window");
49 elm_win_alpha_set(win, EINA_TRUE);
50 evas_object_show(win);
56 * Invoked as soon as application is launched according to applcation lifecycle.
58 * This function creates window object and overlay the theme file.
59 * And also doing following things.
60 * 1. Initializes engine for communicating with several content-providers.
61 * 2. Initializes homescreen UI.
62 * 3. Loads homescreen data.
64 * @param user_data The function specific data which holds _appdata pointer
65 * @return true If the window and layout object is created successfully;
68 static bool _create(void *user_data)
71 struct homescreen *hscr;
77 _ERR("Invalid argument");
83 elm_theme_overlay_add(NULL, THEMEFILE);
84 elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
88 _ERR("failed to initialize engine");
92 hscr = homescreen_init(eng);
94 _ERR("failed to initialize homescreen");
99 win = _add_win(ad->name);
101 _ERR("failed to create window");
102 homescreen_fini(hscr);
107 r = homescreen_load(hscr, win);
109 _ERR("failed to load homescreen");
110 homescreen_fini(hscr);
112 evas_object_del(win);
124 * Invoked before application is terminated according to application lifecycle.
126 * All Resources will be released.
128 * @param user_data The function specific data which holds _appdata pointer
130 static void _terminate(void *user_data)
135 _ERR("Invalid argument");
141 homescreen_fini(ad->hscr);
142 engine_fini(ad->eng);
145 evas_object_del(ad->win);
149 * Invoked when window of application becomes invisible.
151 * Hides this applciation.
153 * @param user_data The function specific data which holds _appdata pointer
155 static void _pause(void *user_data)
160 _ERR("Invalid argument");
166 homescreen_hide(ad->hscr);
170 * Invoked when window of application becomes visible.
172 * Shows this application.
174 * @param user_data The function specific data which holds _appdata pointer
176 static void _resume(void *user_data)
181 _ERR("Invalid argument");
187 homescreen_show(ad->hscr);
191 * Invoked when application should re-lauched according to application
194 * If this function is called at first, set the iconified state of window.
195 * After then, it activates window and shows this application.
197 * @param service The provided arguments for launching
198 * @param user_data The function specific data which holds _appdata pointer
200 static void _service(service_h service, void *user_data)
205 _ERR("Invalid argument");
211 /* FIXME: workaround */
212 homescreen_show(ad->hscr);
216 elm_win_iconified_set(ad->win, EINA_TRUE);
219 elm_win_activate(ad->win);
220 homescreen_show(ad->hscr);
225 * Invoked when language setting changed according to application events.
227 * There is no action in this applciation.
229 static void _lang_changed(void *user_data)
234 * Invoked when system region setting changed according to application events.
236 * There is no action in this application.
238 static void _region_fmt_changed(void *user_data)
245 * This function calls to register the state transition callbacks and system
246 * event callbacks at main loop.
248 * @param args The argument count
249 * @param argv The argument vector
251 int main(int argc, char **argv)
254 app_event_callback_s cbs = {
256 .terminate = _terminate,
262 .device_orientation = NULL,
263 .language_changed = _lang_changed,
264 .region_format_changed = _region_fmt_changed,
267 memset(&ad, 0x00, sizeof(ad));
270 app_efl_main(&argc, &argv, &cbs, &ad);