/* * set up handlers for audio/ISDN input */ void session_io_handlers_start(session_t *session) { if (!(session->option_release_devices && (session->state == STATE_READY || session->state == STATE_RINGING_QUIET))) { session->gtk_audio_input_tag = gtk_input_add_full(session->audio_fd_in, GDK_INPUT_READ, gtk_handle_audio_input, NULL, (gpointer) session, NULL); } session->gtk_isdn_input_tag = gtk_input_add_full(session->isdn_fd, GDK_INPUT_READ, gtk_handle_isdn_input, NULL, (gpointer) session, NULL); /* server functionality */ session->gtk_local_input_tag = gtk_input_add_full(session->local_sock, GDK_INPUT_READ, server_handle_local_input, NULL, (gpointer) session, NULL); }
/* * Start an effect (effect_t) playing on the sound device * * on kind == EFFECT_SOUNDFILE, session->effect_filename should be * initialized so that session_effect_stop can free() it afterwards */ void session_effect_start(session_t *session, enum effect_t kind) { if (kind == EFFECT_SOUNDFILE) { session->effect_sfinfo.format = 0; if (!(session->effect_sndfile = sf_open(session->effect_filename, SFM_READ, &session->effect_sfinfo))) { fprintf(stderr, "Error on opening sound file.\n"); } session->effect_sndfile_buffer_frames = session->fragment_size_out / session->audio_sample_size_out * session->effect_sfinfo.samplerate / session->audio_speed_out; session->effect_sndfile_buffer = (short*) malloc (sizeof(short) * (session->effect_sndfile_buffer_frames + 1) * /* doubled dummy at end */ session->effect_sfinfo.channels); } session->effect_tag = gtk_input_add_full(session->audio_fd_out, GDK_INPUT_WRITE, session_effect_callback, NULL, (gpointer) session, NULL); session->effect = kind; session->effect_pos = 0; }
/* * Callback: reinitialize isdn input watchdog */ static gboolean gtk_isdn_input_defer_timeout(session_t* session) { session->gtk_isdn_input_tag = gtk_input_add_full(session->isdn_fd, GDK_INPUT_READ, gtk_handle_isdn_input, NULL, (gpointer) session, NULL); return FALSE; /* don't call me regularly */ }
void CGtkSocket::selectEvent(int event) { if (input_handler_id) gtk_input_remove(input_handler_id); GdkInputCondition condition; condition = (GdkInputCondition)0; if (event & Socket::READ) condition = (GdkInputCondition)(condition | GDK_INPUT_READ); if (event & Socket::WRITE) condition = (GdkInputCondition)(condition | GDK_INPUT_WRITE); if (event & Socket::EXCEPTION) condition = (GdkInputCondition)(condition | GDK_INPUT_EXCEPTION); input_handler_id = gtk_input_add_full(source, condition, (GdkInputFunction)on_input, NULL, this, NULL); }
static int lcrt_serial_connect(struct lcrt_terminal *lterminal) { struct lcrtc_user *user; struct lcrt_serial_tm *tserial; /* port baud_rate databit parity stopbit software_control hardware_control*/ char s_port[USERNAME_LEN]; int s_baud_rate,s_databit,s_parity,s_stopbit,s_software,s_hardware; debug_where(); if (lterminal == NULL) return -EINVAL; tserial = (struct lcrt_serial_tm *)calloc(1, sizeof(struct lcrt_serial_tm)); if (tserial == NULL) return -ENOMEM; user = lterminal->user; sscanf(user->password, "%s %d %d %d %d %d %d", s_port, &s_baud_rate, &s_databit, &s_parity, &s_stopbit, &s_software, &s_hardware); int fd ; fd = lcrt_serial_config(s_port, s_baud_rate,s_databit, s_parity,s_stopbit,s_software,s_hardware); if (fd <= 0) { lcrt_message_error(lterminal->parent->parent->window, lterminal->parent->config.value[LCRT_TM_SERIAL_ERROR], s_port, strerror(-fd)); free(tserial); return fd; } tserial->fd = fd; lterminal->private_data = tserial; tserial->input = gtk_input_add_full(fd, GDK_INPUT_READ, (GdkInputFunction)lcrt_serial_read, NULL, lterminal, NULL); tserial->commit = g_signal_connect(lterminal->terminal, "commit", G_CALLBACK(lcrt_serial_write), lterminal); lcrt_statusbar_set_user(lterminal->parent->parent->w_statusbar, lterminal->user); lcrt_terminal_set_connected_status(lterminal); return LCRTE_OK; }
int main (int argc, char *argv[]) { DVDResult_t res; char *msgq_str; program_name = argv[0]; #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); #endif if(argc==1) { fprintf(stderr, "Error: Do not start ogle_gui directly. Start ogle\n"); exit(1); } if(pipe(dvdpipe)) { FATAL("dvdpipe: %s", strerror(errno)); exit(1); } msgq_str = argv[2]; init_interpret_config(program_name, add_keybinding, set_dvd_path); interpret_config(); gtk_init(&argc, &argv); dvdpipe_handler_id = gtk_input_add_full(dvdpipe[0], GDK_INPUT_READ, dvdpipe_handler, NULL, NULL, NULL); // Make Solaris 8+24 displays work gdk_rgb_init(); gtk_widget_set_default_colormap(gdk_rgb_get_cmap()); gtk_widget_set_default_visual(gdk_rgb_get_visual()); // Initialize glade, and read in the glade file my_glade_setup(); res = DVDOpenNav(&nav, msgq_str); if(res != DVD_E_Ok ) { DVDPerror("DVDOpen", res); exit(1); } xsniff_init(msgq_str); audio_menu_new(); subpicture_menu_new(); app = get_glade_widget("app"); gtk_widget_show(app); menu_new(app); // If a filename is given on the command line, start immediately. if(argc == 4) { res = DVDSetDVDRoot(nav, argv[3]); if(res != DVD_E_Ok) { DVDPerror("main: DVDSetDVDRoot", res); } autoload_bookmark(); } gtk_main (); return 0; }
void on_data_available(gpointer tab, gint fd, GdkInputCondition cond) { GtkWidget *notebook, *top; gchar *buff = NULL; gsize len = 0; SESSION_STATE *session; session = g_object_get_data(G_OBJECT(tab), "session"); telnet_process(session->telnet, &buff, &len); //if nothing to process - don't process if( len > 0 ) process_text(session, buff, len); // if top != current window change title top = gtk_widget_get_toplevel(GTK_WIDGET(tab)); //if (top != interface_get_active_window()) { if (!gtk_window_is_active(GTK_WINDOW(top))) { gchar *icon; gtk_window_set_title(GTK_WINDOW(top), "### MudMagic ###"); icon = g_build_filename( mudmagic_data_directory(), "interface", "mudmagic2.xpm", NULL); gtk_window_set_icon_from_file(GTK_WINDOW(top), icon, NULL); g_free(icon); } if (session->telnet->fd < 0 ) // connection close occurs { GtkWidget *wid, *message; gchar *label; gint response; gtk_input_remove(session->input_event_id); session->input_event_id = -1; wid = g_object_get_data(G_OBJECT(session->tab), "input1_entry"); g_return_if_fail(wid != NULL); if ( ! gtk_entry_get_visibility (GTK_ENTRY(wid)) ) { interface_input_shadow(session, FALSE); gtk_entry_set_text(GTK_ENTRY(wid), ""); } while (1) { wid = interface_create_object_by_name ("dialog_connection_close"); if (wid == NULL) { g_warning ("can't create 'dialog_connection_close"); } message = interface_get_widget(wid, "connection_close_message"); if (message == NULL) { g_warning ("can't get 'dialog_connection_close"); } label = g_strdup_printf ("Connection to %s:%d has been close.", session->game_host, session->game_port); gtk_label_set_text(GTK_LABEL(message), label); g_free(label); response = gtk_dialog_run(GTK_DIALOG(wid)); gtk_widget_destroy(wid); if (response == 0) { // stay disconnect break; } if (response == 1) { // try to reconnect if (session->pconn) proxy_connection_close (session->pconn); session->pconn = proxy_connection_open( session->game_host, session->game_port, proxy_get_by_name (session->proxy, config->proxies) ); if (session->pconn) session->telnet->fd = session->pconn->sock; else session->telnet->fd = NO_CONNECTION; if (session->telnet->fd == NO_CONNECTION ) { interface_messagebox (GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, network_errmsg (session->telnet->fd)); continue; } session->input_event_id = gtk_input_add_full(session->telnet->fd, GDK_INPUT_READ,(GdkInputFunction)on_data_available, NULL, tab, NULL); break; } if (response == 2) { // close tab interface_remove_tab(tab); return; } } } // if tab != current tab change label color notebook = gtk_widget_get_ancestor(tab, GTK_TYPE_NOTEBOOK); if (notebook) { GtkWidget *label; GtkWidget *current_tab; current_tab = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), gtk_notebook_get_current_page (GTK_NOTEBOOK(notebook)) ); if (tab != current_tab) { label = gtk_notebook_get_tab_label(GTK_NOTEBOOK (notebook), GTK_WIDGET(tab)); if (label) { GtkWidget* icon; icon = g_object_get_data (G_OBJECT (label), "label_icon"); gtk_image_set_from_stock (GTK_IMAGE (icon), GTK_STOCK_NO, GTK_ICON_SIZE_MENU); } } } }