Re: grab paste buffer




John Hurst <jhurst@utac.net> writes:

> Hi,
> 
> I'm using a GtkText object as an interactive terminal in a
> microcontroller console application.
> 
> - I have made it not editable.
> 
> - Data from the serial port connected to the microcontroller is
> collected by a handler (installed with gdk_input_add()) and then
> appended to the Text widget.
> 
> - Keyboard input is collected by another handler (installed with
> gtk_signal_connect() on event "key_press_event"), and then written to
> the controller which then echos back to the Text widget.
> 
> All is well... now I want to be able to paste into the application with
> mouse button 2 (which will actually involve intercepting the data and
> sending it to the microcontroller, as with kbd input). I've installed a
> handler for that, but I need to get my hands (or buffer) on the data.
> I've grepped all available documentation and mailing lists. Hours of
> UTSL have led me to believe the answer is in gtkselect.c, but the more I
> read, the less I seem to know. Is anyone in the mood to provide a hint?

Well, the first thing to do is go read the section on selections
in the GTK+ tutorial. (Available from www.gtk.org.) 

Then, you just need to know that the Editable widgets don't even to
try to paste when not editable. So you need to connect to
"button_press_event", and do a gtk_selection_convert() yourself.
Then, you need to connect to "selection_received" to get the data when
it arrives. Your "selection_received" handler then needs to
do a gtk_signal_emit_stop_by_name(), so that the GtkEditable
default selection_received handler doesn't get called.

Hope that helps. Let me know if you have more questions.

                                        Owen



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