tags:

views:

33

answers:

1

Hi,

I have problem while adding a child to a GtkVBox. The VBox is inside a GtkViewPort which is inside a ScrolledWindows.

After the child it's added using gtk_box_pack_end I check if it's really added checking the GLIST and it appears that it's added. Although visually anything appears and the scrolled window gets really big. Like if something really big and invisible was added.

The code is as follows:

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;
}

The function newChild() is as follows:

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;
 }

Any suggestions?

+1  A: 

Have you called gtk_widget_show() on your new widgets?

ptomato
yes, the code it's right after it's packed (not showed int the code example). I tried all show functions: show_all show_now and show. Doing that increases the scrolled window a lot but nothing shows.
gvalero87
Have you tried `show_all` on your main window, just to check that you're not forgetting something? If that's not the problem, I think it must be somewhere else in your program. Can you make a minimal example that reproduces the problem?
ptomato
I forgot to say that the problem got resolved. It was my mistake. I was calling gtk_widget_show on another widget :s..
gvalero87