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

As far as I can see, the Gtk-Critical fault says that you can not put the
widget onto another parent because it already has a parent. The second
parameter in the glade_xml_new() is for the root widget node. Try this:


and then

rightpanevbox= glade_xml_get_widget(page1xml,"mainvbox");

Hope it works,
good luck.

LUK (gromot)

2009/12/16 Andrew Wood <ajwood at theiet.org>

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;

rightpanevbox= glade_xml_get_widget(page1xml,"mainvbox");


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.


Glade-users maillist  -  Glade-users at lists.ximian.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20091217/d707c2db/attachment.html 

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