static int lua_ftk_set_sources_manager(lua_State* L) { tolua_Error err = {0}; FtkSourcesManager* sources_manager; int param_ok = tolua_isusertype(L, 1, "FtkSourcesManager", 0, &err); return_val_if_fail(param_ok, 0); sources_manager = tolua_tousertype(L, 1, 0); ftk_set_sources_manager(sources_manager); return 1; }
Ret ftk_init(int argc, char* argv[]) { FtkColor bg = {0}; FtkConfig* config = NULL; FtkDisplay* display = NULL; static int ftk_inited = 0; if(ftk_inited) { return RET_OK; } else { ftk_inited = 1; } ftk_clear_globals(); PROFILE_START(); #ifndef USE_STD_MALLOC ftk_set_allocator(FTK_ALLOC_PROFILE(ftk_allocator_default_create())); quit_if_fail(ftk_default_allocator(), "Init allocator failed.\n"); #endif ftk_platform_init(argc, argv); config = ftk_config_create(); ftk_set_config(config); ftk_config_init(config, argc, argv); quit_if_fail(ftk_default_config(), "Init config failed.\n"); PROFILE_END("config init"); ftk_set_text_layout(ftk_text_layout_create()); PROFILE_START(); ftk_set_sources_manager(ftk_sources_manager_create(64)); ftk_set_main_loop(ftk_main_loop_create(ftk_default_sources_manager())); ftk_set_wnd_manager(ftk_wnd_manager_default_create(ftk_default_main_loop())); quit_if_fail(ftk_default_wnd_manager(), "Init windows manager failed.\n"); PROFILE_END("source main loop wnd manager init"); ftk_init_bitmap_factory(); PROFILE_START(); ftk_init_theme(ftk_config_get_theme(config)); ftk_backend_init(argc, argv); PROFILE_END("theme and backend init"); display = ftk_display_rotate_create(ftk_default_display(), ftk_config_get_rotate(ftk_default_config())); ftk_set_display(display); quit_if_fail(ftk_default_display(), "Init display failed.\n"); PROFILE_START(); bg.a = 0xff; ftk_set_shared_canvas(ftk_canvas_create(ftk_display_width(display), ftk_display_height(display), &bg)); ftk_logd("canvas init: %d %d\n", ftk_display_width(display), ftk_display_height(display)); PROFILE_END("canvas init"); PROFILE_START(); ftk_set_input_method_manager(ftk_input_method_manager_create()); ftk_set_input_method_preeditor(ftk_input_method_preeditor_default_create()); quit_if_fail(ftk_default_input_method_manager(), "Init input method failed.\n"); PROFILE_END("input method init"); PROFILE_START(); if(ftk_config_get_enable_status_bar(config)) { ftk_init_panel(); } PROFILE_END("panel init"); if(ftk_config_get_enable_cursor(config)) { #ifndef USE_LINUX_DFB ftk_enable_curosr(); #endif } return RET_OK; }
void ftk_deinit(void) { if(ftk_default_input_method_preeditor() != NULL) { ftk_input_method_preeditor_destroy(ftk_default_input_method_preeditor()); ftk_set_input_method_preeditor(NULL); } if(ftk_default_wnd_manager() != NULL) { ftk_wnd_manager_destroy(ftk_default_wnd_manager()); ftk_set_wnd_manager(NULL); } if(ftk_default_main_loop() != NULL) { ftk_main_loop_destroy(ftk_default_main_loop()); ftk_set_main_loop(NULL); } if(ftk_default_sources_manager() != NULL) { ftk_sources_manager_destroy(ftk_default_sources_manager()); ftk_set_sources_manager(NULL); } if(ftk_default_bitmap_factory() != NULL) { ftk_bitmap_factory_destroy(ftk_default_bitmap_factory()); ftk_set_bitmap_factory(NULL); } if(ftk_default_text_layout() != NULL) { ftk_text_layout_destroy(ftk_default_text_layout()); ftk_set_text_layout(NULL); } if(ftk_default_font() != NULL) { ftk_font_destroy(ftk_default_font()); ftk_set_font(NULL); } if(ftk_default_display() != NULL) { ftk_display_destroy(ftk_default_display()); ftk_set_display(NULL); } if(ftk_default_theme() != NULL) { ftk_theme_destroy(ftk_default_theme()); ftk_set_theme(NULL); } if(ftk_shared_canvas() != NULL) { ftk_canvas_destroy(ftk_shared_canvas()); ftk_set_shared_canvas(NULL); } if(ftk_default_input_method_manager() != NULL) { ftk_input_method_manager_destroy(ftk_default_input_method_manager()); ftk_set_input_method_manager(NULL); } if(ftk_default_config() != NULL) { ftk_config_destroy(ftk_default_config()); ftk_set_config(NULL); } ftk_platform_deinit(); #ifndef USE_STD_MALLOC if(ftk_default_allocator() != NULL) { ftk_allocator_destroy(ftk_default_allocator()); ftk_set_allocator(NULL); } #endif ftk_logd("%s: ftk exit.\n", __func__); return; }