Bug in notebook



It seems that gtk_notebook_set_page() does not work if you have not
previously called a gtk_widget_show() on the notebook widget.

Here is a program to demonstrate...

- Dave

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include <gtk/gtk.h>

int main(int argc, char* argv[])
{
    GtkWidget* top;
    GtkWidget* vbox;
    GtkWidget* notebook;
    GtkWidget* oops_txt;
    GtkWidget* showme_txt;
    GtkWidget* close_btn;

    gtk_init(&argc, &argv);

    top = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(top), "Notebook Bug");
    gtk_window_set_policy(GTK_WINDOW(top), TRUE, TRUE, FALSE);

    vbox = gtk_vbox_new(FALSE, 5);
    gtk_container_border_width(GTK_CONTAINER(vbox), 5);
    gtk_container_add(GTK_CONTAINER(top), vbox);

    notebook = gtk_notebook_new();
    gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);

    oops_txt = gtk_label_new("I should not be visible when\nthe program starts.");
    gtk_label_set_justify(GTK_LABEL(oops_txt), GTK_JUSTIFY_LEFT);

    showme_txt = gtk_label_new("I should be visible when the\nprogram starts.");
    gtk_label_set_justify(GTK_LABEL(showme_txt), GTK_JUSTIFY_LEFT);

    gtk_notebook_insert_page(GTK_NOTEBOOK(notebook),
			     oops_txt, gtk_label_new("Oops"), 0);
    gtk_notebook_insert_page(GTK_NOTEBOOK(notebook),
			     showme_txt, gtk_label_new("Show Me"), 1);
    gtk_notebook_set_page(GTK_NOTEBOOK(notebook), 1);

    close_btn = gtk_button_new_with_label("Close");
    gtk_box_pack_start(GTK_BOX(vbox), close_btn, FALSE, TRUE, 0);
    gtk_signal_connect(GTK_OBJECT(close_btn), "clicked",
		       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);

    gtk_widget_show_all(top);

    gtk_main();
    return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]