[Glade-users] Loading widgets from XML file using libglade
Tristan Van Berkom
tristan.van.berkom at gmail.com
Wed Feb 24 23:06:17 EST 2010
On Wed, Feb 24, 2010 at 2:05 PM, Andrew Wood <ajwood at theiet.org> wrote:
> Lukasz Gromotowicz wrote:
>> 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:
>>
>> page1xml=glade_xml_new("./page1.glade","mainvbox",NULL);
>>
>> and then
>>
>> rightpanevbox= glade_xml_get_widget(page1xml,"mainvbox");
>>
>> Hope it works,
>> good luck.
>>
>> LUK (gromot)
> How would I do this using GtkBuilder? As far as I can see
> gtk_builder_add_from_file doesnt support a similar argument.
>
> Using gtk_builder_get_object (builder, "mainvbox")) doesnt stop parent
> widgets being obtained as well.
>
> The mainvbox is in a window in Glade because you have to put it in one,
> but when I read the file into my program I already have a window for it
> to go in, I only need the vbox.
>
> Just doing
>
> gtk_builder_add_from_file (builder, "./gladexml/general.xml", NULL);
> generalpage= GTK_WIDGET (gtk_builder_get_object (builder,
> "mainvbox"));
>
> then
>
> gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(rightpanescrollview),GTK_WIDGET(generalpage));
>
> is giving the error:
> Gtk-CRITICAL **: gtk_scrolled_window_add_with_viewport: assertion
> `child->parent == NULL' failed
Ok, I believe there is an api to cherry pick objects that you want
parsed (its in one of the newer versions of GTK+).
Or, you can just remove the window in Glade (i.e. Glade does
not require you to have a toplevel GtkWindow for GtkBuilder
projects).
You should be able to do it with "Remove Parent" from the context menu
for your vbox.
Cheers,
-Tristan
>
>
>
> Regards
> Andrew
> _______________________________________________
> Glade-users maillist - Glade-users at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/glade-users
>
More information about the Glade-users
mailing list