guys, the following callback _does_ work when i choose Help -> How_to_Use, but because of the frame the close button is across the bottom. I would like it to be a small botton in the lower right just like the Authors help -> contributors button you clued in in on. I did borrow this from a "display_text" callback that helps the user search for and locate prev or last text files. If I could adopt the same button-placement code as last time; otherwise, would someone help me get the [Close] button in the lower right?
Code:
/*
* the following callback reads in ~/.VBC/.Instructions.txt that tells how to
* use VBC. [[ May need/WANT to divide to explain "Display Textfile" (?)]]
*/
void
show_instructions_cb (void)
{
#define INSTRUCT ".Instructions.txt"
GtkWidget *window, *view, *vbox, *separator;
GtkWidget *close;
GtkWidget *frame;
GtkTextBuffer *buffer;
GtkTextIter iter;
FILE *infile;
gchar file_buff[MAXCHAT];
gchar instruction[32];
gint nchars;
/*
set up file to be read into frame
*/
sprintf (instruction, "%s%s", vhome, INSTRUCT); /* name of instructions file
*/
printf ("DEBUG: show_file: instruction = [%s]\n", instruction);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 500, 500);
//--gtk_window_set_title(GTK_WINDOW(window), "Groat");
gtk_window_set_title (GTK_WINDOW (window), "Instructions");
/* this tells the window manager the smallest size
* good idea to set this, else the UI can start to look goofy
*/
gtk_widget_set_usize (window, 200, 200);
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
/* adding a frame around the vbox to make things look better */
frame = gtk_frame_new ("MAYBE Help-1 {or 2 or 3}" ");
gtk_container_add (GTK_CONTAINER (window), frame);
/* at this point we have:
* window with a frame inside it ( a frame is a container )
*/
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_add (GTK_CONTAINER (frame), vbox);
/* now we added a vbox container, to our frame*/
view = gtk_text_view_new ();
gtk_container_set_border_width (GTK_CONTAINER (view), 6);
gtk_container_add (GTK_CONTAINER (vbox), view);
/* added the text view to the vbox */
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
/* using box packing allows automatic sizing, good idea for
* a seperator (let gtk figure it out)
* so now we packed a seperator below our text view */
GtkWidget *hbox = gtk_hbox_new (FALSE, 5);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
close = gtk_button_new_with_label (" Close window ");
gtk_box_pack_end (GTK_BOX (hbox), close, TRUE, TRUE, FALSE);
/* fetch the buffer from the text view and get offset 0 */
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
/* pull in data from instructions file and insert starting at iter */
chdir (vhome);
infile = fopen (instruction, " r ");
if (infile)
{
while (1)
{
nchars = fread (file_buff, 1, MAXCHAT, infile);
gtk_text_buffer_insert (buffer, &iter, file_buff, nchars);
if (nchars < MAXCHAT)
break;
}
fclose (infile);
}
else
g_print (" \ nERROR ! could not open % s \ n ", instruction);
/* no reason to type out all that crap of showing each widget
* with this example */
gtk_signal_connect (GTK_OBJECT (close), " button_press_event ",
(GtkSignalFunc) remove_text_window, window);
gtk_widget_show_all (window);
return;
}