[pygtk] Replacing text with paste

Walter Leibbrandt walter at translate.org.za
Mon Jan 5 23:45:34 WST 2009


I manage my own undo buffer of changes made to a gtk.TextView. This 
necessarily means that the undo controller is connected to the relevant 
TextBuffer's "delete-range" and "insert-text" signals. Changes made 
during these signals are stored on the undo stack.

Then I ran into some weird behavior: when I select any region of the 
text in the text buffer and then paste something in that was previously 
copied to the clipboard, an "insert-text" and then a "delete-range" 
signal is emitted. This means that, when undoing, the "delete-range" is 
undone first and this leaves both the originally selected text as well 
as the text it was replaced with in the TextView, until undo is called 
again, undoing the "insert-text" changes.

Is there a signal I can connect to to catch this special case, or does 
anyone have another idea of how to combine these two into a single undo 

Thanks in advance,


Walter Leibbrandt                  http://translate.org.za/blogs/walter
Software Developer                                  +27 12 460 1095 (w)

Recent blogs:
* Virtaal's MVCisation
* Things that changed the way I code
* Switching from Subversion to git

More information about the pygtk mailing list