Re: Non-editable textview paste




Thomas Christensen said:
I was wondering if anybody could give me a pointer to how to catch a
paste (non-clipboard primarily), in a textview.

I'm guessing that you want to catch a paste and redirect it to some other
destination, which will eventually modify the textbuffer on its own.  But the
"non-clipboard primarily" makes me wonder if perhaps you mean "i just want to
know whenever the buffer is modified"; if that's the case, you can just listen
to the "changed" or "insert-text" signals on the TextBuffer.


I have tried the 'clipboard-paste' signal but is doesn't get triggered
on a plain (middle-mouse) paste, and it's not applicable anyways since
my textview is editable => 0.

The selections are different; middle button paste is the PRIMARY, while Ctrl+V
is CLIPBOARD.  Inside GtkTextView, the 'paste-clipboard' signal handles the
CLIPBOARD selection, and the 'button-press-event' handler fetches and inserts
the PRIMARY selection when button==2.

Both of these eventually wind up down in gtk_text_buffer_insert_interactive()
with default_editable==FALSE (since you've set your treeview to non-editable)
and thus do nothing.


Any hints would be well received.

The paste-clipboard and button-press-event signals fire regardless of whether
the view is editable, so you can still hook up to them and do stuff.


-- 
muppet <scott at asofyet dot org>




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