gtk notebook用例(毕设中的一小段)

GtkWidget  * textHttp, * textDNS;
GtkWidget 
* addPage(GtkWidget  * notebook,GtkWidget  * text, char   * protocol)
{
        GtkWidget 
*label;
        GtkWidget 
*scrolled;
        GtkWidget 
*tbox;

        label 
= gtk_label_new(protocol);
        tbox 
= gtk_vbox_new(FALSE,0);
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook),tbox,label);


        scrolled 
= gtk_scrolled_window_new(NULL,NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start(GTK_BOX(tbox),scrolled,TRUE,TRUE,
0);

        text 
= gtk_text_view_new();
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled),text);
        gtk_widget_show(text);
        gtk_widget_show(scrolled);
        gtk_widget_show(tbox);
}

GtkWidget 
* showWindow(GtkWidget  * box)
{
        GtkWidget 
*notebook;
        
        notebook 
= gtk_notebook_new();
        gtk_box_pack_start(GTK_BOX(box),notebook,TRUE,TRUE,
0);

        
/*TODO:can add the new page like below*/
        addPage(notebook,textHttp,
"HTTP");
        addPage(notebook,textDNS,
"DNS");

        gtk_widget_show_all(notebook);
}
 

你可能感兴趣的:(null,gtk)