I'm sorry to ask here generic GTK questions, because i'm learning
GTK at the same time than ruby-gtk.. If another mailing-list is more
appropriate to ask, you can redirect me there (although i'm satisfied by
the feedback here as i mentionned ;O) ).
I was wondering if there is in ruby-gtk an equivalent of eg Java's
SwingUtilities.invokeLater() or C# Windows.Forms's BeginInvoke() calls.
That allows to put in the event queue a callback (a Proc) that will be
run when the event queue is empty.
Here is the exact problem that makes me wondering this:
I'm writing as part of a project a rich text "component" that runs on
top of TextBuffer/TextView and loads/saves simple HTML, has links etc.
For links, I override "button-release-event". When the user clicks
on a link, I change the contents of the TextBuffer, no problem. But when
I'm done, the real GTK handler for the "button-release-event" (at least
that's what my interpretation of what's happening) takes over, sees that
the cursor moved between the "button-press-event" and the
"button-release-event" and selects the area between the location the
user clicked (on the link) and the end of the new buffer I displayed. Of
course I wouldn't want this selection to be here.
I tried to return true from my handler to "button-release-event",
but the GUI seems to freeze somehow (I guess the text widget is still in
the "button-press" mode, waiting for the "button-release" since nobody
told it it was released).
I tried to not signal_connect to "button-release-event", but to
signal_connect_after to it, but then I only get called on double clicks,
I guess that's because the TextView "eats" the signal since it processes it.
and in my handler I tried to move the cursor to the position it was
at the click on the link but I can't get it to work, and it won't always
be possible, if the new page I want to open is smaller than the page
where the user clicked the link.
Finally, attempt to kill the selection when in my event handler
(that is, before GTK's handler) trigger:
(gkms.rb:1912): Gtk-CRITICAL **: file gtktextview.c: line 5269
art_selection_drag): assertion `text_view->selection_drag_handler == 0'
(and then there is no selection, but the selection doesn't work well
anymore and it's obviously not the right way)
So my idea is when the user clicks, put a callback on the event
queue to open my link, that will be run after GTK is done with his
"button-release" handler (since I can't user signal_connect_after,