Hi!

I think Ive a solution to what youre asking me.

--- Guenther Sohler <[EMAIL PROTECTED]>
wrote:
[snip]
> I did not yet find a good strategy to delete all
> widgets/childs from within a
> vbox.
>
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

GtkBox [base of VBox & HBox], has a GList of children
it contains. You can simply iterate over the list,
and delete each widget you want.

This code must work. Sorry, I couldnt check it.
Cheers
Muthu.

<CODE>


#include <gtk/gtk.h>

void box_remove(GtkWidget *btn, GtkBox *box)
{
     g_assert(btn!=NULL && box!=NULL);
     
     /* Remove all widgets in the */      
     GtkWidget *widget=NULL;
     GList *ptr=box->children;
     while(ptr->next!=NULL){
          widget=(GtkWidget *)ptr->data;
          ptr=ptr->next;
          
          if(widget!=btn && widget!=NULL){
             gtk_widget_destroy(widget);
          }
     }
     return;
}

int main()
{
  GtkWidget *w,*box,*btn;
  gtk_init(NULL,NULL);
  
  w=gtk_window_new(GTK_WINDOW_TOPLEVEL);
  box=gtk_hbox_new(0,0);
  
  gtk_container_add(GTK_CONTAINER(w),box);
  {
      int i=0;
      while(i<10){
     
gtk_box_pack_start_defaults(GTK_BOX(box),gtk_label_new(g_strdup_printf("%d",i)));
      }
  }
  btn=gtk_button_new_with_label("Remove Labels");
  gtk_box_pack_start_defaults(GTK_BOX(box),btn);
  
 
g_signal_connect(G_OBJECT(btn),"clicked",G_CALLBACK(box_remove),(gpointer)box);
  
  gtk_widget_show_all(w);
  
  gtk_main();   
}
</CODE>



                
__________________________________ 
Discover Yahoo! 
Find restaurants, movies, travel and more fun for the weekend. Check it out! 
http://discover.yahoo.com/weekend.html 

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to