void client_run( void ) { #ifdef NETWORK_ENABLED /* init UDP socket */ sys_printf = client_printf_info; net_init( atoi(config.local_port) ); sys_printf = printf; client_add_chatter( _("Press 'Connect' to connect to a game server."), 1 ); client_state = CLIENT_NONE; client_recv_limit = config.recv_limit; gui_enable_event_filter(); gui_widget_show( dlg_chatroom ); stk_display_fade( STK_FADE_IN, STK_FADE_DEFAULT_TIME ); gui_run( dlg_chatroom ); stk_display_fade( STK_FADE_OUT, STK_FADE_DEFAULT_TIME ); gui_disable_event_filter(); if ( client_is_connected ) { /* tell server we are off */ client_disconnect(); /* finalize UDP socket */ socket_print_stats( &client ); } net_shutdown(); #endif }
int main(int argc, char **argv) { #if ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); g_atexit(gdk_threads_leave); read_opts_preinit(&argc, &argv); hash_init(); g_atexit(hash_deinit); gui_init(opts.datadir ? opts.datadir : DATADIR); g_atexit(gui_deinit); list_init(); prefs_init(); g_atexit(prefs_deinit); read_opts_postinit(); gui_run(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { gui_initialize(&argc, &argv); nu_cities = 100; srandom(0); initialize_cities(); gui_create_window_layout(); gui_draw_window(); gui_run(); }
int run(int argc, char **argv) { clock_t start = clock(); printf("Running...\n"); fflush(stdout); int ret; if (argc >= 2 && strcmp(argv[1], "-c") == 0) { ret = lcsfile_run((const char**)&argv[2]); } else if (argc >= 2 && strcmp(argv[1], "-g") == 0) { ret = doGenerate(argc, argv); } else { ret = gui_run(); } clock_t stop = clock(); double elapsed = ((double) (stop - start)) / CLOCKS_PER_SEC; printf("Done (%.2fs).\n", elapsed); return ret; }
int main(int argc, char **argv) { gtk_test_init(&argc, &argv); hash_init(); resources_register_resource(); gui_init(); list_init(); // Ignore user input during testing gtk_widget_set_sensitive(GTK_WIDGET(gui.window), false); gdk_threads_add_idle((GSourceFunc)test_run, NULL); gui_run(); g_assert_not_reached(); return EXIT_FAILURE; }
// Entry point int main (int argc, char *argv[]) { GList *list, *file; gchar *dir; int ret = 0; // Get initial dir: dir = get_initial_dir(argc, argv); // Get file list for initial dir: if ((list = filelist_create(dir)) == NULL) { ret = 1; goto out0; } // Get the initial file within the dir: if (!(file = get_initial_file(argc, argv, dir, list))) { ret = 1; goto out1; } // Scan to next image: if (!(file = filelist_scan_forward(&list, file)) && !(file = filelist_scan_backward(&list, g_list_last(list)))) { ret = 1; goto out1; } // Initialize GUI layer: gui_init(argc, argv); // Start the GUI on this file: gui_run(&list, file, dir); out1: filelist_destroy(list); out0: g_free(dir); return ret; }
void gui_mode(int argc, char *argv[]) { osso_context_t *osso_context; char *versionstring; AppData *appdata = g_new(AppData, 1); appdata->runmode = GUI; gtk_init(&argc, &argv); /* register OSSO service */ osso_context = osso_initialize(NAME, VERSION, TRUE, NULL); if (! osso_context) fprintf(stderr, "Could not initialize OSSO."); appdata->playlist = playlist_new(); appdata->decoder = decoder_new(); appdata->stream = NULL; appdata->gui = gui_new(appdata->playlist); versionstring = g_strconcat(FULLNAME, " ", VERSION, NULL); gui_set_title(appdata->gui, "", versionstring, ""); g_free(versionstring); /* setup callbacks */ playlist_set_play_cb(appdata->playlist, play_cb, (void *) appdata); /* setup GUI callbacks */ gui_set_open_cb(appdata->gui, open_cb, (void *) appdata); gui_set_volume_cb(appdata->gui, volume_cb, (void *) appdata); gui_set_seek_cb(appdata->gui, seek_cb, (void *) appdata); gui_set_control_cb(appdata->gui, control_cb, (void *) appdata); g_timeout_add(500, (GSourceFunc) status_cb, appdata); gui_run(); }
int main(int argc, char **argv) { struct sigaction action; int i; action.sa_handler = signal_handler; sigaction(SIGABRT, &action, NULL); sigaction(SIGTERM, &action, NULL); for(i = 1; i < argc; i++){ if(!strcmp(argv[i], "-f")){ global_force = 1; }else if(!strcmp(argv[i], "-d")){ global_debug = 1; }else{ fprintf(stderr, "Usage: %s [-f] [-d]\n" " -f: Don't prompt for lsof and strace\n" " -d: Debug mode\n" , *argv); return 1; } } extra_init(); gui_init(); proclist = proc_init(); gui_run(proclist); gui_term(); proc_cleanup(proclist); return 0; }
int App::run() { #ifdef ENABLE_UPDATER app::CheckUpdateThreadLauncher checkUpdate; #endif // Initialize GUI interface if (isGui()) { View* view; Editor* editor; PRINTF("GUI mode\n"); // Setup the GUI screen jmouse_set_cursor(JI_CURSOR_NORMAL); gui::Manager::getDefault()->invalidate(); // Load main window top_window = static_cast<Frame*>(load_widget("main_window.xml", "main_window")); box_menubar = top_window->findChild("menubar"); box_editors = top_window->findChild("editor"); box_colorbar = top_window->findChild("colorbar"); box_toolbar = top_window->findChild("toolbar"); box_statusbar = top_window->findChild("statusbar"); box_tabsbar = top_window->findChild("tabsbar"); menubar = new MenuBar(); statusbar = new StatusBar(); colorbar = new ColorBar(box_colorbar->getAlign()); toolbar = toolbar_new(); tabsbar = new Tabs(m_tabsDelegate = new AppTabsDelegate()); view = new EditorView(EditorView::CurrentEditorMode); editor = create_new_editor(); // configure all widgets to expansives menubar->setExpansive(true); statusbar->setExpansive(true); colorbar->setExpansive(true); toolbar->setExpansive(true); tabsbar->setExpansive(true); view->setExpansive(true); /* prepare the first editor */ view->attachToView(editor); /* setup the menus */ menubar->setMenu(get_root_menu()); /* start text of status bar */ app_default_statusbar_message(); /* add the widgets in the boxes */ if (box_menubar) box_menubar->addChild(menubar); if (box_editors) box_editors->addChild(view); if (box_colorbar) box_colorbar->addChild(colorbar); if (box_toolbar) box_toolbar->addChild(toolbar); if (box_statusbar) box_statusbar->addChild(statusbar); if (box_tabsbar) box_tabsbar->addChild(tabsbar); /* prepare the window */ top_window->remap_window(); // Create the list of tabs app_rebuild_documents_tabs(); app_rebuild_recent_list(); // Set current editor set_current_editor(editor); // Open the window top_window->open_window(); // Redraw the whole screen. gui::Manager::getDefault()->invalidate(); } /* set background mode for non-GUI modes */ /* if (!(ase_mode & MODE_GUI)) */ /* set_display_switch_mode(SWITCH_BACKAMNESIA); */ set_display_switch_mode(SWITCH_BACKGROUND); // procress options PRINTF("Processing options...\n"); ASSERT(m_checkArgs != NULL); { Console console; for (CheckArgs::iterator it = m_checkArgs->begin(); it != m_checkArgs->end(); ++it) { CheckArgs::Option* option = *it; switch (option->type()) { case CheckArgs::Option::OpenSprite: { // Load the sprite Document* document = load_document(option->data().c_str()); if (!document) { if (!isGui()) console.printf("Error loading file \"%s\"\n", option->data().c_str()); } else { // Mount and select the sprite UIContext* context = UIContext::instance(); context->addDocument(document); context->setActiveDocument(document); if (isGui()) { // Show it set_document_in_more_reliable_editor(context->getFirstDocument()); // Recent file getRecentFiles()->addRecentFile(option->data().c_str()); } } break; } } } delete m_checkArgs; m_checkArgs = NULL; } // Run the GUI if (isGui()) { // Support to drop files from Windows explorer install_drop_files(); #ifdef ENABLE_UPDATER // Launch the thread to check for updates. checkUpdate.launch(); #endif // Run the GUI main message loop gui_run(); // Uninstall support to drop files uninstall_drop_files(); // Remove the root-menu from the menu-bar (because the rootmenu // module should destroy it). menubar->setMenu(NULL); // Delete all editors first because they used signals from other // widgets (e.g. color bar). delete box_editors; // Destroy mini-editor. exit_module_editors(); // Destroy the top-window delete top_window; top_window = NULL; } return 0; }
int main(int argc, char **argv) { gui_initialize(&argc, &argv); gui_create_window_layout(); gui_draw_window(); if (argc == 2 && strcmp(argv[1], "--help") == 0) { printf("texview -- a texture and image file viewer.\n" "Usage: texview <filename1> <filename2>\n" "<filename2> is optional.\n"); exit(1); } option_quiet = 1; current_nu_image_sets = 0; if (argc >= 2) { source_filename[0] = argv[1]; source_filetype[0] = determine_filename_type(source_filename[0]); if (!(source_filetype[0] & FILE_TYPE_TEXTURE_BIT) && !(source_filetype[0] & FILE_TYPE_IMAGE_BIT)) { printf("Error -- expected image or texture filename as argument.\n"); exit(1); } if (!file_exists(source_filename[0])) { printf("Error -- source file %s doesn't exist or is unreadable.\n", source_filename[0]); exit(1); } current_nu_image_sets = 1; } if (argc >= 3) { source_filename[1] = argv[2]; source_filetype[1] = determine_filename_type(source_filename[1]); if (!(source_filetype[1] & FILE_TYPE_TEXTURE_BIT) && !(source_filetype[1] & FILE_TYPE_IMAGE_BIT)) { printf("Error -- expected image or texture filename as second argument.\n"); exit(1); } if (!file_exists(source_filename[1])) { printf("Error -- source file %s doesn't exist or is unreadable.\n", source_filename[1]); exit(1); } current_nu_image_sets = 2; } for (int j = 0; j < current_nu_image_sets; j++) { current_file_type[j] = source_filetype[j]; if (source_filetype[j] & FILE_TYPE_TEXTURE_BIT) { current_nu_mipmaps[j] = load_texture(source_filename[j], source_filetype[j], 32, ¤t_texture[j][0]); for (int i = 0 ; i < current_nu_mipmaps[j]; i++) convert_texture_to_image(¤t_texture[j][i], ¤t_image[j][i]); } else { load_image(source_filename[j], source_filetype[j], ¤t_image[j][0]); current_nu_mipmaps[j] = 1; } if (current_nu_mipmaps[j] > 1) printf("Found %d mipmap levels.\n", current_nu_mipmaps[j]); } current_rmse[0] = -1.0; if (current_nu_image_sets > 1) current_rmse[0] = compare_images(¤t_image[0][0], ¤t_image[1][0]); for (int i = 0; i < current_nu_image_sets; i++) { if (!current_image[i][0].is_half_float && current_image[i][0].bits_per_component == 8 && current_image[i][0].nu_components > 2) convert_image_set(i); } gui_zoom_fit_to_window(); for (int i = 0; i < current_nu_image_sets; i++) gui_create_base_surface(i); gui_draw_and_show_window(); gui_run(); }
int main(int argc, char **argv) { cardmanager_t* CTX; cardreader_t* READER; int opt; int opt_index = 0; int run_gui = 1; char* reader_name = NULL; char* exec_command = NULL; #ifndef _WIN32 SSL_load_error_strings(); #endif signal(SIGSEGV, save_what_can_be_saved); path_config_init(); log_open_file(); while ((opt = getopt_long(argc,argv,"r:e:vh",long_options,&opt_index))!=-1) { switch (opt) { case 'r': reader_name = g_strdup(optarg); break; case 'e': exec_command = optarg; break; case 'v': display_readers_and_version(); run_gui = 0; break; default: display_help(argv[0]); run_gui = 0; } } if (run_gui) { /* if we want threads: gdk_threads_init(); gdk_threads_enter(); */ gui_init(&argc,&argv); gui_create(); log_printf(LOG_INFO,"Running %s",system_string_info()); install_dot_file(); luax_init(); CTX = cardmanager_new(); if (reader_name == NULL) { reader_name = gui_select_reader(cardmanager_count_readers(CTX), cardmanager_reader_name_list(CTX)); } READER = cardreader_new(reader_name); cardmanager_free(CTX); if (READER) { luax_set_card_reader(READER); cardreader_set_callback(READER,gui_readerview_print,NULL); if (exec_command) g_idle_add(run_command_from_cli,exec_command); else update_cardpeek(); /*else g_idle_add(run_update_checks,NULL); */ gui_run(); cardreader_free(READER); } else { fprintf(stderr,"Failed to open smart card reader '%s'.\n",reader_name); log_printf(LOG_ERROR,"Failed to open smart card reader '%s'.", reader_name); } luax_config_table_save(); luax_release(); /* if we want threads: gdk_threads_leave(); */ } if (reader_name) g_free(reader_name); log_close_file(); path_config_release(); ERR_free_strings(); return 0; }