Re: [gtk-list] Re: gtk_widget_show_all [or "much ado about foreachand forall]
- From: Tim Janik <timj gtk org>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: gtk_widget_show_all [or "much ado about foreachand forall]
- Date: Fri, 22 Jan 1999 05:35:45 +0100 (CET)
On 20 Jan 1999, Thomas Mailund Jensen wrote:
> >>>>> "J" == J A M Molenaar <Klem.Prod@net.HCC.nl> writes:
>
> J> Sascha Ziemann wrote:
> >> Sascha Ziemann <szi@aibon.ping.de> writes:
> >>
> >> | gtk_widget_show_all does not show tree items. Is that intended?
> >>
> >> sorry: it shows items but doesn't show subtrees.
>
> J> Yes, I had the same problem a while ago... It had something to do
> J> with a TRUE value that had to be FALSE or visa versa... If you
> J> can't figure it out give a sample of the code you have written
>
>
> hmm...this kind of made me curious, since I couldn't find anything in
> the header files[1] like a flag to modify this kind of behavior...and
> since the only alternative to examining this was getting some real
> work done, I decided to track the show_all stuff...
[...]
> --<code from gtkcontainer.c>--------------------------------------------
> static void
> gtk_container_show_all (GtkWidget *widget)
> {
> g_return_if_fail (widget != NULL);
> g_return_if_fail (GTK_IS_CONTAINER (widget));
>
> gtk_container_foreach (GTK_CONTAINER (widget),
> (GtkCallback) gtk_widget_show_all,
> NULL);
> gtk_widget_show (widget);
> }
[...]
> --<code from gtktreeitem.c>--------------------------------------------
> static void
> gtk_tree_item_forall (GtkContainer *container,
> gboolean include_internals,
> GtkCallback callback,
> gpointer callback_data)
> {
> GtkBin *bin;
> GtkTreeItem *tree_item;
>
> g_return_if_fail (container != NULL);
> g_return_if_fail (GTK_IS_TREE_ITEM (container));
> g_return_if_fail (callback != NULL);
>
> bin = GTK_BIN (container);
> tree_item = GTK_TREE_ITEM (container);
>
> if (bin->child)
> (* callback) (bin->child, callback_data);
> if (include_internals && tree_item->subtree)
> (* callback) (tree_item->subtree, callback_data);
> }
> --</code>--------------------------------------------------------------
>
> Hmm...it would seem the include_internals was FALSE in the call, where
> we wanted it to be TRUE
>
> if (include_internals && tree_item->subtree)
> (* callback) (tree_item->subtree, callback_data);
>
>
> Now, the only difference between container_foreach and
> container_forall seems to be the lines
>
> if (class->forall)
> class->forall (container, TRUE, callback, callback_data);
> and
> if (class->forall)
> class->forall (container, FALSE, callback, callback_data);
>
> so changing the call in gtk_container_show_all to gtk_container_forall
> instead of gtk_container_foreach seems to solve the problem...so I
> tried it, and it did. What other consequences this could have I dare
> not say, though I can't really see how it could affect anything...
>
> ...of course, it doesn't really help me to fix it here, in my
> local installation...
>
> So, to quote the original poster: "Is that intended?"
no not really, _forall() is meant to iterate over widgets that are privately
handled by certain containers, and those containers will care about the
widget's visibility themselves. the proper fix for the above case is to
override the default show_all handler for a tree item and let that call
show_all on bin->child and tree_item->subtree.
>
> /mailund
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]