static Ret desktop_on_button_close_applist_clicked(void* ctx, void* obj) { ftk_main_loop_add_source(ftk_default_main_loop(), g_timer); desktop_update_time(_win); ftk_widget_show(ctx, 0); return RET_OK; }
int FTK_MAIN(int argc, char* argv[]) { int i = 0; FtkWidget* win = NULL; FtkWidget* button = NULL; FtkSource* timer = NULL; char path[FTK_MAX_PATH] = {0}; const char* root_path[FTK_ICON_PATH_NR] = {0}; ftk_init(argc, argv); for(i = 0; i < argc; i++) { const char* key_play="--event-play="; const char* key_record="--event-record="; #ifdef FTK_HAS_TESTER if(strncmp(argv[i], key_play, strlen(key_play)) == 0) { ftk_tester_start_play(argv[i] + strlen(key_play)); } if(strncmp(argv[i], key_record, strlen(key_record)) == 0) { ftk_tester_start_record(argv[i] + strlen(key_record)); } #endif } #ifdef ENABLE_NLS if(getenv("LANG") == NULL) { setenv("LANG", "zh_CN.UTF-8", 1); setlocale (LC_ALL, "zh_CN.UTF-8"); ftk_logd("LANG is not set, use zh_CN.UTF-8\n"); } else { setlocale (LC_ALL, ""); } bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); textdomain (PACKAGE); ftk_logd("%s: locale=%s\n", _("Hello, GetText"), setlocale(LC_ALL, NULL)); #endif desktop_add_time_item_on_statusbar(); if(argv[1] != NULL && strncmp(argv[1], "--hor", 5) == 0) { g_desktop.is_horizonal = 1; } g_desktop.app_manager = app_info_manager_create(); ftk_snprintf(path, sizeof(path), "%s/base/apps", FTK_ROOT_DIR); ftk_normalize_path(path); if(app_info_manager_load_dir(g_desktop.app_manager, path) != RET_OK) { ftk_snprintf(path, sizeof(path), "%s/apps", LOCAL_DATA_DIR); app_info_manager_load_dir(g_desktop.app_manager, path); } ftk_snprintf(path, sizeof(path), "%s/desktop", FTK_ROOT_DIR); root_path[0] = path; root_path[1] = NULL; g_desktop.icon_cache = ftk_icon_cache_create(root_path, NULL); win = desktop_load_xul(g_desktop.is_horizonal ? "xul/desktop-h.xul" : "xul/desktop-v.xul"); ftk_app_window_set_on_prepare_options_menu(win, desktop_on_prepare_options_menu, win); button = ftk_widget_lookup(win, 100); ftk_button_set_clicked_listener(button, desktop_on_button_open_applist_clicked, win); ftk_widget_show_all(win, 1); desktop_update_time(win); timer = ftk_source_timer_create(60000, desktop_update_time, win); ftk_main_loop_add_source(ftk_default_main_loop(), timer); ftk_widget_set_user_data(win, desktop_destroy, &g_desktop); ftk_run(); return 0; }