2000-10-18 15:50:13 +00:00
|
|
|
/* Paned Widgets
|
|
|
|
*
|
2015-06-20 01:59:15 +00:00
|
|
|
* The GtkPaned Widget divides its content area into two panes
|
|
|
|
* with a divider in between that the user can adjust. A separate
|
|
|
|
* child is placed into each pane. GtkPaned widgets can be split
|
2020-11-02 18:56:19 +00:00
|
|
|
* horizontally or vertically. This test contains both a horizontal
|
|
|
|
* and a vertical GtkPaned widget.
|
2000-10-18 15:50:13 +00:00
|
|
|
*
|
|
|
|
* There are a number of options that can be set for each pane.
|
2020-11-02 18:56:19 +00:00
|
|
|
* You can use the Inspector to adjust the options for each side
|
|
|
|
* of each widget.
|
2000-10-18 15:50:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2000-11-18 23:59:30 +00:00
|
|
|
GtkWidget *
|
2003-11-08 22:08:05 +00:00
|
|
|
do_panes (GtkWidget *do_widget)
|
2000-10-18 15:50:13 +00:00
|
|
|
{
|
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *hpaned;
|
|
|
|
GtkWidget *vpaned;
|
2020-11-02 18:56:19 +00:00
|
|
|
GtkWidget *label;
|
2000-10-18 15:50:13 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
2020-02-14 19:55:36 +00:00
|
|
|
window = gtk_window_new ();
|
2020-11-02 18:56:19 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 330, 250);
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
2017-10-31 06:41:15 +00:00
|
|
|
gtk_window_set_display (GTK_WINDOW (window),
|
|
|
|
gtk_widget_get_display (do_widget));
|
2020-05-09 16:03:11 +00:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
2020-08-06 15:54:42 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
|
|
|
gtk_widget_set_margin_start (vbox, 8);
|
|
|
|
gtk_widget_set_margin_end (vbox, 8);
|
|
|
|
gtk_widget_set_margin_top (vbox, 8);
|
|
|
|
gtk_widget_set_margin_bottom (vbox, 8);
|
2020-05-02 21:26:54 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
2010-10-31 17:07:20 +00:00
|
|
|
|
2020-08-06 15:54:42 +00:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_box_append (GTK_BOX (vbox), frame);
|
|
|
|
|
2010-10-29 23:47:13 +00:00
|
|
|
vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
2020-08-06 15:54:42 +00:00
|
|
|
gtk_frame_set_child (GTK_FRAME (frame), vpaned);
|
2000-10-18 15:50:13 +00:00
|
|
|
|
2010-10-29 23:47:13 +00:00
|
|
|
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
2020-05-07 12:30:39 +00:00
|
|
|
gtk_paned_set_start_child (GTK_PANED (vpaned), hpaned);
|
2020-11-02 18:56:19 +00:00
|
|
|
gtk_paned_set_shrink_start_child (GTK_PANED (vpaned), FALSE);
|
|
|
|
|
|
|
|
label = gtk_label_new ("Hi there");
|
|
|
|
gtk_widget_set_margin_start (label, 4);
|
|
|
|
gtk_widget_set_margin_end (label, 4);
|
|
|
|
gtk_widget_set_margin_top (label, 4);
|
|
|
|
gtk_widget_set_margin_bottom (label, 4);
|
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
|
|
|
gtk_widget_set_vexpand (label, TRUE);
|
|
|
|
gtk_paned_set_start_child (GTK_PANED (hpaned), label);
|
|
|
|
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
|
|
|
|
|
|
|
|
label = gtk_label_new ("Hello");
|
|
|
|
gtk_widget_set_margin_start (label, 4);
|
|
|
|
gtk_widget_set_margin_end (label, 4);
|
|
|
|
gtk_widget_set_margin_top (label, 4);
|
|
|
|
gtk_widget_set_margin_bottom (label, 4);
|
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
|
|
|
gtk_widget_set_vexpand (label, TRUE);
|
|
|
|
gtk_paned_set_end_child (GTK_PANED (hpaned), label);
|
|
|
|
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
|
|
|
|
|
|
|
|
label = gtk_label_new ("Goodbye");
|
|
|
|
gtk_widget_set_margin_start (label, 4);
|
|
|
|
gtk_widget_set_margin_end (label, 4);
|
|
|
|
gtk_widget_set_margin_top (label, 4);
|
|
|
|
gtk_widget_set_margin_bottom (label, 4);
|
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
|
|
|
gtk_widget_set_vexpand (label, TRUE);
|
|
|
|
gtk_paned_set_end_child (GTK_PANED (vpaned), label);
|
|
|
|
gtk_paned_set_shrink_end_child (GTK_PANED (vpaned), FALSE);
|
2000-10-18 15:50:13 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (!gtk_widget_get_visible (window))
|
2015-06-28 13:23:28 +00:00
|
|
|
gtk_widget_show (window);
|
2000-10-18 15:50:13 +00:00
|
|
|
else
|
2020-05-09 14:26:22 +00:00
|
|
|
gtk_window_destroy (GTK_WINDOW (window));
|
2000-11-18 23:59:30 +00:00
|
|
|
|
|
|
|
return window;
|
2000-10-18 15:50:13 +00:00
|
|
|
}
|