Re: problems with GtkPaned and allocation/set_position



On Wed, 2003-05-21 at 22:42, Paul Davis wrote:
> [ major caveat: working with gtk+ 1.2 ]
> 
> i don't know if this has gotten any better with gtk+2, but in the 1.2
> series, attempts to use gtk_paned_set_position() before the paned has
> been allocated its final size result in failure. the position is
> clamped to the initial allocation size, and thus when later
> allocations occur that expand the size, the original position is never
> used.
> 
> to fix this, i have had to use a connect_after signal handler for the
> allocation signal, and within that signal check to see if the
> allocation is large enough for the desired position, then set it, and
> then disconnect (or make sure the set_position() is not called again,
> since this causes an endless cycle of set_position() -> queue_resize()
> -> size_allocate() signals).
> 
> this all seems very messy. has it been improved in gtk+2, and if not,
> is it likely to be?

I'm not sure what you mean by "allocated a final size". Most programs
allocate each widget only once when a window is initially shown,
and I'm pretty sure GtkPaned handles set_position() before 
size_allocate() fine.

I've never seen a problem with setting the paned position, from, say,
a Glade file, even for 1.2.

If widgets are getting allocated to a tiny size before they get their
final size, then you are probably doing something funny in your app.

It might be possible to treat the set position as "virtual" and 
never clamp it, I might even take a patch to do that, though I'd be
worried that it would look bizarre to the user if the paned was
clamped to the right edge, they resized the window bigger, and the
paned stayed clamped to the right edge.

But I don't think it should be necessary in most cases, and I'd like to
see an test case of where things don't work first.

Regards,
                                         Owen

(Certainly both the size allocation and the paned positioning code
have been extensively rewritten and improved in various ways in the last
4+ years, so the 2.x may well behave better for your case. Nothing
has changed in particular in respect to paned clamping, as far as I
know.)




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