Re: GtkMenu question



13.12.09, 17:45, "Julien Bramary" <julien_bramary msn com>:
1. being able to tell that the user hasn't clicked on any item when the menu disappears (and make a default choice)
2. prevent the menu from disappearing unless the user has actually activated one of the menu items

I tried to implement 1 by connecting to the "hide" signal and setting some flag in the menu items handler, but it turns out the "hide" signal is sent before the one sent by activating a menu item so it doesn't work.

GtkMenuShell is parent class of GtkMenu. Maybe one of [1] is what you want ("deactivate", "cancel"); can't test myself.
If not, and assuming double updates are evil, test whether "hide" and optional activation emissions both appear in same iteration of main loop -- if so, you can play with g_idle_add() to set final value:

before popup -> set default value to tmp
on optional activate -> set activated value to tmp
... (iteration ends)
on high-priority idle -> set final value from tmp

[1] http://library.gnome.org/devel/gtk/stable/GtkMenuShell.html#GtkMenuShell.signals


-- 
Artur

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