[meld] meldbuffer: Fix tag applying on paste (bgo#709580)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] meldbuffer: Fix tag applying on paste (bgo#709580)
- Date: Sat, 8 Feb 2014 23:02:15 +0000 (UTC)
commit ef124355cef3a8e6ac93cf1200b15c0892ccdbe7
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Feb 9 08:51:35 2014 +1000
meldbuffer: Fix tag applying on paste (bgo#709580)
This is just a horrible hack around GtkTextBuffer's limited hooks for
dealing with clipboard stuff.
meld/meldbuffer.py | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index 74aaa67..8959877 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -34,6 +34,26 @@ class MeldBuffer(GtkSource.Buffer):
def __init__(self, filename=None):
GtkSource.Buffer.__init__(self)
self.data = MeldBufferData(filename)
+ self.user_action_count = 0
+
+ def do_begin_user_action(self, *args):
+ self.user_action_count += 1
+
+ def do_end_user_action(self, *args):
+ self.user_action_count -= 1
+
+ def do_apply_tag(self, tag, start, end):
+ # Filthy, evil, horrible hack. What we're doing here is trying to
+ # figure out if a tag apply has come from a paste action, in which
+ # case GtkTextBuffer will 'helpfully' apply the existing tags in the
+ # copied selection. There appears to be no way to override this
+ # behaviour, or to hook in to the necessary paste mechanics to just
+ # request that we only get plain text or something. We're abusing the
+ # user_action notion here, because we only apply the tags we actually
+ # want in a callback.
+ if tag.props.name == 'inline' and self.user_action_count > 0:
+ return
+ return GtkSource.Buffer.do_apply_tag(self, tag, start, end)
def reset_buffer(self, filename):
"""Clear the contents of the buffer and reset its metadata"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]