void ghack_save_game_cb(GtkWidget *widget, gpointer data) { GtkWidget *box; box = gnome_message_box_new(_("Quit and save the current game?"), GNOME_MESSAGE_BOX_QUESTION, GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO, NULL); gnome_dialog_set_default( GNOME_DIALOG(box), 1); gnome_dialog_set_parent (GNOME_DIALOG (box), GTK_WINDOW (ghack_get_main_window ()) ); gnome_dialog_set_accelerator (GNOME_DIALOG(box), 1, 'n', 0); gnome_dialog_set_accelerator (GNOME_DIALOG(box), 0, 'y', 0); gtk_window_set_modal( GTK_WINDOW(box), TRUE); gtk_signal_connect( GTK_OBJECT(box), "clicked", (GtkSignalFunc)ghack_save_game, NULL); gtk_widget_show(box); }
static gboolean gui_message_big_new (const char *from, const char *subject, const char *date, const char *account, const char *kbytes) { GtkWidget *vbox, *hbox; GtkWidget *table; GtkWidget *label; GtkWidget *hsep; GtkStyle *style1; GtkStyle *style2; char *buf; GtkWidget *xpm; go = FALSE; gbool = TRUE; window = gnome_dialog_new (_("Confirm message downloading"), GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO, NULL); gtk_window_set_modal (GTK_WINDOW (window), TRUE); gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (WMain->window)); gnome_dialog_set_default (GNOME_DIALOG (window), 0); vbox = GNOME_DIALOG (window)->vbox; label = gtk_label_new (_("There's a message bigger than what you allowed to automatically download.")); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); table = gtk_table_new (5, 2, FALSE); gtk_widget_show (table); gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_table_set_col_spacings (GTK_TABLE (table), 2); if (from && subject && date) { label = gtk_label_new (_("From:")); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1"); gtk_widget_set_style (label, style2); label = gtk_label_new (from); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-courier-medium-r-normal-*-*-120-*-*-m-*-iso8859-1"); gtk_widget_set_style (label, style2); label = gtk_label_new (_("Date:")); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1"); gtk_widget_set_style (label, style2); label = gtk_label_new (date); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-courier-medium-r-normal-*-*-120-*-*-m-*-iso8859-1"); gtk_widget_set_style (label, style2); } else { label = gtk_label_new (_("Since the server doesn't support advanced POP commands very little information about this message could be extracted.")); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); } label = gtk_label_new (_("Account:")); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1"); gtk_widget_set_style (label, style2); if (from && subject && date) { label = gtk_label_new (_("Subject:")); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1"); gtk_widget_set_style (label, style2); label = gtk_label_new (subject); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-courier-medium-r-normal-*-*-120-*-*-m-*-iso8859-1"); gtk_widget_set_style (label, style2); } label = gtk_label_new (_("Size:")); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-iso8859-1"); gtk_widget_set_style (label, style2); buf = g_strdup_printf ("%s (%d Kb)", kbytes, atoi (kbytes)/1024); label = gtk_label_new (buf); c2_free (buf); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-courier-medium-r-normal-*-*-120-*-*-m-*-iso8859-1"); gtk_widget_set_style (label, style2); label= gtk_label_new (account); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 7.45058e-09, 0.5); style1 = gtk_widget_get_style (label); style2 = gtk_style_copy (style1); style2->font = gdk_font_load ("-adobe-courier-medium-r-normal-*-*-120-*-*-m-*-iso8859-1"); gtk_widget_set_style (label, style2); hsep = gtk_hseparator_new (); gtk_widget_show (hsep); gtk_box_pack_start (GTK_BOX (vbox), hsep, FALSE, TRUE, 0); hbox = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); buf = gnome_unconditional_pixmap_file("gnome-question.png"); if (buf) { xpm = gnome_pixmap_new_from_file(buf); c2_free(buf); gtk_widget_show (xpm); gtk_box_pack_start (GTK_BOX (hbox), xpm, FALSE, FALSE, 0); } label = gtk_label_new (_("Do you want to download it?")); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); gnome_dialog_button_connect (GNOME_DIALOG (window), 0, GTK_SIGNAL_FUNC (cb), (gpointer) "Y"); gnome_dialog_set_accelerator (GNOME_DIALOG (window), 0, GDK_Y, 0); gnome_dialog_button_connect (GNOME_DIALOG (window), 1, GTK_SIGNAL_FUNC (cb), (gpointer) "N"); gnome_dialog_set_accelerator (GNOME_DIALOG (window), 1, GDK_N, 0); gtk_widget_show (window); gdk_threads_leave (); while (!go) usleep (500); gdk_threads_enter (); return gbool; }
int ghack_yes_no_dialog( const char *question, const char *choices, int def) { int i=0, ret; gchar button_name[BUFSZ]; GtkWidget *box; GtkWidget* mainWnd=NULL; box = gnome_message_box_new ( question, GNOME_MESSAGE_BOX_QUESTION, NULL); /* add buttons for each choice */ if (!strcmp(GNOME_STOCK_BUTTON_OK, choices)) { gnome_dialog_append_button ( GNOME_DIALOG(box), GNOME_STOCK_BUTTON_OK); gnome_dialog_set_default( GNOME_DIALOG(box), 0); gnome_dialog_set_accelerator( GNOME_DIALOG(box), 0, 'o', 0); #if 0 g_print("Setting accelerator '%c' for button %d\n", 'o', 0); #endif } else { for( ; choices[i]!='\0'; i++) { if (choices[i]=='y') { sprintf( button_name, GNOME_STOCK_BUTTON_YES); } else if (choices[i]=='n') { sprintf( button_name, GNOME_STOCK_BUTTON_NO); } else if (choices[i] == 'q') { sprintf( button_name, "Quit"); } else { sprintf( button_name, "%c", choices[i]); } if (def==choices[i]) gnome_dialog_set_default( GNOME_DIALOG(box), i); gnome_dialog_append_button ( GNOME_DIALOG(box), button_name); gnome_dialog_set_accelerator( GNOME_DIALOG(box), i, choices[i], 0); #if 0 g_print("Setting accelerator '%c' for button %d\n", choices[i], i); #endif } } #if 0 /* Perhaps add in a quit game button, like this... */ gnome_dialog_append_button ( GNOME_DIALOG(box), GNOME_STOCK_BUTTON_CLOSE); gnome_dialog_set_accelerator( GNOME_DIALOG(box), i, choices[i], 0); g_print("Setting accelerator '%c' for button %d\n", 'Q', i); #endif gnome_dialog_set_close(GNOME_DIALOG (box), TRUE); mainWnd = ghack_get_main_window (); gtk_window_set_modal( GTK_WINDOW(box), TRUE); gtk_window_set_title( GTK_WINDOW(box), "GnomeHack"); if ( mainWnd != NULL ) { gnome_dialog_set_parent (GNOME_DIALOG (box), GTK_WINDOW ( mainWnd) ); } ret=gnome_dialog_run_and_close ( GNOME_DIALOG (box)); #if 0 g_print("You selected button %d\n", ret); #endif if (ret==-1) return( '\033'); else return( choices[ret]); }