Re: GtkToolbar - 2 sizes needed ...



Michael Meeks <michael ximian com> writes:

> 	One thing that struck me as I looked at it is that the BonoboUIToolbar
> provides 2 sizes:
> 
> 	a) size_request:
> 		returns the size of the popout button with
> 	associated maximum height for either orientation.
> 	( or full-size for un-docked case [1] )
> 
> 	b) 'preferred_width/height' properties
> 		these give the normal size of the widgets, given
> 	infinite space - as normally in size_request.
> 
> 	The dock of course, uses these two to a) ensure there is always enough
> space for the popout - and hence that we never size_allocate less then
> was size_requested, and b) can use the preferred_width/height to juggle
> the remaining space in a constrained space situation.
> 
> 	I was wondering how this was intended to be achieved with the
> GtkToolbar ? - it looks (on a very casual glance) as if your
> size_allocate always returns b) and there is no way to get a), and it is
> expected that people allocate less size than is requested routinely (?).

When the GtkToolbar::show_arrow property is TRUE (which it is by
default when you use the new API), the size request returns the size
of the arrow with associated maximum height, just as BonoboUIToolbar.

When show_arrow is FALSE (which would be the case when the toolbar is
floating, to prevent the floating toolbar from degenerating into an
arrow), size_request will return its preferred size in both
dimensions.

What you may have missed is this:

      /* There is no point requesting space for the arrow if that would take
       * up more space than all the items combined
       */
      long_req = MIN (long_req, pack_front_size);

Ie. size_request never actually requests the "pack_front_size" unless
it is _smaller_ than the arrow.

So, as far as I can see, GtkToolbar behaves like BonoboUIToolbar,
except that there is no convenient way to get its preferred size. 

Not knowing the dock in any detail, what I would recommend for the
purposes of preferred size, is to treat the GtkToolbar as infinitely
greedy, ie. have the dock's size allocation first hand out space based
on requisitions, then give all remaining space to the toolbar.

In my opinion, the right way to get "preferred size" information (and
I agree that it is useful and needed in many cases) would be to
have an extended size negotiation scheme within gtk+ that would also
allow stuff like wrapping boxes and widgets reporting baselines. 

Søren



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