textview buffers and primary clipboard issue



Hi,

I have a GTK3 app that uses Notebook with a TextView buffer for 
each page.  At startup, I call:
|  tagset_atom_serialize = 
|         gtk_text_buffer_register_serialize_tagset(buf[i], "myapp");
| tagset_atom_deserialize = 
|         gtk_text_buffer_register_deserialize_tagset(buf[i], "myapp");

for each buffer.

Then I read and write files with:
|  gtk_text_buffer_deserialize_set_can_create_tags(buf[i],
|         tagset_atom_deserialize, FALSE);
| gtk_text_buffer_deserialize(buf[i], buf[i], 
|         tagset_atom_deserialize,   
|         &iter, fdata, (gsize )len, &error);

and
|  serialized = gtk_text_buffer_serialize(buf[i],
|         buf[i], tagset_atom_serialize,
|         &start, &end, &len);

All of that works.  Now here's the problem.  I can select text 
with the mouse in Buffer 1 and use middle button to paste it in 
Buffer 2 (ie, via the Primary clipboard).  BUT if there is a PixBuf 
in Buffer1, below the selected text, then somehow the pixbuf and 
many lines below it are put on the Primary clipboard, even though 
I did not select any of that with the mouse.  So when I paste 
it into Buffer 2 using the middle button, I see the selected text 
plus image(s) and extra junk.  Okay, that's bad enough ☺, but 
when I save that buffer (ie, serialize code above), the whole 
process hangs and I have to kill it with SIGKILL!  No error messages 
on stdout from the process.

I can work around this by using Ctrl-C to copy a mouse selection 
and Ctrl-V to paste, and that works as expected.

Here is the output of the xclip command, after selecting "baz" 
with the mouse (note the extra stuff put on the clipboard):
|  PRIMARY contents
| GTKTEXTBUFFERCONTENTS-0001. . . .<text_view_markup>
|  <tags>
|  </tags>
| <text>baz
| <pixbuf index="0" />
| 
| <pixbuf index="1" />
| 
| </text>
| </text_view_markup>
| GTKTEXTBUFFERPIXBDATA-00. .. .

and here is the secondary clipboard when using Ctrl-C on the same 
mouse selection:
|  clipboard contents
| GTKTEXTBUFFERCONTENTS-0001J <text_view_markup>
|  <tags>
|  </tags>
| <text>baz</text>
| </text_view_markup>


Any ideas on what I'm doing wrong and how to make middle-click 
paste work between buffers, when there is a pixbuf in the source 
buffer?

--
Doug McCasland, San Francisco  <dougm bravoecho net>


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