2000-10-18 15:50:13 +00:00
|
|
|
/* Button Boxes
|
|
|
|
*
|
|
|
|
* The Button Box widgets are used to arrange buttons with padding.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
create_bbox (gint horizontal,
|
2001-05-18 16:28:30 +00:00
|
|
|
char *title,
|
2000-10-18 15:50:13 +00:00
|
|
|
gint spacing,
|
|
|
|
gint layout)
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
frame = gtk_frame_new (title);
|
|
|
|
|
|
|
|
if (horizontal)
|
|
|
|
bbox = gtk_hbutton_box_new ();
|
|
|
|
else
|
|
|
|
bbox = gtk_vbutton_box_new ();
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), bbox);
|
|
|
|
|
|
|
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
|
2001-03-07 21:10:44 +00:00
|
|
|
gtk_box_set_spacing (GTK_BOX (bbox), spacing);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
2001-05-25 20:41:46 +00:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_OK);
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
|
|
|
|
2001-05-25 20:41:46 +00:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
|
|
|
|
2001-03-22 06:45:57 +00:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_HELP);
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2000-11-18 23:59:30 +00:00
|
|
|
GtkWidget *
|
2000-10-18 15:50:13 +00:00
|
|
|
do_button_box (void)
|
|
|
|
{
|
2001-05-18 16:28:30 +00:00
|
|
|
static GtkWidget *window = NULL;
|
2000-10-18 15:50:13 +00:00
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *frame_horz;
|
|
|
|
GtkWidget *frame_vert;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
|
|
|
&window);
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
|
|
|
|
|
|
|
main_vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
|
|
|
|
|
|
|
frame_horz = gtk_frame_new ("Horizontal Button Boxes");
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 5);
|
2001-04-18 18:09:18 +00:00
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 5);
|
2001-04-18 18:09:18 +00:00
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 5);
|
|
|
|
|
|
|
|
frame_vert = gtk_frame_new ("Vertical Button Boxes");
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame_vert, TRUE, TRUE, 10);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 5);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 5);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2001-05-18 16:28:30 +00:00
|
|
|
create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
|
2000-10-18 15:50:13 +00:00
|
|
|
TRUE, TRUE, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GTK_WIDGET_VISIBLE (window))
|
2000-11-18 23:59:30 +00:00
|
|
|
{
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
2000-10-18 15:50:13 +00:00
|
|
|
else
|
2001-05-18 16:28:30 +00:00
|
|
|
{
|
2000-11-18 23:59:30 +00:00
|
|
|
gtk_widget_destroy (window);
|
|
|
|
window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window;
|
2000-10-18 15:50:13 +00:00
|
|
|
}
|