Hi Gary,
There are two ways of doing the help dialog that you want, the hard way and the easy way. First I shall show you the hard way which is a correction of your code.
What you did originally was to place the buttons two on one line and the last button on another. Here I have used a GtkVBox to contain the GtkLabel and a GtkHBox which is set to be expanded. To the GtkHBox is added two GtkHButtonBox again both set expanded and with one set to have the buttons to the start and the other to have the buttons set to the end. To these I then added the buttons. I also tried to simplify the code.
Code:
/*
* Compile:
gcc -Wall -Wextra -g twoLeft.c -o tLeft `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
*/
#include <gtk/gtk.h>
#define ABOUT \
"\n\n This program assists those with a speech impairment to speak\n\
\n\n\n\
Principal Author: Gary Kline\n\n\n\
Copyright (C), 2011, 2012."
static void
remove_text_window (GtkButton *widget, GtkWidget *text_window)
{
(void) widget; // get rid of gcc complaint.
gtk_widget_destroy (text_window);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *close;
GtkWidget *vbox;
GtkWidget *hbbox;
GtkWidget *b1box, *b2box, *credits, *license;
GtkWidget *label;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size (GTK_WINDOW (window), 350, 200);
gtk_window_set_title (GTK_WINDOW (window), "GtkAlignment");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (window), vbox);
/**** Only string in Help/About ... ****/
label = gtk_label_new (ABOUT);
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
hbbox = gtk_hbox_new(TRUE, 2);
b1box = gtk_hbutton_box_new ();
b2box = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), hbbox, TRUE, TRUE, 0);
gtk_button_box_set_layout (GTK_BUTTON_BOX (b1box), GTK_BUTTONBOX_START);
gtk_button_box_set_layout (GTK_BUTTON_BOX (b2box), GTK_BUTTONBOX_END);
gtk_box_pack_start (GTK_BOX (hbbox), b1box, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbbox), b2box, TRUE, TRUE, 0);
credits = gtk_button_new_with_label ("Credits");
license = gtk_button_new_with_label ("License");
close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_box_pack_start (GTK_BOX(b1box), credits, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(b1box), license, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(b2box), close, FALSE, FALSE, 0);
g_signal_connect (close, "clicked", G_CALLBACK (remove_text_window), window);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
and the easy way. This is a complete example and all that you need to show an about dialog that is standardised across most GTK applications is one function call to set all the properties.
The API you need is for the GtkAboutDialog
http://developer.gnome.org/gtk/stable/GtkAboutDialog.html and the function I used is gtk_show_about_dialog() see
http://developer.gnome.org/gtk/stable/GtkAboutDialog.html#gtk-show-about-dialogCode:
/*
* Compile:
gcc -Wall -Wextra -g twoLeft.c -o tLeft `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
*/
#include <gtk/gtk.h>
const gchar *authors[] = {
"Gary Kline",
NULL
};
void
cb_on_about(GtkWidget *object, gpointer data)
{
gtk_show_about_dialog(GTK_WINDOW(data),
"program-name", "VBC",
"version", "0.0",
"copyright", "Copyright (c) 2011, 2012",
"comments", "This program assists those with a speech impairment to speak",
"authors", authors,
"license", "Some license",
NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *about_button, *quit_button;
GtkWidget *hbox;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
hbox = gtk_hbox_new(FALSE, 2);
about_button = gtk_button_new_from_stock(GTK_STOCK_ABOUT);
quit_button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
gtk_container_add(GTK_CONTAINER(window), hbox);
gtk_box_pack_start(GTK_BOX(hbox), about_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), quit_button, FALSE, FALSE, 0);
g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect (about_button, "clicked", G_CALLBACK(cb_on_about), window);
g_signal_connect (quit_button, "clicked", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}