views:

134

answers:

1

Using GTK, I'm trying to overlay a "More" prompt (but it could just as well be any drawing object) in the corner of a GtkTextView contained within a GtkScrolledWindow. I draw the prompt in the handler for the expose signal of the text view. It works, but when I scroll the window I get artifacts: the prompt is moved along with the contents of the text view and not erased.

In order to get rid of the artifacts I trigger a redraw after each scroll. This mostly works, but you can still see the prompt jumping up and down when you scroll quickly. Is there any way to prevent this? It would be nice if the prompt just "floated" on top of the text view.

I tried enclosing the scrolled window in a GtkEventBox and painting the prompt on top of that, but that didn't work either; the scrollbars and text view always paint over the prompt, even when you set the event box's window to go in front of its children's windows.

UPDATE

If I connect the GtkEventBox's expose callback with g_signal_connect_after(), then it is called after the expose callbacks of the GtkScrolledWindow and GtkTextView. The text view still draws over the event box though. I think this is because the scrolling happens asynchronously. Anybody got any idea how I can prevent my drawing from being overwritten?

ANOTHER UPDATE

So I guess what I actually need is a signal to connect to when the asynchronous scrolling has completed. If I can find out when that is, then I can trigger another expose event on the GtkEventBox. How can I get a notification when the scrolling has completed?

+1  A: 

Use a popup window for the prompt. This should avoid all problems with scrolling artifacts.

ergosys
I thought of that, but then if you move the main window, the popup window will stay where it is. Any ideas?
ptomato
I have no certain answer, but I'd try hooking into the configure event for the parent or the textview widget. Also look at set_transient_for().
ergosys
Sounds reasonable, thanks! I'm still not sure it's the ideal solution, but then again, neither is what I've got now ;-)
ptomato