int main(int ac, char **av) { t_main c; int res; c.connect = FALSE; c.m = init_gtk(&ac, &av); c.start = 0; c.end = 0; while (1) { if (c.connect == TRUE) do_select(&c); gtk_main_iteration(); if (!c.m->buffer) continue; c.tab = str_to_wordtab((char *)c.m->buffer); if ((res = gere_cmd(&c)) == -1) aff_msg(c.m, "Usage: /server host[:port]\n"); else if (!res) send_serv(c.m, c.m->buffer, c.sfd); gtk_widget_show_all(c.m->main_win); free_tab(c.tab); c.m->buffer = xfree(c.m->buffer); } return (EXIT_SUCCESS); }
void init(const char* name, int desktop) { int argc = 0; char *argv[] = { "" }; gtk_init(&argc, (char***)&argv); tray_name = strdup(name); reset_menu(); if (desktop == 2) { //GNOME init_gtk(); } if (desktop == 3) { //Unity init_indicator(); } if (desktop == 4) { //generic if (init_indicator() != 0) { init_gtk(); } } }
int main(int argc, char **argv) { t_gmine gmine; gl_gmine = &gmine; init_gtk(argc, argv, &gmine); init_main(&gmine); init_table(&gmine); if ((gmine.buttons = malloc(gmine.x * gmine.y * sizeof(t_button))) == NULL) exit(1); init_pixmap(&gmine); init_menu(&gmine); init_buttons(&gmine); init_mines(&gmine); init_text(&gmine); gtk_timeout_add(1000, (GtkFunction) m_timer, &gmine); gtk_widget_show_all(gmine.window); gtk_main(); return (0); }
/* * Simple "main" function for multiple platforms. * * Note the special "--" option which terminates the processing of * standard options. All non-standard options (if any) are passed * directly to the "init_xxx()" function. */ int main(int argc, char *argv[]) { int i; bool done = FALSE; bool new_game = FALSE; int show_score = 0; cptr mstr = NULL; bool args = TRUE; /* Save the "program name" XXX XXX XXX */ argv0 = argv[0]; #ifdef USE_286 /* Attempt to use XMS (or EMS) memory for swap space */ if (_OvrInitExt(0L, 0L)) { _OvrInitEms(0, 0, 64); } #endif #ifdef SET_UID /* Default permissions on files */ (void)umask(022); # ifdef SECURE /* Authenticate */ Authenticate(); # endif #endif /* Get the file paths */ init_stuff(); #ifdef SET_UID /* Get the user id (?) */ player_uid = getuid(); #ifdef VMS /* Mega-Hack -- Factor group id */ player_uid += (getgid() * 1000); #endif # ifdef SAFE_SETUID # ifdef _POSIX_SAVED_IDS /* Save some info for later */ player_euid = geteuid(); player_egid = getegid(); # endif # if 0 /* XXX XXX XXX */ /* Redundant setting necessary in case root is running the game */ /* If not root or game not setuid the following two calls do nothing */ if (setgid(getegid()) != 0) { quit("setgid(): cannot set permissions correctly!"); } if (setuid(geteuid()) != 0) { quit("setuid(): cannot set permissions correctly!"); } # endif # endif #endif #ifdef SET_UID /* Initialize the "time" checker */ if (check_time_init() || check_time()) { quit("The gates to Angband are closed (bad time)."); } /* Initialize the "load" checker */ if (check_load_init() || check_load()) { quit("The gates to Angband are closed (bad load)."); } /* Acquire the "user name" as a default player name */ #ifdef ANGBAND_2_8_1 user_name(player_name, player_uid); #else /* ANGBAND_2_8_1 */ user_name(op_ptr->full_name, player_uid); #endif /* ANGBAND_2_8_1 */ #ifdef PRIVATE_USER_PATH /* Create a directory for the users files. */ create_user_dir(); #endif /* PRIVATE_USER_PATH */ #endif /* SET_UID */ /* Process the command line arguments */ for (i = 1; args && (i < argc); i++) { /* Require proper options */ if (argv[i][0] != '-') game_usage(); /* Analyze option */ switch (argv[i][1]) { case 'N': case 'n': { new_game = TRUE; break; } case 'F': case 'f': { arg_fiddle = TRUE; break; } case 'W': case 'w': { arg_wizard = TRUE; break; } case 'V': case 'v': { arg_sound = TRUE; break; } case 'G': case 'g': { /* HACK - Graphics mode switches on the original tiles */ arg_graphics = GRAPHICS_ORIGINAL; break; } case 'R': case 'r': { arg_force_roguelike = TRUE; break; } case 'O': case 'o': { arg_force_original = TRUE; break; } case 'S': case 's': { show_score = atoi(&argv[i][2]); if (show_score <= 0) show_score = 10; break; } case 'u': case 'U': { if (!argv[i][2]) game_usage(); #ifdef ANGBAND_2_8_1 strncpy(player_name, &argv[i][2], 32); player_name[31] = '\0'; #else /* ANGBAND_2_8_1 */ strncpy(op_ptr->full_name, &argv[i][2], 32); op_ptr->full_name[31] = '\0'; #endif /* ANGBAND_2_8_1 */ break; } case 'm': { if (!argv[i][2]) game_usage(); mstr = &argv[i][2]; break; } case 'M': { arg_monochrome = TRUE; break; } case 'd': case 'D': { change_path(&argv[i][2]); break; } case '-': { argv[i] = argv[0]; argc = argc - i; argv = argv + i; args = FALSE; break; } default: { /* Default usage-help */ game_usage(); } } } /* Hack -- Forget standard args */ if (args) { argc = 1; argv[1] = NULL; } /* Process the player name */ process_player_name(TRUE); /* Install "quit" hook */ quit_aux = quit_hook; /* * Drop privs (so X11 will work correctly) * unless we are running the Linux-SVGALib version. * * (In which case we initialize after safe_setuid_grab() * is called.) */ safe_setuid_drop(); #ifdef USE_XAW /* Attempt to use the "main-xaw.c" support */ if (!done && (!mstr || (streq(mstr, "xaw")))) { if (0 == init_xaw(argc, argv)) { ANGBAND_SYS = "xaw"; done = TRUE; } } #endif #ifdef USE_X11 /* Attempt to use the "main-x11.c" support */ if (!done && (!mstr || (streq(mstr, "x11")))) { if (0 == init_x11(argc, argv)) { ANGBAND_SYS = "x11"; done = TRUE; } } #endif #ifdef USE_XPJ /* Attempt to use the "main-xpj.c" support */ if (!done && (!mstr || (streq(mstr, "xpj")))) { if (0 == init_xpj(argc, argv)) { ANGBAND_SYS = "xpj"; done = TRUE; } } #endif #ifdef USE_GTK /* Attempt to use the "main-gtk.c" support */ if (!done && (!mstr || (streq(mstr, "gtk")))) { if (0 == init_gtk((unsigned char*) &new_game, argc, argv)) { done = TRUE; } } #endif #ifdef USE_GCU /* Attempt to use the "main-gcu.c" support */ if (!done && (!mstr || (streq(mstr, "gcu")))) { if (0 == init_gcu()) { ANGBAND_SYS = "gcu"; done = TRUE; } } #endif #ifdef USE_CAP /* Attempt to use the "main-cap.c" support */ if (!done && (!mstr || (streq(mstr, "cap")))) { if (0 == init_cap(argc, argv)) { ANGBAND_SYS = "cap"; done = TRUE; } } #endif #ifdef USE_DOS /* Attempt to use the "main-dos.c" support */ if (!done && (!mstr || (streq(mstr, "dos")))) { if (0 == init_dos()) { ANGBAND_SYS = "dos"; done = TRUE; } } #endif #ifdef USE_IBM /* Attempt to use the "main-ibm.c" support */ if (!done && (!mstr || (streq(mstr, "ibm")))) { if (0 == init_ibm()) { ANGBAND_SYS = "ibm"; done = TRUE; } } #endif #ifdef USE_EMX /* Attempt to use the "main-emx.c" support */ if (!done && (!mstr || (streq(mstr, "emx")))) { if (0 == init_emx()) { ANGBAND_SYS = "emx"; done = TRUE; } } #endif #ifdef USE_SLA /* Attempt to use the "main-sla.c" support */ if (!done && (!mstr || (streq(mstr, "sla")))) { if (0 == init_sla()) { ANGBAND_SYS = "sla"; done = TRUE; } } #endif #ifdef USE_AMI /* Attempt to use the "main-ami.c" support */ if (!done && (!mstr || (streq(mstr, "ami")))) { if (0 == init_ami()) { ANGBAND_SYS = "ami"; done = TRUE; } } #endif #ifdef USE_VME /* Attempt to use the "main-vme.c" support */ if (!done && (!mstr || (streq(mstr, "vme")))) { if (0 == init_vme()) { ANGBAND_SYS = "vme"; done = TRUE; } } #endif #ifdef USE_VCS /* Attempt to use the "main-vcs.c" support */ if (!done && (!mstr || (streq(mstr, "vcs")))) { if (0 == init_vcs(argc, argv)) { ANGBAND_SYS = "vcs"; done = TRUE; } } #endif /* USE_VCS */ /* Grab privs (dropped above for X11) */ safe_setuid_grab(); #ifdef USE_LSL /* Attempt to use the "main-lsl.c" support */ if (!done && (!mstr || (streq(mstr, "lsl")))) { if (0 == init_lsl()) { ANGBAND_SYS = "lsl"; done = TRUE; } } #endif /* Make sure we have a display! */ if (!done) quit("Unable to prepare any 'display module'!"); /* Hack -- If requested, display scores and quit */ if (show_score > 0) display_scores(0, show_score); /* Gtk initializes earlier */ if (!streq(ANGBAND_SYS, "gtk")) { /* Catch nasty signals */ signals_init(); /* Initialize */ init_angband(); } /* Wait for response */ pause_line(23); /* Play the game */ play_game(new_game); /* Quit */ quit(NULL); /* Exit */ return (0); }
GtkWidget *snd_as_widget(int argc, char **argv, GtkWidget *parent, void (*error_func)(const char *msg)) { #else void snd_doit(int argc, char **argv) { #endif GtkWidget *shell; int i; #ifdef SND_AS_WIDGET set_error_display(error_func); ss = snd_main(argc, argv); #else gtk_init(&argc, &argv); #if (!HAVE_GTK_3) #ifndef HAVE_OSX gdk_set_locale(); #endif #endif #endif ss->channel_min_height = CHANNEL_MIN_HEIGHT; ss->Graph_Cursor = DEFAULT_GRAPH_CURSOR; #ifndef SND_AS_WIDGET shell = gtk_window_new(GTK_WINDOW_TOPLEVEL); sg_make_resizable(shell); #endif auto_open_files = argc-1; if (argc > 1) auto_open_file_names = (char **)(argv + 1); ss->startup_title = mus_strdup("snd"); set_sound_style(SOUNDS_VERTICAL); for (i = 1; i < argc; i++) if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-horizontal") == 0) || (strcmp(argv[i], "--horizontal") == 0)) set_sound_style(SOUNDS_HORIZONTAL); else if ((strcmp(argv[i], "-v") == 0) || (strcmp(argv[i], "-vertical") == 0) || (strcmp(argv[i], "--vertical") == 0)) set_sound_style(SOUNDS_VERTICAL); else if ((strcmp(argv[i], "-notebook") == 0) || (strcmp(argv[i], "--notebook") == 0)) set_sound_style(SOUNDS_IN_NOTEBOOK); else if ((strcmp(argv[i], "-separate") == 0) || (strcmp(argv[i], "--separate") == 0)) set_sound_style(SOUNDS_IN_SEPARATE_WINDOWS); else if (strcmp(argv[i], "-noglob") == 0) noglob = true; else if (strcmp(argv[i], "-noinit") == 0) noinit = true; else if (strcmp(argv[i], "-nostdin") == 0) nostdin = true; else if ((strcmp(argv[i], "-b") == 0) || (strcmp(argv[i], "-batch") == 0) || (strcmp(argv[i], "--batch") == 0)) batch = true; else if (strcmp(argv[i], "--features") == 0) /* testing (compsnd) */ check_features_list(argv[i + 1]); ss->batch_mode = batch; set_auto_resize(AUTO_RESIZE_DEFAULT); ss->zoom_slider_width = ZOOM_SLIDER_WIDTH; ss->position_slider_width = POSITION_SLIDER_WIDTH; ss->channel_sash_indent = CHANNEL_SASH_INDENT; /* not currently used */ ss->channel_sash_size = CHANNEL_SASH_SIZE; ss->sash_size = SASH_SIZE; ss->sash_indent = SASH_INDENT; ss->toggle_size = TOGGLE_SIZE; ss->graph_is_active = false; ss->bg_gradient = 0.05; ss->white = WHITE_COLOR; ss->black = BLACK_COLOR; ss->light_blue = LIGHT_BLUE_COLOR; ss->lighter_blue = LIGHTER_BLUE_COLOR; ss->red = RED_COLOR; ss->green = GREEN_COLOR; ss->blue = BLUE_COLOR; ss->yellow = YELLOW_COLOR; ss->highlight_color = HIGHLIGHT_COLOR; ss->basic_color = BASIC_COLOR; ss->position_color = POSITION_COLOR; ss->zoom_color = ZOOM_COLOR; ss->cursor_color = CURSOR_COLOR; ss->selection_color = SELECTION_COLOR; ss->mix_color = MIX_COLOR; ss->enved_waveform_color = ENVED_WAVEFORM_COLOR; ss->filter_control_waveform_color = FILTER_CONTROL_WAVEFORM_COLOR; ss->listener_color = LISTENER_COLOR; ss->listener_text_color = LISTENER_TEXT_COLOR; ss->graph_color = GRAPH_COLOR; ss->selected_graph_color = SELECTED_GRAPH_COLOR; ss->data_color = DATA_COLOR; ss->selected_data_color = SELECTED_DATA_COLOR; ss->mark_color = MARK_COLOR; ss->sash_color = SASH_COLOR; ss->text_focus_color = TEXT_FOCUS_COLOR; ss->grid_color = get_in_between_color(ss->data_color, ss->graph_color); ss->selected_grid_color = get_in_between_color(ss->selected_data_color, ss->selected_graph_color); ss->axis_color_set = false; ss->orig_data_color = ss->data_color; ss->orig_selected_data_color = ss->selected_data_color; ss->orig_mark_color = ss->mark_color; ss->orig_mix_color = ss->mix_color; ss->orig_graph_color = ss->graph_color; ss->orig_selected_graph_color = ss->selected_graph_color; ss->orig_listener_color = ss->listener_color; ss->orig_listener_text_color = ss->listener_text_color; ss->orig_cursor_color = ss->cursor_color; ss->orig_basic_color = ss->basic_color; ss->orig_selection_color = ss->selection_color; ss->orig_zoom_color = ss->zoom_color; ss->orig_position_color = ss->position_color; ss->orig_highlight_color = ss->highlight_color; if ((!(set_tiny_font(DEFAULT_TINY_FONT))) && (!(set_tiny_font(FALLBACK_FONT)))) fprintf(stderr, "can't find tiny font: %s", DEFAULT_TINY_FONT); if ((!(set_axis_label_font(DEFAULT_AXIS_LABEL_FONT))) && (!(set_axis_label_font(FALLBACK_FONT)))) fprintf(stderr, "can't find axis label font: %s", DEFAULT_AXIS_LABEL_FONT); if ((!(set_axis_numbers_font(DEFAULT_AXIS_NUMBERS_FONT))) && (!(set_axis_numbers_font(FALLBACK_FONT)))) fprintf(stderr, "can't find axis numbers font: %s", DEFAULT_AXIS_NUMBERS_FONT); if ((!(set_peaks_font(DEFAULT_PEAKS_FONT))) && (!(set_peaks_font(FALLBACK_FONT)))) fprintf(stderr, "can't find peaks font: %s", DEFAULT_PEAKS_FONT); if ((!(set_bold_peaks_font(DEFAULT_BOLD_PEAKS_FONT))) && (!(set_bold_peaks_font(FALLBACK_FONT)))) fprintf(stderr, "can't find bold peaks font: %s", DEFAULT_BOLD_PEAKS_FONT); if (!(set_listener_font(FALLBACK_FONT))) fprintf(stderr, "can't find listener font: %s", FALLBACK_FONT); ss->orig_axis_label_font = mus_strdup(axis_label_font(ss)); ss->orig_axis_numbers_font = mus_strdup(axis_numbers_font(ss)); ss->orig_peaks_font = mus_strdup(peaks_font(ss)); ss->orig_bold_peaks_font = mus_strdup(bold_peaks_font(ss)); ss->orig_listener_font = mus_strdup(listener_font(ss)); ss->orig_tiny_font = mus_strdup(tiny_font(ss)); #if (!HAVE_GTK_3) init_gtk(); #endif MAIN_PANE(ss) = gtk_vbox_new(false, 0); /* not homogenous, spacing 0 */ #if (HAVE_GTK_3) init_gtk(); #endif #ifdef SND_AS_WIDGET MAIN_SHELL(ss) = parent; shell = MAIN_PANE(ss); #else MAIN_SHELL(ss) = shell; gtk_container_add(GTK_CONTAINER(MAIN_SHELL(ss)), MAIN_PANE(ss)); #endif add_menu(); /* adds menubar to MAIN_PANE (via box_pack_start) */ if (with_toolbar(ss)) show_toolbar(); if (sound_style(ss) != SOUNDS_IN_SEPARATE_WINDOWS) { SOUND_PANE(ss) = gtk_vpaned_new(); gtk_container_set_border_width(GTK_CONTAINER(SOUND_PANE(ss)), 0); gtk_container_add(GTK_CONTAINER(MAIN_PANE(ss)), SOUND_PANE(ss)); if (sound_style(ss) == SOUNDS_IN_NOTEBOOK) { SOUND_PANE_BOX(ss) = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(SOUND_PANE_BOX(ss)), GTK_POS_TOP); SG_SIGNAL_CONNECT(SOUND_PANE_BOX(ss), "switch_page", notebook_switch_page, NULL); } else { if (sound_style(ss) == SOUNDS_HORIZONTAL) SOUND_PANE_BOX(ss) = gtk_hbox_new(false, 0); else SOUND_PANE_BOX(ss) = gtk_vbox_new(false, 0); } gtk_paned_add1(GTK_PANED(SOUND_PANE(ss)), SOUND_PANE_BOX(ss)); gtk_widget_show(SOUND_PANE_BOX(ss)); gtk_widget_show(SOUND_PANE(ss)); } gtk_widget_show(MAIN_PANE(ss)); gtk_widget_show(MAIN_SHELL(ss)); #ifndef SND_AS_WIDGET #if HAVE_GTK_ADJUSTMENT_GET_UPPER MAIN_WINDOW(ss) = gtk_widget_get_window(MAIN_SHELL(ss)); #else MAIN_WINDOW(ss) = MAIN_SHELL(ss)->window; #endif #else MAIN_WINDOW(ss) = gtk_widget_get_parent_window(MAIN_SHELL(ss)); #endif setup_gcs(); if (batch) gtk_widget_hide(MAIN_SHELL(ss)); else gdk_window_resize(WIDGET_TO_WINDOW(MAIN_SHELL(ss)), INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT); startup_funcs(); #if HAVE_SETJMP_H #if MUS_TRAP_SEGFAULT if (sigsetjmp(envHandleEventsLoop, 1)) { if (!(ss->exiting)) snd_error_without_format("Caught seg fault (will try to continue):\n"); else { snd_error_without_format("Caught seg fault while trying to exit.\n"); exit(0); } } #endif if (setjmp(top_level_jump)) { if (!(ss->jump_ok)) snd_error_without_format("Caught top level error (will try to continue):\n"); else ss->jump_ok = false; } #endif if (ss->startup_errors) { post_it("Error in initialization", ss->startup_errors); free(ss->startup_errors); ss->startup_errors = NULL; } #if HAVE_GTK_3 set_basic_color(ss->basic_color); color_listener(ss->listener_color); color_chan_components(ss->zoom_color, COLOR_ZOOM); color_chan_components(ss->position_color, COLOR_POSITION); #endif #ifndef SND_AS_WIDGET set_up_icon(); gtk_main(); #else return(shell); #endif }
static void run( const gchar * name, gint nparams, // !!! Always 3 for INTERACTIVE, not lengthof(param)? const GimpParam * param, gint * nreturn_vals, GimpParam ** return_vals) { static GimpParam values[1]; // return values persist after run() returns Parameters parameters; gboolean ok; /* Unless anything goes wrong, result is success */ *nreturn_vals = 1; *return_vals = values; values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = GIMP_PDB_SUCCESS; /* Initialize i18n support */ #if defined(G_OS_WIN32) bindtextdomain (GETTEXT_PACKAGE, gimp_locale_directory()); #else bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); #endif #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif textdomain (GETTEXT_PACKAGE); /* Don't really need the drawable or its tiles until we get to the engine. */ gint32 drawable_id; drawable_id = param[2].data.d_drawable; /* Assert the image type is OK because Gimp checked it. */ /* Deal with run mode */ ok = FALSE; switch(param[0].data.d_int32) { case GIMP_RUN_INTERACTIVE : get_last_parameters(¶meters, drawable_id, RESYNTH_CONTROLS_PDB_NAME ); init_gtk(); /* GUI dialog. */ ok = get_parameters_by_asking(¶meters,drawable_id); if (ok) /* Not canceled and not an exception. */ set_last_parameters(¶meters, drawable_id); break; case GIMP_RUN_NONINTERACTIVE : /* GUI CAN be called noninteractively, in batch mode or otherwise. */ ok = get_parameters_from_list(¶meters, nparams, param); break; case GIMP_RUN_WITH_LAST_VALS : ok = get_last_parameters(¶meters,drawable_id, RESYNTH_CONTROLS_PDB_NAME); break; } if (!ok) { /* No message displayed here because it is usually Cancel button, else the resynthesizer control panel GUI already displayed an error message? */ values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; return; } /* Prepare params for engine: augment passed params with user's choices. */ static GimpParam temp[RESYNTH_PARAMETER_COUNT]; set_parameters_to_list(¶meters, param, nparams, GIMP_RUN_NONINTERACTIVE, temp); /* Call resynthesizer engine. */ GimpParam * engine_result; gint engine_n_return_vals; engine_result = gimp_run_procedure2( RESYNTH_ENGINE_PDB_NAME, &engine_n_return_vals, RESYNTH_PARAMETER_COUNT, /* !!! Not nparams */ temp ); /* Always a status. */ if (engine_result[0].data.d_status != GIMP_PDB_SUCCESS) { /* Reraise engine error. */ *nreturn_vals = engine_n_return_vals; *return_vals = engine_result; } else { /* Free engine result, return our own. */ gimp_destroy_params(engine_result, engine_n_return_vals); } }