1 /* SCCS Id: @(#)gnyesno.c 3.4 2000/07/16 */
2 /* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
3 /* NetHack may be freely redistributed. See license for details. */
10 int ghack_yes_no_dialog( const char *question,
11 const char *choices, int def)
14 gchar button_name[BUFSZ];
16 GtkWidget* mainWnd=NULL;
18 box = gnome_message_box_new ( question, GNOME_MESSAGE_BOX_QUESTION, NULL);
19 /* add buttons for each choice */
20 if (!strcmp(GNOME_STOCK_BUTTON_OK, choices)) {
21 gnome_dialog_append_button ( GNOME_DIALOG(box), GNOME_STOCK_BUTTON_OK);
22 gnome_dialog_set_default( GNOME_DIALOG(box), 0);
23 gnome_dialog_set_accelerator( GNOME_DIALOG(box), 0, 'o', 0);
25 g_print("Setting accelerator '%c' for button %d\n", 'o', 0);
29 for( ; choices[i]!='\0'; i++) {
30 if (choices[i]=='y') {
31 sprintf( button_name, GNOME_STOCK_BUTTON_YES);
33 else if (choices[i]=='n') {
34 sprintf( button_name, GNOME_STOCK_BUTTON_NO);
36 else if (choices[i] == 'q') {
37 sprintf( button_name, "Quit");
39 sprintf( button_name, "%c", choices[i]);
42 gnome_dialog_set_default( GNOME_DIALOG(box), i);
43 gnome_dialog_append_button ( GNOME_DIALOG(box), button_name);
44 gnome_dialog_set_accelerator( GNOME_DIALOG(box), i, choices[i], 0);
46 g_print("Setting accelerator '%c' for button %d\n", choices[i], i);
51 /* Perhaps add in a quit game button, like this... */
52 gnome_dialog_append_button ( GNOME_DIALOG(box), GNOME_STOCK_BUTTON_CLOSE);
53 gnome_dialog_set_accelerator( GNOME_DIALOG(box), i, choices[i], 0);
54 g_print("Setting accelerator '%c' for button %d\n", 'Q', i);
57 gnome_dialog_set_close(GNOME_DIALOG (box), TRUE);
58 mainWnd = ghack_get_main_window ();
59 gtk_window_set_modal( GTK_WINDOW(box), TRUE);
60 gtk_window_set_title( GTK_WINDOW(box), "GnomeHack");
61 if ( mainWnd != NULL ) {
62 gnome_dialog_set_parent (GNOME_DIALOG (box),
63 GTK_WINDOW ( mainWnd) );
66 ret=gnome_dialog_run_and_close ( GNOME_DIALOG (box));
69 g_print("You selected button %d\n", ret);
75 return( choices[ret]);