Re: GtkDrawingArea within a GtkScrolledWindow problem



Norman Black wrote:
[snipped lots of stuff I had a difficulty following but I'll have a go
anyway]

I assume a scrolled window only displays scroll bars if the child is bigger
than it is? How does it determine when to show/hide the scroll bars?

I never got this to work automatically, so I put a callback to the
signal "size-allocate" on the scrolledwindow, and checked myself if the
size was maximum or not and hid/showed the scrollbars accordingly.
Worked like a charm. I'll treat you some code:

Callback:
void manage_scrollbars(GtkWidget *sw, GtkAllocation *allocation)
{
  if(allocation->width == xnestWidth && allocation->height ==
xnestHeight)
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
           GTK_POLICY_NEVER,
           GTK_POLICY_NEVER);
  else
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
           GTK_POLICY_ALWAYS,
           GTK_POLICY_ALWAYS);
}       

Signal connect:
gtk_signal_connect(GTK_OBJECT(scrolledwindow), "size-allocate",
                     GTK_SIGNAL_FUNC(manage_scrollbars), NULL); 

Note: if you're doing this on a toplevel window or a drawing area you'd
rather be using configure_event.

On another note, I myself am very confused by having to deal with *both*
"signals" and "events" and the way the callback functions seemingly can
have any number of arguments and a random return type.

Cheers,
-- 
Adam Huuva / Easter-eggs                 Spécialiste GNU/Linux
44-46 rue de l'Ouest  -  75014 Paris  -  France -  Métro Gaité
Phone: +33 (0) 1 43 35 00 37    -   Fax: +33 (0) 1 41 35 00 76
mailto:sventon easter-eggs com  -   http://www.easter-eggs.com




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