将一个孩子添加到GtkVBox

时间:2010-09-22 18:34:07

标签: c linux gtk

将孩子添加到GtkVBox时遇到问题。 VBox位于ScrollledWindows内的GtkViewPort内。

在孩子之后使用gtk_box_pack_end添加它我检查它是否真的添加了检查GLIST并且它似乎已添加。虽然视觉上出现了任何东西,但滚动的窗口变得非常大。就像添加了一些非常大而无形的东西一样。

代码如下:

GtkWidget *child;
switch (response_id) {
    case GTK_RESPONSE_ADD:

        //The see the code for this function read the other 
        //piece of code i'm posting
        child = (GtkWidget *)newChild();
        gtk_box_pack_end((GtkBox *)protocolsBox, child, 0, 1, 0);

        GList *temp = gtk_container_get_children((GtkContainer *) protocolsBox);

        //Here I do a while to check if the list has gotten bigger

        break;
}

函数newChild()如下:

GtkHBox* newChild() {
   printf("Creating new hbox\n");
   countProt++;

   //creation of all the widgets to look for a service
   GtkHBox* new = (GtkHBox *) gtk_hbox_new(0, 0);
   GtkEntry* nameEntry = (GtkEntry *) gtk_entry_new();
   GtkEntry* domainEntry = (GtkEntry *) gtk_entry_new();
   GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
   GtkRadioButton *tcpButton = (GtkRadioButton *) gtk_radio_button_new_with_label_from_widget(NULL, "tcp");
   GtkRadioButton *udpButton = (GtkRadioButton *) gtk_radio_button_new_with_label_from_widget(tcpButton, "udp");

   //packing the radio button widget
   gtk_box_pack_start((GtkBox *) buttons, (GtkWidget *) tcpButton, 0, 0, 0);
   gtk_box_pack_end((GtkBox *) buttons, (GtkWidget *) udpButton, 0, 0, 0);

   //packing the outer most widget
   gtk_box_pack_start((GtkBox *) new, (GtkWidget *) nameEntry, 1, 1, 0);
   gtk_box_pack_end((GtkBox *) new, (GtkWidget *) buttons, 0, 0, 0);
   gtk_box_pack_end((GtkBox *) new, (GtkWidget *) domainEntry, 1, 1, 0);

   return new;
 }

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您是否在新窗口小部件上调用了gtk_widget_show()