Re: Finding a widget in a Glade interface

2008-08-03 Thread dhk

Nicola Fontana wrote:

On Thu, 31 Jul 2008 11:07:34 +
dhk [EMAIL PROTECTED] wrote:


Jim George wrote:
I wasn't a fan of keeping the GladeXml object around due to the 
resources it used.  Even though it's not as efficient as storing 
pointer, I wish I could just traverse up and down the the object tree 
for my pointer.  I guess I'll be storing the pointers that I need.  That 
would mean that after calling glade_xml_new() I need to call 
glade_xml_get_widget() on each object I will need and then save that 
pointer . . . right?


You don't need special API to traverse Gtk widgets, and GladeXml
is less than needed: just use GTK_IS_CONTAINER() and
gtk_container_get_children() or gtk_container_forall().

If you want to go from the leafs to the root, use
gtk_widget_get_parent().

Is gtk_container_get_children() suppose to return a list of all children 
including children of children down to the last leaf or just the 
immediate children?  I only seem to get the immediate children.  Will 
gtk_container_foreach() or gtk_container_forall() go down all levels to 
the last leaf or just the next level?


Thanks,
Dave
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Finding a widget in a Glade interface

2008-08-03 Thread Nicola Fontana
On Sun, 03 Aug 2008 19:10:37 +
dhk [EMAIL PROTECTED] wrote:
 Is gtk_container_get_children() suppose to return a list of all children 
 including children of children down to the last leaf or just the 
 immediate children?  I only seem to get the immediate children.  Will 
 gtk_container_foreach() or gtk_container_forall() go down all levels to 
 the last leaf or just the next level?

Both work on immediate children. You must call them recursively,
something like that:

void
action(GtkWidget *widget)
{
  /* Do something */
}

void
callback(GtkWidget *widget)
{
  action(widget);
  if (GTK_IS_CONTAINER(widget))
  gtk_container_foreach(GTK_CONTAINER(widget),
callback, NULL);

}

gtk_container_foreach() is the way: the forall() version
traverses also internal stuff I think you don't care about.

Ciao
-- 
Nicola
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list