Re: [gtk-list] Suggestion: show a whole tree of widgets




Well, I think it's a great idea :)  But I'm no GTK guru yet so It's really
only my opinion.  It'd be interesting to try it on more complex things
like menus (with the gtk_menu_new() that never gets shown), and ones with
several layers of packing.

If it all works good I'd like to see it as part of the standard distro..
course, I'd have to rewrite all my examples :)

Ian


On Sat, 9 Aug 1997, Stefan Wille wrote:


> 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
> 
> 


Regards,

Ian

--

No problem is insoluble in all conceivable circumstances.



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