[Glade-users] Loading widgets from XML file using libglade



Im having problems getting libglade to load widgets from an XML file.  
My aim is to have a GtkVBox in a window - the window is made in code not 
Glade, and the contents of the vbox will be loaded from Glade files such 
that the contents of the vbox can change as the app runs. 

To test it out I created 2 Glade XML files page1.glade and page2.glade 
each have the following hierarchy:  GtkWindow->GtkVBox->GtkLabel

The label contains the text "Page1" or "Page2" accordingly. I want to 
load the GtkVBox from either file and use it to 'replace' a manually 
created vbox which is in code.

In the code which is just a short 'main' file Ive declared the following:

GladeXML* page1xml;
GladeXML* page2xml;

GtkWidget* mainwindow;
GtkWidget* rightpanescrollview;
GtkWidget* rightpanevbox;

page1xml=glade_xml_new("./page1.glade",NULL,NULL);
rightpanevbox= glade_xml_get_widget(page1xml,"mainvbox");

gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(rightpanescrollview),rightpanevbox);

The rightpanevbox is then put into the window.

But when the app runs the label from Glade doesnt appear and the 
following is printed on the console:

(a.out:3894): Gtk-CRITICAL **: gtk_scrolled_window_add_with_viewport: 
assertion `child->parent == NULL' failed
I tried decalring in code a GtkWindow and loading the top-level window 
widget from the XML file but again I got an error similar but slightly 
different suggesting that no widgets are actually being found in the file.

The file itself is found because it throws up an error if I change the 
filename in the call to  glade_xml_new but it seemingly cant find 
anything in that file.

Any suggestions? I can post the entire main code file if it would help 
its not very long.

Thanks
Andrew





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