GdkFont * my_font_load (char *fontname) { GdkFont *font; char temp[256]; if (!*fontname) fontname = "fixed"; if (prefs.use_fontset) font = gdk_fontset_load (fontname); else font = gdk_font_load (fontname); if (!font) { snprintf (temp, sizeof (temp), _("Cannot open font:\n\n%s"), fontname); gtkutil_simpledialog (temp); font = gdk_font_load ("fixed"); if (!font) { g_error (_("gdk_font_load failed")); gtk_exit (0); } } return font; }
/* Terminate the program and return the given exit code to the caller. * This function will shut down the GUI and free all resources allocated for GTK. */ int clip_GTK_EXIT(ClipMachine * cm) { int err_code = _clip_parni(cm,1); gtk_exit(err_code); return 0; }
int quit_callback (GtkWidget *widget, gpointer data) { fprintf(stderr,"%s\n", (char *)data); gtk_exit(0); return(FALSE); }
void OnConfigClose(GtkWidget *widget, gpointer user_data) { GladeXML *xml = (GladeXML *)user_data; gtk_widget_destroy(glade_xml_get_widget(xml, "CfgWnd")); gtk_exit(0); }
gint init(GtkWidget *widget) { if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) { GdkFont *font; /* set viewport */ glViewport(0,0, widget->allocation.width, widget->allocation.height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,widget->allocation.width, 0,widget->allocation.height, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* generate font display lists */ fontbase = glGenLists( 128 ); font = gdk_font_load(fontname); if (!font) { g_print("Can't load font '%s'\n", fontname); gtk_exit(1); } gdk_gl_use_gdk_font(font, 0, 128, fontbase); fontheight = font->ascent+font->descent; gdk_font_unref(font); } return TRUE; }
static gint client_die (GnomeClient *client, gpointer client_data) { gtk_exit (0); return FALSE; }
static gboolean desktop_destroy(GtkWidget *desktop, gpointer user_data) { //TODO: Make sure to check whether they REALLY wanna quit gtk_exit(0); return FALSE; }
static void text_received_cb (GtkClipboard *clipboard, const char *text, gpointer data) { char *cpy; int i; if (text != NULL && strlen (text) > 2) { cpy = g_strdup (text); /* Remove trailing gunk */ i = strlen (cpy) - 1; while (i > 0 && cpy [i] == 10) { cpy [i] = '\0'; --i; } /* Remove excess whitespace. */ g_strstrip (cpy); /* Searchs for best in the PATH. */ execlp ("best", "best", "--no-tray", cpy, NULL); } gtk_exit (0); }
void safe_realloc (void **p, size_t siz) { void *r; if (siz == 0) { if (*p) { free (*p); *p = NULL; } return; } if (*p) r = (void *) realloc (*p, siz); else { /* realloc(NULL, nbytes) doesn't seem to work under SunOS 4.1.x */ r = (void *) malloc (siz); } if (!r) { g_print ("-E- Out of memory!"); sleep (1); gtk_exit (1); } *p = r; }
gboolean on_ieb_window_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { gtk_exit( 0 ); return FALSE; }
void callback(GtkWidget *w, gpointer data) { gint i; for(i=0; i<3; i++){ if(GTK_TOGGLE_BUTTON(button[i])->active) g_print("button %d pressed\n", i); } gtk_exit(0); }
void destroy( void ) { if( dn_shutdown ) { dn_shutdown( ); } gtk_exit( 0 ); }
//Handle updating the displayed image from a given midi message static void midi_update_image(int midi_note,int velocity) { if(velocity > 0) { switch(midi_note) { case C4: //printf("%c",event->keyval); update_image("c4.jpg"); break; case D4: //printf("%c",event->keyval); update_image("d4.jpg"); break; case E4: //printf("%c",event->keyval); update_image("e4.jpg"); break; case F4: //printf("%c",event->keyval); update_image("f4.jpg"); break; case G4: //printf("%c",event->keyval); update_image("g4.jpg"); break; case A5: //printf("%c",event->keyval); update_image("a5.jpg"); break; case B5: //printf("%c",event->keyval); update_image("b5.jpg"); break; case C5: //printf("%c",event->keyval); update_image("c5.jpg"); break; case 96: //printf("%c",event->keyval); gtk_exit(0); break; } } }
int interface_gtk_stop() { global_update = -1; GDK_THREADS_ENTER(); gdk_flush(); gtk_exit(0); // This is *NOT* clean :-( GDK_THREADS_LEAVE(); return 1; }
int main(int argc, char *argv[]) { GtkWidget *dialog; GtkWidget *dialog_wrapper; GtkWidget *select_interfaces_label; GtkWidget *ready_button; Interface_list interfaces; int i; gtk_init(&argc, &argv); g_set_application_name("Traffic Monitor"); /* Asking for interfaces to display */ dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); dialog_wrapper = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER (dialog), dialog_wrapper); select_interfaces_label = gtk_label_new("Select interfaces to display:"); gtk_box_pack_start(GTK_BOX(dialog_wrapper), select_interfaces_label, FALSE, FALSE, 0); interfaces = get_full_iflist(); interfaces.dialog = dialog; for(i = 0; i < interfaces.len; i++) { GtkWidget *select = gtk_check_button_new_with_label(interfaces.interface[i].ifname); interfaces.interface[i].select_widget = select; gtk_box_pack_start(GTK_BOX(dialog_wrapper), select, FALSE, FALSE, 0); } ready_button = gtk_button_new_with_label("Draw!"); gtk_box_pack_start(GTK_BOX(dialog_wrapper), ready_button, FALSE, FALSE, 0); g_signal_connect (ready_button, "clicked", G_CALLBACK (interfaces_selected), (gpointer) &interfaces); g_signal_connect (dialog, "destroy", G_CALLBACK (destroy), NULL); gtk_widget_show_all(dialog_wrapper); gtk_widget_show(GTK_WIDGET(dialog)); //printf("Active interfaces: %d\n", nif); gtk_main(); gtk_exit(0); return EXIT_SUCCESS; }
static void do_gtkdisplay(void) { GIOChannel *chan; struct imgrect *ir; /* have our main loop poll the pipe file descriptor */ chan = g_io_channel_unix_new(imgpipe_readfd); g_io_add_watch(chan, G_IO_IN | G_IO_ERR | G_IO_HUP, (GIOFunc)pipe_event, NULL); fcntl(imgpipe_readfd, F_SETFL, O_NONBLOCK); /* set up list of image rectangles. */ imgrects = xcalloc(nimgrects = 16, sizeof *imgrects); /* do some init thing */ gtk_init(0, NULL); gtk_widget_push_colormap(gdk_rgb_get_colormap()); /* Make our own window. */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request(window, DEFAULT_WIDTH + 2 * BORDER, DEFAULT_HEIGHT + 2 * BORDER); darea = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window), darea); gtk_widget_set_events(darea, GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK); g_signal_connect(G_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); g_signal_connect(G_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(destroy), NULL); g_signal_connect(G_OBJECT(darea), "expose-event", GTK_SIGNAL_FUNC(expose_event), NULL); g_signal_connect(G_OBJECT(darea), "configure_event", GTK_SIGNAL_FUNC(expose_event), NULL); /* mouse button press/release for saving images */ g_signal_connect(G_OBJECT(darea), "button_press_event", GTK_SIGNAL_FUNC(button_press_event), NULL); g_signal_connect(G_OBJECT(darea), "button_release_event", GTK_SIGNAL_FUNC(button_release_event), NULL); gtk_widget_show_all(window); gtk_main(); /* Get rid of all remaining images. */ for (ir = imgrects; ir < imgrects + nimgrects; ++ir) if (ir->filename) unlink(ir->filename); img_delete(backing_image); gtk_exit(0); return; /* NOTREACHED */ }
void *safe_calloc (size_t nmemb, size_t size) { void *p; if (!nmemb || !size) return NULL; if (!(p = calloc (nmemb, size))) { g_print ("Out of memory!"); sleep (1); gtk_exit (1); } return p; }
void clean_exit(const char *msg, ...) { va_list args; if ((msg != NULL) && !(GTK_IS_OBJECT(msg))) { va_start(args, msg); fprintf(stderr, PACKAGE ": "); vfprintf(stderr, msg, args); va_end(args); fflush(stderr); } gtk_exit(0); }
void SaveConfig(GtkWidget *widget, gpointer user_data) { GladeXML *xml = (GladeXML *)user_data; FILE *fp; int val; fp = fopen(CONFIG_FILENAME, WRITEBINARY); if (fp == NULL) { fprintf(stderr, "Unable to write to configuration file %s!\n", CONFIG_FILENAME); gtk_exit(0); } val = gtk_combo_box_get_active(GTK_COMBO_BOX(glade_xml_get_widget(xml, "cbVolume2"))); fprintf(fp, "\nVolume = %d\n", val); val = gtk_combo_box_get_active(GTK_COMBO_BOX(glade_xml_get_widget(xml, "cbInterpolation2"))); fprintf(fp, "\nUseInterpolation = %d\n", val); val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "chkXASpeed"))); fprintf(fp, "\nXAPitch = %d\n", val); val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "chkHiCompat"))); fprintf(fp, "\nHighCompMode = %d\n", val); val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "chkIRQWait"))); fprintf(fp, "\nSPUIRQWait = %d\n", val); val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "chkDisStereo"))); fprintf(fp, "\nDisStereo = %d\n", val); val = gtk_combo_box_get_active(GTK_COMBO_BOX(glade_xml_get_widget(xml, "cbReverb2"))); fprintf(fp, "\nUseReverb = %d\n", val); fclose(fp); gtk_exit(0); }
static int plug_removed(GtkWidget *widget, gpointer data) { static int cnt = 2; fprintf(stderr, "GtkPlug removed\n"); cnt--; if(cnt==0) { fprintf(stderr, "No GtkPlugs left, exiting.\n"); gtk_exit(0); } return(FALSE); /* TRUE would keep xsocket open */ }
void DestroyMessage (void) { gtk_widget_destroy (messagewindow); iyesno = 0; if (iquit == 1) { Play ("", 2); gtk_exit (0); } if (iselectdead == 1) { itype = 3; AskSave (); } }
void loader_show() { GtkWidget *loader = gtk_file_chooser_dialog_new("Open .lua File", NULL,GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); int res = gtk_dialog_run(GTK_DIALOG(loader)); if(res == GTK_RESPONSE_CANCEL) { gtk_exit(0); } if(res == GTK_RESPONSE_ACCEPT) { char *filename; filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(loader)); gtk_widget_destroy(loader); nldt_gizmo_load(filename); } }
int main (int argc, char **argv) { GtkWidget *window; gtk_init (&argc, &argv); gnome_vfs_init(); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); init_list (window); puts("showing..."); gtk_widget_show (window); puts("running..."); gtk_main(); puts("exiting..."); gtk_exit(0); return 0; }
int main(int argc, char *argv[]) { #if 0 GError *error = NULL; GtkWidget *window; if (gtk_init_with_args(&argc, &argv, NULL, options, NULL, &error) == FALSE) { if (error != NULL) { g_printerr("%s\n", error->message); g_error_free(error); } else g_printerr("An unknown error occurred\n"); gtk_exit(1); } g_set_application_name("Connection Manager Demo"); gtk_window_set_default_icon_name("network-wireless"); client = connman_client_new(); window = create_window(); connman_client_set_callback(client, status_callback, NULL); if (option_fullscreen == TRUE) gtk_window_fullscreen(GTK_WINDOW(window)); gtk_widget_show_all(window); gtk_main(); g_object_unref(client); #endif return 0; }
gboolean gtk_xpart_register( GtkXPart *part, const gchar *host_app_id, const gchar *host_obj_id) { dcop_data *reply_data; char *reply_type; dcop_data *data = dcop_data_ref( dcop_data_new() ); GtkXPartPrivate *d = (GtkXPartPrivate *)part->data; if(!P->client) fprintf(stderr, "register a dcop client first!\n"); dcop_marshal_string( data, dcop_client_app_id( P->client ) ); dcop_marshal_string( data, DCOP_ID(DCOP_OBJECT(part)) ); if ( !dcop_client_call( P->client, host_app_id, host_obj_id, "registerXPart(DCOPRef)", data, &reply_type, &reply_data ) ) { fprintf( stderr, "cannot register with shell %s / %s\n", host_app_id, host_obj_id ); gtk_exit( 1 ); } g_message( "back from registration call!" ); /*assert( strcmp( reply_type, "DCOPRef" ) == 0 );*/ #if 0 /* this is wrong. but as we have the ref anyway, let's ignore the return value*/ dcop_demarshal_string( data, &d->host_app_id ); dcop_demarshal_string( data, &d->host_obj_id ); printf("appid=%s, objid=%s\n", d->host_app_id, d->host_obj_id); #endif d->host_obj_id = g_strdup( host_obj_id ); d->host_app_id = g_strdup( host_app_id ); dcop_data_reset( reply_data ); dcop_data_deref( data ); g_message( "returning from gtk_xpart_register" ); return TRUE; }
/* Called to notify that an image display window has been closed */ void hdfsee_window_closed(DisplayWindow *dw) { size_t i; for ( i=0; i<main_n_windows; i++ ) { if ( main_window_list[i] == dw ) { size_t j; for ( j=i+1; j<main_n_windows; j++ ) { main_window_list[j] = main_window_list[j+1]; } } } main_n_windows--; if ( main_n_windows == 0 ) gtk_exit(0); }
gboolean on_print_scale_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { if( logined ) { printf( "logout\n" ); fflush( stdout ); while( getchar() != '\n'); while( getchar() != '\n'); } else { //因為沒有登入過,但是要通知機器作離開的動作 printf( "192.168.1.193\n"); fflush( stdout ); } printf( "bye\n" ); fflush( stdout ); gtk_exit( 0 ); return FALSE; }
/* * Función destruirNotasWidget() */ void destruirNotasWidget (void) { destruirNotas(&(datosAgenda.notas)); gtk_exit(0); }
/* Exits the window system. This should dismiss all windows, except the "window" used for raw_print(). str is printed if possible. */ void gnome_exit_nhwindows(const char *str) { gtk_exit (0); terminate(EXIT_SUCCESS); }
int main( int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *box1; GtkWidget *box2; GtkWidget *separator; GtkWidget *label; GtkWidget *quitbox; int which; /* Our init, don't forget this! :) */ gtk_init (&argc, &argv); if (argc != 2) { fprintf (stderr, "usage: packbox num, where num is 1, 2, or 3.\n"); /* This just does cleanup in GTK and exits with an exit status of 1. */ gtk_exit (1); } which = atoi (argv[1]); /* Create our window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* You should always remember to connect the delete_event signal * to the main window. This is very important for proper intuitive * behavior */ gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* We create a vertical box (vbox) to pack the horizontal boxes into. * This allows us to stack the horizontal boxes filled with buttons one * on top of the other in this vbox. */ box1 = gtk_vbox_new (FALSE, 0); /* which example to show. These correspond to the pictures above. */ switch (which) { case 1: /* create a new label. */ label = gtk_label_new ("gtk_hbox_new (FALSE, 0);"); /* Align the label to the left side. We'll discuss this function and * others in the section on Widget Attributes. */ gtk_misc_set_alignment (GTK_MISC (label), 0, 0); /* Pack the label into the vertical box (vbox box1). Remember that * widgets added to a vbox will be packed one on top of the other in * order. */ gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); /* Show the label */ gtk_widget_show (label); /* Call our make box function - homogeneous = FALSE, spacing = 0, * expand = FALSE, fill = FALSE, padding = 0 */ box2 = make_box (FALSE, 0, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* Call our make box function - homogeneous = FALSE, spacing = 0, * expand = TRUE, fill = FALSE, padding = 0 */ box2 = make_box (FALSE, 0, TRUE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* Args are: homogeneous, spacing, expand, fill, padding */ box2 = make_box (FALSE, 0, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* Creates a separator, we'll learn more about these later, * but they are quite simple. */ separator = gtk_hseparator_new (); /* Pack the separator into the vbox. Remember each of these * widgets is being packed into a vbox, so they'll be stacked * vertically. */ gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); gtk_widget_show (separator); /* Create another new label, and show it. */ label = gtk_label_new ("gtk_hbox_new (TRUE, 0);"); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); gtk_widget_show (label); /* Args are: homogeneous, spacing, expand, fill, padding */ box2 = make_box (TRUE, 0, TRUE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* Args are: homogeneous, spacing, expand, fill, padding */ box2 = make_box (TRUE, 0, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* Another new separator. */ separator = gtk_hseparator_new (); /* The last 3 arguments to gtk_box_pack_start are: * expand, fill, padding. */ gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); gtk_widget_show (separator); break; case 2: /* Create a new label, remember box1 is a vbox as created * near the beginning of main() */ label = gtk_label_new ("gtk_hbox_new (FALSE, 10);"); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); gtk_widget_show (label); /* Args are: homogeneous, spacing, expand, fill, padding */ box2 = make_box (FALSE, 10, TRUE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* Args are: homogeneous, spacing, expand, fill, padding */ box2 = make_box (FALSE, 10, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); separator = gtk_hseparator_new (); /* The last 3 arguments to gtk_box_pack_start are: * expand, fill, padding. */ gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); gtk_widget_show (separator); label = gtk_label_new ("gtk_hbox_new (FALSE, 0);"); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); gtk_widget_show (label); /* Args are: homogeneous, spacing, expand, fill, padding */ box2 = make_box (FALSE, 0, TRUE, FALSE, 10); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* Args are: homogeneous, spacing, expand, fill, padding */ box2 = make_box (FALSE, 0, TRUE, TRUE, 10); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); separator = gtk_hseparator_new (); /* The last 3 arguments to gtk_box_pack_start are: expand, fill, padding. */ gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); gtk_widget_show (separator); break; case 3: /* This demonstrates the ability to use gtk_box_pack_end() to * right justify widgets. First, we create a new box as before. */ box2 = make_box (FALSE, 0, FALSE, FALSE, 0); /* Create the label that will be put at the end. */ label = gtk_label_new ("end"); /* Pack it using gtk_box_pack_end(), so it is put on the right * side of the hbox created in the make_box() call. */ gtk_box_pack_end (GTK_BOX (box2), label, FALSE, FALSE, 0); /* Show the label. */ gtk_widget_show (label); /* Pack box2 into box1 (the vbox remember ? :) */ gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); gtk_widget_show (box2); /* A separator for the bottom. */ separator = gtk_hseparator_new (); /* This explicitly sets the separator to 400 pixels wide by 5 pixels * high. This is so the hbox we created will also be 400 pixels wide, * and the "end" label will be separated from the other labels in the * hbox. Otherwise, all the widgets in the hbox would be packed as * close together as possible. */ gtk_widget_set_usize (separator, 400, 5); /* pack the separator into the vbox (box1) created near the start * of main() */ gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); gtk_widget_show (separator); } /* Create another new hbox.. remember we can use as many as we need! */ quitbox = gtk_hbox_new (FALSE, 0); /* Our quit button. */ button = gtk_button_new_with_label ("Quit"); /* Setup the signal to terminate the program when the button is clicked */ gtk_signal_connect_object (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_main_quit), GTK_OBJECT (window)); /* Pack the button into the quitbox. * The last 3 arguments to gtk_box_pack_start are: * expand, fill, padding. */ gtk_box_pack_start (GTK_BOX (quitbox), button, TRUE, FALSE, 0); /* pack the quitbox into the vbox (box1) */ gtk_box_pack_start (GTK_BOX (box1), quitbox, FALSE, FALSE, 0); /* Pack the vbox (box1) which now contains all our widgets, into the * main window. */ gtk_container_add (GTK_CONTAINER (window), box1); /* And show everything left */ gtk_widget_show (button); gtk_widget_show (quitbox); gtk_widget_show (box1); /* Showing the window last so everything pops up at once. */ gtk_widget_show (window); /* And of course, our main function. */ gtk_main (); /* Control returns here when gtk_main_quit() is called, but not when * gtk_exit is used. */ return(0); }