5 /* This function rotates the position of the tabs */
6 static void rotate_book( GtkButton *button,
7 GtkNotebook *notebook )
9 gtk_notebook_set_tab_pos (notebook, (notebook->tab_pos + 1) % 4);
12 /* Add/Remove the page tabs and the borders */
13 static void tabsborder_book( GtkButton *button,
14 GtkNotebook *notebook )
18 if (notebook->show_tabs == 0)
20 if (notebook->show_border == 0)
23 gtk_notebook_set_show_tabs (notebook, tval);
24 gtk_notebook_set_show_border (notebook, bval);
27 /* Remove a page from the notebook */
28 static void remove_book( GtkButton *button,
29 GtkNotebook *notebook )
33 page = gtk_notebook_get_current_page (notebook);
34 gtk_notebook_remove_page (notebook, page);
35 /* Need to refresh the widget --
36 This forces the widget to redraw itself. */
37 gtk_widget_queue_draw (GTK_WIDGET (notebook));
40 static gboolean delete( GtkWidget *widget,
57 GtkWidget *checkbutton;
62 gtk_init (&argc, &argv);
64 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
66 g_signal_connect (window, "delete-event",
67 G_CALLBACK (delete), NULL);
69 gtk_container_set_border_width (GTK_CONTAINER (window), 10);
71 table = gtk_table_new (3, 6, FALSE);
72 gtk_container_add (GTK_CONTAINER (window), table);
74 /* Create a new notebook, place the position of the tabs */
75 notebook = gtk_notebook_new ();
76 gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
77 gtk_table_attach_defaults (GTK_TABLE (table), notebook, 0, 6, 0, 1);
78 gtk_widget_show (notebook);
80 /* Let's append a bunch of pages to the notebook */
81 for (i = 0; i < 5; i++) {
82 sprintf(bufferf, "Append Frame %d", i + 1);
83 sprintf(bufferl, "Page %d", i + 1);
85 frame = gtk_frame_new (bufferf);
86 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
87 gtk_widget_set_size_request (frame, 100, 75);
88 gtk_widget_show (frame);
90 label = gtk_label_new (bufferf);
91 gtk_container_add (GTK_CONTAINER (frame), label);
92 gtk_widget_show (label);
94 label = gtk_label_new (bufferl);
95 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
98 /* Now let's add a page to a specific spot */
99 checkbutton = gtk_check_button_new_with_label ("Check me please!");
100 gtk_widget_set_size_request (checkbutton, 100, 75);
101 gtk_widget_show (checkbutton);
103 label = gtk_label_new ("Add page");
104 gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), checkbutton, label, 2);
106 /* Now finally let's prepend pages to the notebook */
107 for (i = 0; i < 5; i++) {
108 sprintf (bufferf, "Prepend Frame %d", i + 1);
109 sprintf (bufferl, "PPage %d", i + 1);
111 frame = gtk_frame_new (bufferf);
112 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
113 gtk_widget_set_size_request (frame, 100, 75);
114 gtk_widget_show (frame);
116 label = gtk_label_new (bufferf);
117 gtk_container_add (GTK_CONTAINER (frame), label);
118 gtk_widget_show (label);
120 label = gtk_label_new (bufferl);
121 gtk_notebook_prepend_page (GTK_NOTEBOOK (notebook), frame, label);
124 /* Set what page to start at (page 4) */
125 gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 3);
127 /* Create a bunch of buttons */
128 button = gtk_button_new_with_label ("close");
129 g_signal_connect_swapped (button, "clicked",
130 G_CALLBACK (delete), NULL);
131 gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 1, 2);
132 gtk_widget_show (button);
134 button = gtk_button_new_with_label ("next page");
135 g_signal_connect_swapped (button, "clicked",
136 G_CALLBACK (gtk_notebook_next_page),
138 gtk_table_attach_defaults (GTK_TABLE (table), button, 1, 2, 1, 2);
139 gtk_widget_show (button);
141 button = gtk_button_new_with_label ("prev page");
142 g_signal_connect_swapped (button, "clicked",
143 G_CALLBACK (gtk_notebook_prev_page),
145 gtk_table_attach_defaults (GTK_TABLE (table), button, 2, 3, 1, 2);
146 gtk_widget_show (button);
148 button = gtk_button_new_with_label ("tab position");
149 g_signal_connect (button, "clicked",
150 G_CALLBACK (rotate_book),
152 gtk_table_attach_defaults (GTK_TABLE (table), button, 3, 4, 1, 2);
153 gtk_widget_show (button);
155 button = gtk_button_new_with_label ("tabs/border on/off");
156 g_signal_connect (button, "clicked",
157 G_CALLBACK (tabsborder_book),
159 gtk_table_attach_defaults (GTK_TABLE (table), button, 4, 5, 1, 2);
160 gtk_widget_show (button);
162 button = gtk_button_new_with_label ("remove page");
163 g_signal_connect (button, "clicked",
164 G_CALLBACK (remove_book),
166 gtk_table_attach_defaults (GTK_TABLE (table), button, 5, 6, 1, 2);
167 gtk_widget_show (button);
169 gtk_widget_show (table);
170 gtk_widget_show (window);