Thank you for helping in advance.
I made a button to be referred to multiple pages of Notebook. So I wrote some codes as below, but it didn't work as I expected.
Expected: A button, labeled as "Next page", is shown in each page. If I click it, then the window shows me the next page.
Should I make four buttons to attach to each page? But I want to use only one button to do this task if I can.
GtkWidget *notebook;
static GtkWidget*
init_notebook_widgets (void)
/* Return: GtkNotebook pointer */
{
GtkWidget *page1, *page2, *page3, *page4, \
*label1, *label2, *label3, *label4, \
*next_button;
notebook = gtk_notebook_new ();
next_button = gtk_button_new_with_mnemonic ("_Next page");
g_signal_connect (G_OBJECT (next_button), "clicked",
G_CALLBACK (go_next_page), NULL);
page1 = gtk_vbox_new (TRUE, 5);
label1 = gtk_label_new ("This is first page!");
gtk_box_pack_start_defaults (GTK_BOX (page1), label1);
gtk_box_pack_start_defaults (GTK_BOX (page1), next_button);
page2 = gtk_vbox_new (TRUE, 5);
label2 = gtk_label_new ("This is second page!");
gtk_box_pack_start_defaults (GTK_BOX (page2), label2);
gtk_box_pack_start_defaults (GTK_BOX (page2), next_button);
page3 = gtk_vbox_new (TRUE, 5);
label3 = gtk_label_new ("This is third page!");
gtk_box_pack_start_defaults (GTK_BOX (page3), label3);
gtk_box_pack_start_defaults (GTK_BOX (page3), next_button);
page4 = gtk_vbox_new (TRUE, 5);
label4 = gtk_label_new ("This is fourth page!");
gtk_box_pack_start_defaults (GTK_BOX (page4), label4);
gtk_box_pack_start_defaults (GTK_BOX (page4), next_button);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page1,
gtk_label_new ("Page 1"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page2,
gtk_label_new ("Page 2"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page3,
gtk_label_new ("Page 3"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page4,
gtk_label_new ("Page 4"));
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_BOTTOM);
return notebook;
}
static void
go_next_page (GtkWidget *widget,
gpointer data)
{
gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
}
A gtkwidget can be placed only in one container. You should create buttons for each page (btw, what behaviour it will have on the last page?) or create a single button, but pack it outside of notebook (same question applies)
And take a look at GtkAssistant