GtkWidget* ghack_init_menu_window (void) { GtkWidget *menuWin = NULL; GtkWidget *parent = ghack_get_main_window (); menuWin = gnome_dialog_new("GnomeHack", GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_set_default( GNOME_DIALOG(menuWin), 0); gtk_signal_connect(GTK_OBJECT(menuWin), "destroy", GTK_SIGNAL_FUNC(ghack_menu_destroy), NULL); gtk_signal_connect (GTK_OBJECT (menuWin), "delete_event", GTK_SIGNAL_FUNC (ghack_menu_hide), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "ghack_clear", GTK_SIGNAL_FUNC(ghack_menu_window_clear), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "ghack_display", GTK_SIGNAL_FUNC(ghack_menu_window_display), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "ghack_start_menu", GTK_SIGNAL_FUNC(ghack_menu_window_start_menu), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "ghack_add_menu", GTK_SIGNAL_FUNC(ghack_menu_window_add_menu), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "ghack_end_menu", GTK_SIGNAL_FUNC(ghack_menu_window_end_menu), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "ghack_select_menu", GTK_SIGNAL_FUNC(ghack_menu_window_select_menu), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "ghack_putstr", GTK_SIGNAL_FUNC(ghack_menu_window_put_string), NULL); gtk_signal_connect(GTK_OBJECT(menuWin), "key_press_event", GTK_SIGNAL_FUNC(ghack_menu_window_key), NULL); /* Center the dialog over parent */ g_assert (parent != NULL); g_assert (menuWin != NULL); g_assert (GTK_IS_WINDOW (parent)); g_assert (GNOME_IS_DIALOG (menuWin)); gnome_dialog_set_parent (GNOME_DIALOG (menuWin), GTK_WINDOW (parent)); return menuWin; }
GnomeDialog * gnocam_camera_selector_new (void) { GnoCamCameraSelector *selector; const gchar *buttons[] = {GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL}; GtkWidget *hbox, *pixmap, *vbox, *widget, *label; Bonobo_PropertyBag pb; CORBA_Environment ev; selector = gtk_type_new (GNOCAM_TYPE_CAMERA_SELECTOR); gnome_dialog_constructv (GNOME_DIALOG (selector), _("Select a Camera"), buttons); gnome_dialog_set_default (GNOME_DIALOG (selector), 0); gtk_window_set_policy (GTK_WINDOW (selector), TRUE, TRUE, TRUE); gtk_widget_set_usize (GTK_WIDGET (selector), 400, 300); hbox = gtk_hbox_new (FALSE, 10); gtk_widget_show (hbox); gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (selector)->vbox), hbox); vbox = gtk_vbox_new (FALSE, 10); gtk_widget_show (vbox); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); /* The camera picture */ pixmap = gnome_pixmap_new_from_file (IMAGEDIR "/gnocam.png"); gtk_widget_show (pixmap); gtk_box_pack_start (GTK_BOX (vbox), pixmap, FALSE, FALSE, 0); /* The "Autodetect" check button */ CORBA_exception_init (&ev); pb = bonobo_get_object ("config:/apps/" PACKAGE, "Bonobo/PropertyBag", &ev); if (BONOBO_EX (&ev)) { g_warning ("Could not get property bag: %s", bonobo_exception_get_text (&ev)); } else { GtkObject *ed; ed = bonobo_peditor_new (pb, "autodetect", TC_boolean, NULL); bonobo_object_release_unref (pb, NULL); widget = bonobo_peditor_get_widget (BONOBO_PEDITOR (ed)); gtk_widget_show (widget); gtk_box_pack_end (GTK_BOX (vbox), widget, FALSE, FALSE, 0); label = gtk_label_new (_("Autodetect")); gtk_widget_show (label); gtk_container_add (GTK_CONTAINER (widget), label); } CORBA_exception_free (&ev); /* The camera list */ selector->priv->table = gnocam_capplet_table_scrolled_new (NULL); gtk_widget_show (selector->priv->table); gtk_box_pack_start (GTK_BOX (hbox), selector->priv->table, TRUE, TRUE, 0); return (GNOME_DIALOG (selector)); }
static GtkWidget * request_dialog (const gchar * request, const gchar * default_text, const guint16 max_length, GnomeStringCallback callback, gpointer data, gboolean password, GtkWindow * parent) { GtkWidget * mbox; callback_info * info; GtkWidget * entry; mbox = gnome_message_box_new ( request, GNOME_MESSAGE_BOX_QUESTION, GNOME_STOCK_BUTTON_CANCEL, GNOME_STOCK_BUTTON_OK, NULL ); gnome_dialog_set_default ( GNOME_DIALOG(mbox), 1 ); /* set up text entry widget */ entry = gtk_entry_new(); if (password) gtk_entry_set_visibility (GTK_ENTRY(entry), FALSE); if ((default_text != NULL) && (*default_text)) gtk_entry_set_text(GTK_ENTRY(entry), default_text); if (max_length > 0) gtk_entry_set_max_length(GTK_ENTRY(entry), max_length); gtk_box_pack_end ( GTK_BOX(GNOME_DIALOG(mbox)->vbox), entry, FALSE, FALSE, GNOME_PAD_SMALL ); /* If Return is pressed in the text entry, propagate to the buttons */ gnome_dialog_editable_enters(GNOME_DIALOG(mbox), GTK_EDITABLE(entry)); info = g_new(callback_info, 1); info->function = callback; info->data = data; info->entry = GTK_ENTRY(entry); g_signal_connect_data (mbox, "clicked", G_CALLBACK (dialog_string_callback), info, (GClosureNotify) g_free, 0); if (parent != NULL) { gnome_dialog_set_parent(GNOME_DIALOG(mbox),parent); } gtk_widget_grab_focus (entry); gtk_widget_show (entry); gtk_widget_show (mbox); return mbox; }
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 int game_quit_callback (GtkWidget *widget, void *data) { GtkWidget *box; box = gnome_message_box_new (_("Do you really want to quit?"), GNOME_MESSAGE_BOX_QUESTION, GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO, NULL); gnome_dialog_set_parent (GNOME_DIALOG(box), GTK_WINDOW(app)); gnome_dialog_set_default (GNOME_DIALOG (box), 0); gtk_window_set_modal (GTK_WINDOW (box), TRUE); gtk_signal_connect (GTK_OBJECT (box), "clicked", (GtkSignalFunc)game_maybe_quit, NULL); gtk_widget_show (box); return TRUE; }
int ghack_ask_string_dialog(const char *szMessageStr, const char *szDefaultStr, const char *szTitleStr, char *buffer) { int i; GtkWidget* dialog; gchar *user_text = NULL; dialog = gnome_request_dialog(FALSE, szMessageStr, szDefaultStr, 0, ghack_ask_string_callback, &user_text, NULL); g_assert(dialog != NULL); gtk_window_set_title(GTK_WINDOW(dialog), szTitleStr); gnome_dialog_set_default( GNOME_DIALOG(dialog), 0); gtk_window_set_modal( GTK_WINDOW(dialog), TRUE); gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (ghack_get_main_window ()) ); i = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); /* Quit */ if ( i != 0 || user_text == NULL ) { if (user_text) g_free(user_text); return -1; } if ( *user_text == 0 ) { g_free(user_text); return -1; } g_assert(strlen(user_text) > 0); strcpy (buffer, user_text); g_free(user_text); return 0; }
void find_process_result(GnomeFindDialog *find_dialog, int find_result) { find_selection *find_select; GtkWidget *message_dialog; if (find_dialog != NULL) g_return_if_fail(GNOME_IS_FIND_DIALOG(find_dialog)); switch (find_result) { case GNOME_FIND_NOMATCH: message_dialog = gnome_message_box_new("Could not find text in console output.", GNOME_MESSAGE_BOX_WARNING, GNOME_STOCK_BUTTON_OK, NULL); if (find_dialog != NULL ) { gnome_dialog_set_parent(GNOME_DIALOG(message_dialog), GTK_WINDOW(find_dialog)); } else { gnome_dialog_set_parent(GNOME_DIALOG(message_dialog), GTK_WINDOW(R_gtk_main_window)); } gnome_dialog_run_and_close (GNOME_DIALOG(message_dialog)); if(find_dialog != NULL) gnome_dialog_set_default(GNOME_DIALOG(find_dialog), GNOME_FIND_BUTTON_FIND); break; case GNOME_FIND_MATCH: find_select = (find_selection *) find_current_match->data; gtk_editable_set_position(GTK_EDITABLE(R_gtk_terminal_text), find_select->select_end); gtk_editable_select_region(GTK_EDITABLE(R_gtk_terminal_text), find_select->select_start, find_select->select_end); break; } }
/* Display the file named str. Complain about missing files iff complain is TRUE. */ void gnome_display_file(const char *filename,BOOLEAN_P must_exist) { /* Strange -- for some reason it makes us create a new text window * instead of reusing any existing ones -- perhaps we can work out * some way to reuse stuff -- but for now just make and destroy new * ones each time */ dlb *f; f = dlb_fopen(filename, "r"); if (!f) { if (must_exist) { GtkWidget *box; char message[90]; sprintf(message, "Warning! Could not find file: %s\n",filename); box = gnome_message_box_new (_(message), GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL); gnome_dialog_set_default( GNOME_DIALOG(box), 0); gnome_dialog_set_parent (GNOME_DIALOG (box), GTK_WINDOW (ghack_get_main_window ()) ); gtk_window_set_modal( GTK_WINDOW(box), TRUE); gtk_widget_show (box); } } else { GtkWidget *txtwin, *gless, *frametxt; #define LLEN 128 char line[LLEN], *textlines; int num_lines, charcount; txtwin = gnome_dialog_new("Text Window", GNOME_STOCK_BUTTON_OK, NULL); gtk_widget_set_usize(GTK_WIDGET(txtwin), 500, 400); gtk_window_set_policy(GTK_WINDOW(txtwin), TRUE, TRUE, FALSE); gtk_window_set_title(GTK_WINDOW(txtwin), "Text Window"); gnome_dialog_set_default( GNOME_DIALOG(txtwin), 0); gtk_window_set_modal( GTK_WINDOW(txtwin), TRUE); frametxt = gtk_frame_new (""); gtk_widget_show (frametxt); /* * Count the number of lines and characters in the file. */ num_lines = 0; charcount = 1; while (dlb_fgets(line, LLEN, f)) { num_lines++; charcount += strlen(line); } (void) dlb_fclose(f); /* Ignore empty files */ if (num_lines == 0) return; /* * Re-open the file and read the data into a buffer. */ textlines = (char *) alloc((unsigned int) charcount); textlines[0] = '\0'; f = dlb_fopen( filename, RDTMODE); while (dlb_fgets(line, LLEN, f)) { (void) strcat(textlines, line); } (void) dlb_fclose(f); gless = gnome_less_new (); gnome_less_show_string (GNOME_LESS (gless), textlines); gtk_container_add (GTK_CONTAINER (frametxt), gless); gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (txtwin)->vbox), frametxt, TRUE, TRUE, 0); gtk_widget_show_all( txtwin); gtk_window_set_modal( GTK_WINDOW(txtwin), TRUE); gnome_dialog_set_parent (GNOME_DIALOG (txtwin), GTK_WINDOW (ghack_get_main_window ()) ); gnome_dialog_run_and_close (GNOME_DIALOG (txtwin)); free(textlines); } }
void ghack_settings_dialog() { int i; static GtkWidget* dialog; static GtkWidget* swin; static GtkWidget* frame1; dialog = gnome_dialog_new (_("GnomeHack Settings"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE); gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event", GTK_SIGNAL_FUNC (opt_sel_key_hit), tilesets ); frame1 = gtk_frame_new (_("Choose one of the following tilesets:")); gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1); gtk_widget_show (frame1); gtk_container_border_width (GTK_CONTAINER (frame1), 3); swin = gtk_scrolled_window_new (NULL, NULL); clist = gtk_clist_new (2); gtk_clist_column_titles_hide (GTK_CLIST (clist)); gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180); gtk_container_add (GTK_CONTAINER (swin), clist); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_signal_connect (GTK_OBJECT (clist), "select_row", GTK_SIGNAL_FUNC (opt_sel_row_selected), NULL ); gtk_container_add (GTK_CONTAINER (frame1), swin); gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1); /* Add the tilesets into the list here... */ for (i=0; i < no_tilesets; i++) { gchar accelBuf[BUFSZ]; const char *text[3]={accelBuf, tilesets[i].name,NULL}; if ((tilesets[i].flags & ~TILESET_TRANSPARENT) != 0) continue; /* Unsupported flag set */ sprintf( accelBuf, "%c ", tolower(tilesets[i].name[0])); gtk_clist_insert (GTK_CLIST (clist), i, (char**)text); } gtk_clist_columns_autosize (GTK_CLIST (clist)); gtk_widget_show_all (swin); /* Center the dialog over over parent */ gnome_dialog_set_default( GNOME_DIALOG(dialog), 0); gtk_window_set_modal( GTK_WINDOW(dialog), TRUE); gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (ghack_get_main_window ()) ); /* Run the dialog -- returning whichever button was pressed */ i = gnome_dialog_run (GNOME_DIALOG (dialog)); gnome_dialog_close (GNOME_DIALOG (dialog)); /* They hit Quit or error */ if (i != 0 ) { return; } if (gn_tileset < no_tilesets) { if (tilesets[gn_tileset].file[0] != '/') { char *path; path = (char *)alloc(strlen(TILESETDIR) + strlen(tilesets[gn_tileset].file) + 2); sprintf(path, TILESETDIR "/%s", tilesets[gn_tileset].file); ghack_free_glyphs(); if (ghack_init_glyphs(path)) g_error ("ERROR: Could not initialize glyphs.\n"); free(path); } else { ghack_free_glyphs(); if (ghack_init_glyphs(tilesets[gn_tileset].file)) g_error ("ERROR: Could not initialize glyphs.\n"); } ghack_reinit_map_window(); } else { /* This shouldn't happen */ g_warning("This shouldn't happen\n"); } }
int ghack_player_sel_dialog(const char** choices, const gchar* title, const gchar* prompt) { int i; static GtkWidget* dialog; static GtkWidget* swin; static GtkWidget* frame1; dialog = gnome_dialog_new(title, GNOME_STOCK_BUTTON_OK, _("Random"), GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE); gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event", GTK_SIGNAL_FUNC (player_sel_key_hit), choices ); frame1 = gtk_frame_new(prompt); gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1); gtk_widget_show (frame1); gtk_container_border_width (GTK_CONTAINER (frame1), 3); swin = gtk_scrolled_window_new (NULL, NULL); clist = gtk_clist_new (2); gtk_clist_column_titles_hide (GTK_CLIST (clist)); gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180); gtk_container_add (GTK_CONTAINER (swin), clist); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_signal_connect (GTK_OBJECT (clist), "select_row", GTK_SIGNAL_FUNC (player_sel_row_selected), NULL ); gtk_container_add (GTK_CONTAINER (frame1), swin); gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1); /* Add the roles into the list here... */ for (i=0; choices[i]; i++) { gchar accelBuf[BUFSZ]; const char *text[3]={accelBuf, choices[i],NULL}; sprintf( accelBuf, "%c ", tolower(choices[i][0])); gtk_clist_insert (GTK_CLIST (clist), i, (char**)text); } gtk_clist_columns_autosize (GTK_CLIST (clist)); gtk_widget_show_all (swin); /* Center the dialog over over parent */ gnome_dialog_set_default( GNOME_DIALOG(dialog), 0); gtk_window_set_modal( GTK_WINDOW(dialog), TRUE); gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (ghack_get_main_window ()) ); /* Run the dialog -- returning whichever button was pressed */ i = gnome_dialog_run_and_close(GNOME_DIALOG(dialog)); /* Quit on button 2 or error */ if (i < 0 || i > 1) { return(ROLE_NONE); } /* Random is button 1*/ if (i == 1 ) { return(ROLE_RANDOM); } return ( role_number); }
int ghack_menu_ext_cmd(void) { int n; GtkWidget* dialog; GtkWidget* swin; GtkWidget* frame1; GtkWidget* clist; extMenu info; dialog = gnome_dialog_new("Extended Commands", GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE); gtk_signal_connect(GTK_OBJECT(dialog), "key_press_event", GTK_SIGNAL_FUNC(ghack_ext_key_hit), &info); frame1 = gtk_frame_new("Make your selection"); gtk_object_set_data(GTK_OBJECT(dialog), "frame1", frame1); gtk_widget_show(frame1); gtk_container_border_width(GTK_CONTAINER(frame1), 3); swin = gtk_scrolled_window_new(NULL, NULL); clist = gtk_clist_new(2); gtk_object_set_data(GTK_OBJECT(dialog), "clist", clist); gtk_widget_set_usize(clist, 500, 400); gtk_container_add(GTK_CONTAINER(swin), clist); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(ghack_menu_row_selected), NULL); gtk_container_add(GTK_CONTAINER(frame1), swin); gtk_box_pack_start_defaults(GTK_BOX(GNOME_DIALOG(dialog)->vbox), frame1); /* Add the extended commands into the list here... */ for (n = 0; extcmdlist[n].ef_txt; ++n) { const char *text[3]={extcmdlist[n].ef_txt,extcmdlist[n].ef_desc,NULL}; gtk_clist_insert(GTK_CLIST(clist), n, (char**) text); } /* fill in starting info fields */ info.curItem = -1; info.numRows = n; info.charIdx = 0; info.lastTime = 0; gtk_clist_columns_autosize(GTK_CLIST(clist)); gtk_widget_show_all(swin); /* Center the dialog over over parent */ gnome_dialog_set_default(GNOME_DIALOG(dialog), 0); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(ghack_get_main_window())); /* Run the dialog -- returning whichever button was pressed */ n = gnome_dialog_run_and_close(GNOME_DIALOG(dialog)); /* Quit on button 2 or error */ return (n != 0) ? -1 : info.curItem; }
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]); }