[Glade-users] Loading widgets from XML file using libglade
- From: ajwood at theiet.org (Andrew Wood)
- Subject: [Glade-users] Loading widgets from XML file using libglade
- Date: Wed, 16 Dec 2009 19:10:10 +0000
Ah. The rightpanevbox is inside the right portion of an HPane. I want
the left side of the HPane to stay the same (declared in code) but the
contents of the right side to change (and be loaded from Glade).
The page1.glade file is as follows. I dont actually want that 'window1'
but I cant seem to find a way of setting the top level as just a vbox.
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window1">
<child>
<widget class="GtkVBox" id="mainvbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">PAGE1</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
David L?pez Luengo wrote:
The problem comes because your rightpanevbox widget is already inside
another widget. Are you sure that in the mainvbox file definition,
rightpanevbox is the top widget? If you post the xml would help a lot.
It seems to be an easy-to-solve problem :-)
Good luck!
--
David
2009/12/16 Andrew Wood <ajwood at theiet.org <mailto: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;
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
_______________________________________________
Glade-users maillist - Glade-users at lists.ximian.com
<mailto:Glade-users at lists.ximian.com>
http://lists.ximian.com/mailman/listinfo/glade-users
--
David
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
David L?pez Luengo wrote:
The problem comes because your rightpanevbox widget is already inside
another widget. Are you sure that in the mainvbox file definition,
rightpanevbox is the top widget? If you post the xml would help a lot.
It seems to be an easy-to-solve problem :-)
Good luck!
--
David
2009/12/16 Andrew Wood <ajwood at theiet.org <mailto: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;
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
_______________________________________________
Glade-users maillist - Glade-users at lists.ximian.com
<mailto:Glade-users at lists.ximian.com>
http://lists.ximian.com/mailman/listinfo/glade-users
--
David
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]