Re: GtkNotebook problems



Owen Taylor wrote:
> 
> Damon Chaplin <damon@karuna.freeserve.co.uk> writes:
> 
> > I think there are a couple of problems with GtkNotebook (GTK+ 1.2.6):
> >
> >  1) gtk_notebook_real_switch_page() currently queues a resize, but
> >     for complicated layouts this can make page switching quite slow,
> 
> Really? Resizing is almost always pretty instantaneous.

I'm rewriting the Day view of gnome-cal, using a GnomeCanvas. After a bit
more investigation it seems that the problem is that the Year view adds an
idle function during size_allocate which takes quite a bit of time, so when
the notebook switches to my view it gets repainted slowly (about 0.5 sec delay).

So doing a resize can be slow, though I'm not sure why the Year view is that
slow. Maybe just too many canvas items (something like 540).

 
> >  2) gtk_notebook_size_request() sometimes shows, hides, or unmaps child
> >     widgets. I don't think this should be done here, and I think this may
> >     be causing a problem I have where pages sometimes do not appear at all.
> 
> Well, with the way GTK+ 1.2 works, the map/unmap must be done here.
> I don't believe that gtk_notebook_size_request() ever shows or
> hides pages, though it does do that to tab labels.
> 
> The problem is that gtk_widget_real_show() has code like:
> 
> static void
> gtk_widget_real_show (GtkWidget *widget)
> {
>   g_return_if_fail (widget != NULL);
>   g_return_if_fail (GTK_IS_WIDGET (widget));
> 
>   if (!GTK_WIDGET_VISIBLE (widget))
>     {
>       GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
> 
>       if (widget->parent &&
>           GTK_WIDGET_MAPPED (widget->parent) &&
>           !GTK_WIDGET_MAPPED (widget))
>         gtk_widget_map (widget);
>     }
> }
> 
> So, if we show a non-current page of a shown notebook, it will get
> mapped, so we need to unmap it again in the size_request.

OK. I understand now. It just looked out of place there.


> There are basically possible two solutions we can take for GTK+-1.4:
> 
>  1) Use a GdkWindow per page. That way, we can just leave the
>     child widget mapped and show/hide the GdkWindow.
> 
>  2) Add ::child_shown ::child_hidden signals/vfuncs to
>     gtk_container, move the gtk_widget_map(child)
>     to gtk_container_real_child_shown(), and override
>     that in GtkNotebook.

Both look OK to me, but (1) is probably easier to do.

Damon



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