Re: Too long menus

Matt Kimball <> writes:

> Hello GTK+ folks.
> One particular itch of mine about GTK+ apps is when you've got an
> option menu with enough options that the menu height is actually
> taller than your screen height.  You can't get to some of the options
> because they run off the screen.
> So, how to fix this problem?  I thought it might be nice if the menu
> code truncated the menu to fit the screen and put arrows at the top
> and/or bottom of the menu to indicate more options are available.  And
> if the user moves her mouse over the arrows, the menu would scroll
> through the available options until she finds the one she needs.

Handling menus bigger than the screen has been on the TODO list
for a long time, and this (scrolling the menu) was the way
I wanted to implement it. So, thanks for workingo on this.
> So, I got to work and started hacking up the gtkmenu.c code yesterday.
> As of today I've got scroll arrows working on menus which are too
> long.  A patch against GTK+ 1.2.4 is attached.  It seems to apply
> cleanly to the current CVS version too, but I haven't tested that.
> The code could stand to be cleaned up and there are some rough edges
> in the behavior, so I wouldn't necessarily expect you folks to include
> the patch as-is.

Actually, I can't get this patch to work. Once I
ixed a small conflict against current CVS, it would come
up with the arrows, but would not prelight or scroll.

I also had some other problems:

 - Warnings about incorrect use of gtk_widget_set_request()
 - It seems to break the "pop up and stay up" capability of 
   menus, at least in some case.

One possilibility is that this is just some subtle version
creep problems with the changes from 1.2.4 - 1.2.5 - since
your patch is a CVS diff, you might want to try it against
current CVS.

> But, do y'all think this is the best way to handle the problem?  Is
> this a solution worth pursuing?  

> Any ideas how to avoid that obnoxious flicker while scrolling?

I don't quite understand how you are doing the scrolling,
but the flicker is almost certainly coming from

 gtk_widget_size_allocate (GTK_WIDGET (menu), &allocation)

(Which is, btw, not allowable. Only a parent can call
 size_allocate on a child.) 

I think what you want to do to scroll nicely is to use the
GtkViewport method of scrolling where you move one GdkWindow
inside another.  (This limits you to 32768 pixel high menus, but that
is a lot better than currently, and probably greater than most people's
patience for letting a menu scroll.) I'd probably use a Viewport for this.

In fact, you might want to use a GtkScrolledWindow. Once
the user has torn off the menu, you really need to have a


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