Re: set_resize



Il giorno gio, 15/01/2009 alle 16.41 -0500, Havoc Pennington ha scritto:
> Hi,
> 
> On Thu, Jan 15, 2009 at 10:04 AM, Pietro Battiston <toobaz email it> wrote:
> > I already considered my doubt as answered (see below), but I disagree
> > with what you say: if you call size_request "minimum size", why don't
> > you fulfill it, and how do you call "set_size_request"?!
> >
> > Maybe you meant set_size_request?
> 
> I don't know what you mean; set_size_request just sets the size
> request. The size request is defined as the minimum size, that is how
> GTK works. If you don't set it with set_size_request, then the size
> request (aka minimum size) of a window will be the sum of the minimum
> sizes (size requests) of all the contained widgets in the window.
> set_size_request is just a way to override the "normal" minimum size.
> 
> I promise I am right, I added gtk_widget_set_size_request in the first place:
> 
> 2001-08-07  Havoc Pennington  <hp pobox com>
> 
>  	* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
>  	(gtk_widget_get_size_request): new function
> 
> And the API docs are:
> 
>  * gtk_widget_set_size_request:
>  * @widget: a #GtkWidget
>  * @width: width @widget should request, or -1 to unset
>  * @height: height @widget should request, or -1 to unset
>  *
>  * Sets the minimum size of a widget [...]
> 
> When the docs say "Also remember that the size request is not
> necessarily the size a widget will actually be allocated," they are
> primarily referring to the fact that the widget can be *larger* than
> its size request, because there is extra space in the window for
> whatever reason.


MMhhh... I think there is somewhere a problem in communication, and
since you forged the terms at the time I still was a schoolboy, the
problem is evidently mine...

So I'll try to explain what I mean: get_size_request returns a size that
I'll call x and that is a request "stronger" than the one returned by
size_request, right? I mean: the user can't shrink it. How do you call
x? Or is the fact that the user can't shrink a window just related to a
particular flag set collaterally by set_size_request? I searched for
something like that in the documentation, but with no luck.


> It is possible for widgets to get a size smaller than their minimum
> size, but only due to a bug in something, really. It can be due to a
> bug in the window manager rather than the app, so gtk widgets usually
> try not to crash if they get a size below the minimum.

can't it also just be due to a user resizing?!

When I program in gtk, I always think to size_request (or if you prefer
the do_size_request() method of the python subclass of gtk.SomeThing I'm
working on) as a size I'd like for my widget. But when I really need a
size under which the widget is really ugly, or maybe crashes, I use
set_size_request. Is this approach totally wrong?

That said, I thought that instead "as far as a user can resize (=as far
as I use size_request but not set_size_request), I don't see anything
bad in the window manager doing it" (this is referred to your above
text).

So in my utopic world (where every window manager obeys my orders),
metacity would have just said "size_request? sorry, I'll give you less,
I have not enough screen. get_size_request (yours or of some children)?
OK, here you are, but it's your fault if you overflow". Anyway, I woke
from this dream already a couple of emails ago.

> 
> > What I wanted is: windows which don't overflow the screen when their
> > size_request (but not their set_size_request) is too big; however, I
> > understood this is impossible without coordinate improvements to the
> > window manager(s) _and_ gtk.
> 
> Some window managers may automatically force windows to fit on the
> screen, but it's not technically allowed for them to force windows
> below their minimum size. Some may do it anyway, perhaps, but it's
> pretty much a bug.
> 
> If you want to resize a window without changing its minimum size, then
> the right calls are things like gtk_window_set_default_size() and
> gtk_window_resize().

Yes, that's what I do. Together with ugly hacks to know how much I can
resize before overflowing screen...

Pietro



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