Re: Non-editable textview paste
- From: Thomas Christensen <christensenthomas gmail com>
- To: gtk-perl-list gnome org
- Subject: Re: Non-editable textview paste
- Date: Fri, 01 Jul 2005 01:57:22 +0200
"muppet" <scott asofyet org> writes:
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
I want to fetch text pasted onto the (read-only) GtkTextView and
insert it into a GtkEntry. It's kind of a TELNET program, with a
output window (GtkTextView) and a input window (GtkEntry).
"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.
Nope, it will not get modified by the paste.
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.
Ok, I can react to the "button 2" signal, but is there a more generic
"paste signal"?
Also, I have done '#perldoc Gtk2::Selection' and googled a little, but
I can't quite find how to fetch the selection. I have seen mentions
of gtk_selection_convert at the GTK+ site's selections tutorial, which
I am not sure I fully understand; but Gtk2::Selection doesn't seem
have this method.
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.
Can I somehow hook into this code?
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.
Yes, I now hook into 'button-press-event', but need to fetch the
pasted string.
Thanks for the pointers, and tell me if this is not the right place to
ask, since it is mostly GTK+ oriented.
Thomas
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]