[Glade-users] how to replicate a glade designed window?

Tristan -

Thanks, this does just what I need.  So I see the way this works is that if you call glade_xml_new once, then 
calling glade_xml_get_widget multiple times keeps giving you the same widget; but calling glade_xml_new again 
gives you a whole new set of widgets.

Dave Cottingham

 -------------- Original message ----------------------
From: "Tristan Van Berkom" <tristan.van.berkom at gmail.com>
On Mon, May 19, 2008 at 7:46 PM,  <dcottingham00 at comcast.net> wrote:
Suppose I have used glade to design a window for displaying a view, but I want 
my application to be able to fire up multiple of these windows at the same time, 
each showing this kind of view of a different object instance.  I confess I 
cannot figure out how to do this.  It seems you'd need to somehow clone the 
whole widget tree.

Can someone take pity on me and explain how this is done?  This has to be a 
really elementary question, but I can't find the answer.

Just do something like this:

for (i = 0...items) {
   xml = glade_xml_new (...);

   if ((widgets[i] = glade_xml_get_widget (...)) == NULL)
       error ();

   /* Here you need to deal with the limitation of having to use a
GtkWindow toplevel,
    * so assuming its a normal widget you'll have to do something like this:
   toplevel = glade_xml_get_widget (...);
   g_object_ref (widgets[i]);
   gtk_container_remove (widget from the toplevel);
   gtk_widget_destroy (the toplevel);

   /* and always dont forget to not leek the GladeXML */
   g_object_unref (xml);

Note that in the GtkBuilder api you can do exactly the same.


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