Creating a local event loop (modality again...)



Suppose you have a text entry, where the user can enter
abbreviations, and the program must expand the abbreviations when the
user leaves the entry. This is pretty easy, all you must do is
connect the entry's "focus_out_event" to a handler that replaces the
abbreviations for the full text.

Now suppose that the abbreviations are not univocal, i.e. it might
happen that the user enters an abbreviation that matches more than
one expansion. In that case, I would like to have the program pop up
a window with the list of potential matches, and let the user decide
which expansion she meant. If there are more than one ambiguous
match, the program should pop up the window to let the user select
which is the right expansion for the first one, then pop it up again
for the second, and so on.

I'm having real trouble implementing this. The main problem here is
that the "focus_out_event" handler must create the window, display
it, and handle this window's user input, and even potentially repeat
all of this several times BEFORE returning to the main Gtk event
loop. What this amounts to, basically, is a local event loop for this
window exclusively, but I haven't been able to figure out how to do
that yet. I considered using gtk_main_iteration(), but I understand
that it does busy waiting, and I'm not THAT desperate.

Any pointers on how to go about this? Or even a suggestion for a
better implementation? I must admit I hate modal windows myself, but
I seem unable to come up with a better idea.

Thanks in advance,

        Federico







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