Moving widgets from one parent to another...?



The scenario:

I have 2 windows, each with widgets, somewhat like this:

+ Window1
+-+ VBox1
  +-- MenuBar1

+ Window2
+--* VBox2
   +-- Label1
   +-- Label2

Now, what I want to do is for a specific menu selection in Window1's menu bar,
create an instance of Window2 and then move the whole of vbox2 fro window2 into
vbox1.  So after it's done, I want things to look like this:

* Window1
+-+ VBox1
  +-+ MenuBar1
  +-+ VBox2
    +-- Label1
    +-- Label2
   
I had thought I might be able to do it like this, but it doesn't seem to work?

%<-----------------------------------------------------------
void
on_menuitem_activate        (GtkMenuItem     *menuitem,
                             gpointer         user_data)
{
	GtkWidget *window1, *vbox1, *window2, *vbox2;
	
	window1 = lookup_widget(GTK_WIDGET(menuitem), "window1");
	vbox1 = lookup_widget(window1, "vbox1");
	window2 = create_window2();
	vbox2 = lookup_widget(window2 "vbox2");

	gtk_container_remove(GTK_CONTAINER(window2), vbox2);
	gtk_container_add(GTK_CONTAINER(vbox1), vbox2);
	
	gtk_widget_show_all(vbox2); 
}

%<-----------------------------------------------------------

This code doesn't seem to work, and I can't understand why.  Anyon managed to do
this before?

TIA

John Breen



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