ApplicationMain::ApplicationMain(int argc, char **argv) { cInfo() << "Calaos Home, starting..."; if (system("killall -9 eskiss 2> /dev/null") == -1) cCritical() << "Error forking !"; //init random generator srand(time(NULL)); //Init SSL and CURL SSL_load_error_strings(); SSL_library_init(); curl_global_init(CURL_GLOBAL_ALL); char *themefile = argvOptionParam(argv, argv + argc, "--theme"); if (themefile) { ApplicationMain::theme = themefile; cInfo() << "Using specified theme file: " << ApplicationMain::getTheme(); } else { ApplicationMain::theme = Prefix::Instance().dataDirectoryGet() + "/default.edj"; if (ecore_file_exists(ApplicationMain::theme.c_str())) cInfo() << "Using theme file " << theme; else cError() << theme << " Not found!"; } //Init efl core if (!eina_init()) throw (runtime_error("Unable to init Eina")); if (!ecore_init()) throw (runtime_error("Unable to init Ecore")); if (!ecore_con_init()) throw (runtime_error("Unable to init Ecore-Con")); if (!ecore_con_url_init()) throw (runtime_error("Unable to init Ecore-Con-Url")); if (!evas_init()) throw (runtime_error("Unable to init Evas")); if (!ecore_evas_init()) throw (runtime_error("Unable to init Ecore-Evas")); if (!edje_init()) throw (runtime_error("Unable to init Edje")); edje_frametime_set(1.0 / 60.0); edje_scale_set(1.0); if (!elm_init(argc, argv)) throw (runtime_error("Unable to init Elementary")); //Load Calaos specific ELM extensions elm_theme_extension_add(NULL, ApplicationMain::getTheme()); //Create the main window window = elm_win_add(NULL, "calaos-home", ELM_WIN_BASIC); elm_win_title_set(window, "Calaos Home"); elm_win_borderless_set(window, true); bool bFullscreen = argvOptionCheck(argv, argv + argc, "--fullscreen"); elm_win_fullscreen_set(window, bFullscreen); //Automatically quit main loop when the window is closed elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); elm_win_autodel_set(window, true); if (argvOptionCheck(argv, argv + argc, "--set-elm-config")) { //force setting the correct elementary options for touchscreen elm_config_finger_size_set(10); elm_config_scroll_bounce_enabled_set(true); elm_config_scroll_thumbscroll_enabled_set(true); elm_config_scroll_thumbscroll_threshold_set(24); elm_config_scroll_thumbscroll_momentum_threshold_set(100.0); elm_config_scroll_bounce_friction_set(0.5); elm_config_scroll_page_scroll_friction_set(0.5); elm_config_scroll_bring_in_scroll_friction_set(0.5); elm_config_scroll_zoom_friction_set(0.5); elm_config_scroll_thumbscroll_friction_set(1.0); elm_config_scroll_thumbscroll_border_friction_set(0.5); elm_config_scroll_thumbscroll_sensitivity_friction_set(0.25); } evas_object_event_callback_add(window, EVAS_CALLBACK_RESIZE, _window_resize_cb, this); evas = evas_object_evas_get(window); Evas_Object *bg = elm_bg_add(window); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(window, bg); evas_object_show(bg); evas_object_size_hint_min_set(bg, 200, 200); elm_bg_color_set(bg, 0, 0, 0); layout = elm_layout_add(window); if (!elm_layout_file_set(layout, ApplicationMain::getTheme(), EDJE_GROUP_MAIN_LAYOUT)) { string e = "Unable to find group \""; e += EDJE_GROUP_MAIN_LAYOUT; e += "\" in theme \""; e += ApplicationMain::getTheme(); e += "\""; throw (runtime_error(e)); } //create the screen suspend object and put it on the canvas ScreenSuspendView *screen_suspend = new ScreenSuspendView(evas, window); screen_suspend->Show(); screen_suspend->setAutoDelete(true); evas_object_size_hint_weight_set(layout, 1.0, 1.0); evas_object_show(layout); evas_object_resize(window, 1024, 768); evas_object_show(window); ecore_evas_focus_set(ecore_evas_ecore_evas_get(evas_object_evas_get(window)), true); Resize(); try { controller = new ApplicationController(evas, layout); } catch(exception const& e) { cCritical() << "Can't create ApplicationController"; throw; } }
int main(int argc, char *argv[]) { app_t app; int i; Evas_Object *o; ecore_init(); ecore_app_args_set(argc, (const char **)argv); ecore_evas_init(); edje_init(); edje_frametime_set(1.0 / 30.0); memset(&app, 0, sizeof(app)); app.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, WIDTH, HEIGHT); ecore_evas_data_set(app.ee, "app", &app); ecore_evas_title_set(app.ee, TITLE); ecore_evas_name_class_set(app.ee, WM_NAME, WM_CLASS); app.theme = THEME; for (i=1; i < argc; i++) if (strcmp (argv[i], "-fs") == 0) ecore_evas_fullscreen_set(app.ee, 1); else if (strncmp (argv[i], "-theme=", sizeof("-theme=") - 1) == 0) app.theme = argv[i] + sizeof("-theme=") - 1; else if (argv[i][0] != '-') app.infile = argv[i]; app.evas = ecore_evas_get(app.ee); app.edje_main = edje_object_add(app.evas); evas_data_attach_set(app.evas, &app); if (!edje_object_file_set(app.edje_main, app.theme, THEME_GROUP)) { fprintf(stderr, "Failed to load file \"%s\", part \"%s\".\n", app.theme, THEME_GROUP); return 1; } evas_object_move(app.edje_main, 0, 0); evas_object_resize(app.edje_main, WIDTH, HEIGHT); app.e_box = e_box_add(app.evas); e_box_orientation_set(app.e_box, 0); e_box_homogenous_set(app.e_box, 0); e_box_align_set(app.e_box, 0.0, 0.5); edje_object_part_swallow(app.edje_main, "contents_swallow", app.e_box); evas_object_show(app.edje_main); evas_object_show(app.e_box); ecore_evas_show(app.ee); _populate(&app); app.scroll.initial_delay_ms = 750; app.scroll.accel_ms = 600; setup_gui_list(&app); ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL); ecore_evas_callback_resize_set(app.ee, resize_cb); evas_object_event_callback_add(app.edje_main, EVAS_CALLBACK_KEY_DOWN, key_down, &app); evas_object_focus_set(app.edje_main, 1); o = edje_object_part_object_get(app.edje_main, "back_button"); evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, mouse_down_back_button, &app); ecore_main_loop_begin(); return 0; }
int main(int argc, char *argv[]) { app_t app; int i; char *engine = "x11-16"; ecore_init(); ecore_app_args_set(argc, (const char **)argv); ecore_evas_init(); edje_init(); edje_frametime_set(1.0 / 30.0); memset(&app, 0, sizeof(app)); app.theme = THEME; app.fs = 1; app.total_ms = 1000; app.fade_in = 1; for (i=1; i < argc; i++) if (strcmp (argv[i], "-fs") == 0) ecore_evas_fullscreen_set(app.ee, 1); else if (strncmp (argv[i], "-theme=", sizeof("-theme=") - 1) == 0) app.theme = argv[i] + sizeof("-theme=") - 1; else if (strncmp (argv[i], "-time=", sizeof("-time=") - 1) == 0) app.total_ms = atoi(argv[i] + sizeof("-time=") - 1); else if (strncmp (argv[i], "-engine=", sizeof("-engine=") - 1) == 0) engine = argv[i] + sizeof("-engine=") - 1; if (app.total_ms < 1) app.total_ms = 1000; app.ee = init_ecore_evas(engine); if (!app.ee) { fprintf(stderr, "Could not init engine '%s'.\n", engine); return 1; } ecore_evas_data_set(app.ee, "app", &app); ecore_evas_title_set(app.ee, TITLE); ecore_evas_name_class_set(app.ee, WM_NAME, WM_CLASS); ecore_evas_fullscreen_set(app.ee, app.fs); fprintf(stderr, "time to fade: %dms\n", app.total_ms); app.evas = ecore_evas_get(app.ee); app.edje_main = edje_object_add(app.evas); evas_data_attach_set(app.evas, &app); if (!edje_object_file_set(app.edje_main, app.theme, THEME_GROUP)) { fprintf(stderr, "Failed to load file \"%s\", part \"%s\".\n", app.theme, THEME_GROUP); return 1; } app.obj = edje_object_part_object_get(app.edje_main, "obj"); evas_object_move(app.edje_main, 0, 0); evas_object_resize(app.edje_main, WIDTH, HEIGHT); evas_object_show(app.edje_main); ecore_evas_show(app.ee); ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL); ecore_evas_callback_resize_set(app.ee, resize_cb); evas_object_event_callback_add(app.edje_main, EVAS_CALLBACK_KEY_DOWN, key_down, &app); evas_object_focus_set(app.edje_main, 1); gettimeofday(&app.start, NULL); app.anim = ecore_animator_add(do_anim, &app); ecore_main_loop_begin(); return 0; }