[699] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Suggestion: show a whole tree of widgets
daemon@ATHENA.MIT.EDU (Stefan Wille)
Sat Aug 9 16:14:58 1997
Date: Sat, 09 Aug 1997 22:12:40 +0200
From: Stefan Wille <Stefan_Wille@public.uni-hamburg.de>
To: gtk-list@redhat.com
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com
Hello everybody,
today I went through Ian's tutorial, and I
asked myself why I have to call
gtk_widget_show(mywidget);
for every single widget I create. If I could just
create, configure and pack all widgets and then had to
say 'show' only to their container (maybe a dialog), things
would become handier.
My suggestion is to introduce a new method
gtk_widget_show_all(GtkWidget* widget);
that shows a whole tree of widgets. One calls
it on the window that contains all the other widgets
to be shown.
Here's an implementation:
void gtk_widget_show_tree_impl(GtkWidget* widget, gpointer data)
{
/* show all descendants */
if( GTK_IS_CONTAINER(widget) )
gtk_container_foreach(GTK_CONTAINER(widget),
gtk_widget_show_tree_impl,
(gpointer)0);
/* show this */
gtk_widget_show(widget);
}
void gtk_widget_show_tree(GtkWidget* widget)
{
gtk_widget_show_tree_impl(widget,0);
}
As a test, I took Packing Demonstration Program from
Ian's tutorial, removed every call to gtk_widget_show and
changed the call
gtk_widget_show(window)
at the bottom to
gtk_widget_show_tree(window).
It works fine. And saves a lot of code, and is intuitive -
because most times you want to show the whole thing anyway.
Aahm, maybe something like this is part of gtk already? I have looked
for
such a call, but not found.
well, what do You think?
listening
Stefan Wille <Stefan_Wille@public.uni-hamburg.de>
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null