Re: size-request
- From: Jamie Guinan <guinan bluebutton com>
- To: Havoc Pennington <hp redhat com>
- Cc: <gtk-list gnome org>
- Subject: Re: size-request
- Date: Thu, 10 Jan 2002 01:21:19 -0500 (EST)
On 9 Jan 2002, Havoc Pennington wrote:
>
> Jamie Guinan <guinan bluebutton com> writes:
> > I have an application in which I want to use a GtkDrawingArea,
> > and I want to control how it responds to size-request events.
> >
> > Should I,
> >
> > A. Connect to the "size-request" signal? Does modifying
> > requisition->width/height in a handler have any effect?
> >
>
> It ought to, if you connect_after, but I've had it not work in the
> past I think. Maybe I was doing something weird. You must
> connect_after though or the default handler will overwrite what you
> put in.
What I was looking to do was have a layout like,
GtkWindow
`-GtkVBox
|-GtkDrawingArea
`-GtkStatusBar
created with a default "preferred" size for the GtkDrawingArea, but be
able to resize it and catch the size changes so that I could scale or crop
the contents accordingly.
I was a bit confused about the semantics of size-request. I expected
it to mean "this is how much space I'm giving you, change it if you want
to", and that the requisition would be different every time I resized
the window. I was surprised to find that the requisition does *not*
change, its always what I last set it to. And with,
gtk_window_set_policy(GTK_WINDOW(main_window), FALSE, TRUE, FALSE);
I can't resize the window below the requisition limits. I guess this
makes sense for most widgets, where one doesn't want them to be hidden
when the window size is reduced, but it makes it a little awkward for
what I'm trying to do. I ended up dancing around with two signals:
1. I connect to "size-request", and pass my preferred initial size the
first time (the GtkDrawingArea is created that size), then
{0,0} every successive time, which allows the window to be
sized down.
2. I connect to "size-allocate", and scale/crop the GtkDrawingArea
contents in that handler.
Maybe there's a better way, but this works well enough.
-Jamie
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]