2000-10-18 15:50:13 +00:00
|
|
|
/* Button Boxes
|
|
|
|
*
|
|
|
|
* The Button Box widgets are used to arrange buttons with padding.
|
|
|
|
*/
|
|
|
|
|
2013-06-21 17:46:54 +00:00
|
|
|
#include <glib/gi18n.h>
|
2000-10-18 15:50:13 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
create_bbox (gint horizontal,
|
2011-09-02 03:55:47 +00:00
|
|
|
char *title,
|
|
|
|
gint spacing,
|
|
|
|
gint layout)
|
2000-10-18 15:50:13 +00:00
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *button;
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
frame = gtk_frame_new (title);
|
|
|
|
|
|
|
|
if (horizontal)
|
2010-10-29 23:21:15 +00:00
|
|
|
bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
|
2000-10-18 15:50:13 +00:00
|
|
|
else
|
2010-10-29 23:21:15 +00:00
|
|
|
bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
|
|
|
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);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2013-06-21 17:46:54 +00:00
|
|
|
button = gtk_button_new_with_label (_("OK"));
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2013-06-21 17:46:54 +00:00
|
|
|
button = gtk_button_new_with_label (_("Cancel"));
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2013-06-21 17:46:54 +00:00
|
|
|
button = gtk_button_new_with_label (_("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 *
|
2003-11-08 22:08:05 +00:00
|
|
|
do_button_box (GtkWidget *do_widget)
|
2000-10-18 15:50:13 +00:00
|
|
|
{
|
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;
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2003-11-08 22:08:05 +00:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (window),
|
2011-09-02 03:55:47 +00:00
|
|
|
gtk_widget_get_screen (do_widget));
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2001-10-20 23:39:32 +00:00
|
|
|
g_signal_connect (window, "destroy",
|
2011-09-02 03:55:47 +00:00
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
|
|
|
&window);
|
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
frame_horz = gtk_frame_new ("Horizontal Button Boxes");
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
|
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
|
|
|
create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
|
|
|
|
TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
|
|
|
create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
|
|
|
|
TRUE, TRUE, 5);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
|
|
|
create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
|
|
|
|
TRUE, TRUE, 5);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
|
|
|
create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
|
|
|
|
TRUE, TRUE, 5);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
2014-01-12 03:46:19 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
|
|
|
create_bbox (TRUE, "Center", 40, GTK_BUTTONBOX_CENTER),
|
|
|
|
TRUE, TRUE, 5);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox),
|
|
|
|
create_bbox (TRUE, "Expand", 40, GTK_BUTTONBOX_EXPAND),
|
|
|
|
TRUE, TRUE, 5);
|
|
|
|
|
2000-10-18 15:50:13 +00:00
|
|
|
frame_vert = gtk_frame_new ("Vertical Button Boxes");
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame_vert, TRUE, TRUE, 10);
|
2011-09-02 03:55:47 +00:00
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2000-10-18 15:50:13 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
|
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2014-01-12 03:46:19 +00:00
|
|
|
create_bbox (FALSE, "Spread", 10, GTK_BUTTONBOX_SPREAD),
|
2011-09-02 03:55:47 +00:00
|
|
|
TRUE, TRUE, 0);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2014-01-12 03:46:19 +00:00
|
|
|
create_bbox (FALSE, "Edge", 10, GTK_BUTTONBOX_EDGE),
|
2011-09-02 03:55:47 +00:00
|
|
|
TRUE, TRUE, 5);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2014-01-12 03:46:19 +00:00
|
|
|
create_bbox (FALSE, "Start", 10, GTK_BUTTONBOX_START),
|
2011-09-02 03:55:47 +00:00
|
|
|
TRUE, TRUE, 5);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
2011-09-02 03:55:47 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
2014-01-12 03:46:19 +00:00
|
|
|
create_bbox (FALSE, "End", 10, GTK_BUTTONBOX_END),
|
|
|
|
TRUE, TRUE, 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
|
|
|
create_bbox (FALSE, "Center", 10, GTK_BUTTONBOX_CENTER),
|
|
|
|
TRUE, TRUE, 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
|
|
|
create_bbox (FALSE, "Expand", 10, GTK_BUTTONBOX_EXPAND),
|
2011-09-02 03:55:47 +00:00
|
|
|
TRUE, TRUE, 5);
|
2000-10-18 15:50:13 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (!gtk_widget_get_visible (window))
|
2000-11-18 23:59:30 +00:00
|
|
|
{
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
}
|
2000-10-18 15:50:13 +00:00
|
|
|
else
|
2011-09-02 03:55:47 +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
|
|
|
}
|