forked from AuroraMiddleware/gtk
9c0bc41a17
Sat Nov 8 23:06:02 2003 Matthias Clasen <maclas@gmx.de> * demos/gtk-demo/main.c (row_activated_cb): Call the do_ functions with the toplevel as argument. * demos/gtk-demo/geninclude.pl.in: Change the signature of GDoDemoFunc to take a widget argument * demos/gtk-demo/ui_manager.c (do_ui_manager): * demos/gtk-demo/tree_store.c (do_tree_store): * demos/gtk-demo/textview.c (do_textview): * demos/gtk-demo/stock_browser.c (do_stock_browser): * demos/gtk-demo/sizegroup.c (do_sizegroup): * demos/gtk-demo/pixbufs.c (do_pixbufs): * demos/gtk-demo/panes.c (do_panes): * demos/gtk-demo/menus.c (do_menus): * demos/gtk-demo/list_store.c (do_list_store): * demos/gtk-demo/images.c (do_images): * demos/gtk-demo/hypertext.c (do_hypertext): * demos/gtk-demo/editable_cells.c (do_editable_cells): * demos/gtk-demo/drawingarea.c (do_drawingarea): * demos/gtk-demo/dialog.c (do_dialog): * demos/gtk-demo/colorsel.c (do_colorsel): * demos/gtk-demo/changedisplay.c (do_changedisplay): * demos/gtk-demo/button_box.c (do_button_box): * demos/gtk-demo/appwindow.c (do_appwindow): Take a widget as argument, and make new windows or dialogs appear on the same screen. (#80388)
128 lines
3.3 KiB
C
128 lines
3.3 KiB
C
/* Button Boxes
|
|
*
|
|
* The Button Box widgets are used to arrange buttons with padding.
|
|
*/
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
static GtkWidget *
|
|
create_bbox (gint horizontal,
|
|
char *title,
|
|
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);
|
|
gtk_box_set_spacing (GTK_BOX (bbox), spacing);
|
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_OK);
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_HELP);
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
|
|
|
return frame;
|
|
}
|
|
|
|
GtkWidget *
|
|
do_button_box (GtkWidget *do_widget)
|
|
{
|
|
static GtkWidget *window = NULL;
|
|
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_screen (GTK_WINDOW (window),
|
|
gtk_widget_get_screen (do_widget));
|
|
gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
|
|
|
|
g_signal_connect (window, "destroy",
|
|
G_CALLBACK (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),
|
|
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);
|
|
|
|
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),
|
|
create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
|
|
TRUE, TRUE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
|
create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
|
|
TRUE, TRUE, 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
|
create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
|
|
TRUE, TRUE, 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox),
|
|
create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
|
|
TRUE, TRUE, 5);
|
|
}
|
|
|
|
if (!GTK_WIDGET_VISIBLE (window))
|
|
{
|
|
gtk_widget_show_all (window);
|
|
}
|
|
else
|
|
{
|
|
gtk_widget_destroy (window);
|
|
window = NULL;
|
|
}
|
|
|
|
return window;
|
|
}
|