[meld] filediff, meldbuffer: Make MeldBuffer handle the common undo sequence
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filediff, meldbuffer: Make MeldBuffer handle the common undo sequence
- Date: Sat, 2 Apr 2016 21:44:45 +0000 (UTC)
commit 9738566b1640651e0b4523c948c955034a1dce47
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Apr 2 08:05:14 2016 +1000
filediff, meldbuffer: Make MeldBuffer handle the common undo sequence
meld/filediff.py | 22 +++++++---------------
meld/meldbuffer.py | 5 +++++
2 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 4da970b..d19fc3b 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -211,11 +211,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self._cached_match = CachedSequenceMatcher()
for buf in self.textbuffer:
+ buf.undo_sequence = self.undosequence
buf.connect("notify::has-selection",
self.update_text_actions_sensitivity)
- buf.connect('begin_user_action',
- self.on_textbuffer_begin_user_action)
- buf.connect('end_user_action', self.on_textbuffer_end_user_action)
buf.data.connect('file-changed', self.notify_file_changed)
self.ui_file = gnomeglade.ui_file("filediff-ui.xml")
@@ -573,9 +571,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
for mergedfile in merger.merge_2_files(src, dst):
pass
self._sync_vscroll_lock = True
- self.on_textbuffer_begin_user_action()
+ self.textbuffer[dst].begin_user_action()
self.textbuffer[dst].set_text(mergedfile)
- self.on_textbuffer_end_user_action()
+ self.textbuffer[dst].end_user_action()
def resync():
self._sync_vscroll_lock = False
@@ -598,9 +596,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
for mergedfile in merger.merge_3_files(False):
pass
self._sync_vscroll_lock = True
- self.on_textbuffer_begin_user_action()
+ self.textbuffer[dst].begin_user_action()
self.textbuffer[dst].set_text(mergedfile)
- self.on_textbuffer_end_user_action()
+ self.textbuffer[dst].end_user_action()
def resync():
self._sync_vscroll_lock = False
self._sync_vscroll(self.scrolledwindow[0].get_vadjustment(), 0)
@@ -870,12 +868,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if self.undosequence.can_redo():
self.undosequence.redo()
- def on_textbuffer_begin_user_action(self, *buffer):
- self.undosequence.begin_group()
-
- def on_textbuffer_end_user_action(self, *buffer):
- self.undosequence.end_group()
-
def on_text_insert_text(self, buf, it, text, textlen):
text = text_type(text, 'utf8')
self.undosequence.add_action(
@@ -1817,10 +1809,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
dst_end = b1.get_iter_at_line_or_eof(chunk[4])
t0 = text_type(b0.get_text(src_start, src_end, False), 'utf8')
mark0 = b1.create_mark(None, dst_start, True)
- self.on_textbuffer_begin_user_action()
+ self.textbuffer[dst].begin_user_action()
b1.delete(dst_start, dst_end)
new_end = b1.insert_at_line(chunk[3], t0)
- self.on_textbuffer_end_user_action()
+ self.textbuffer[dst].end_user_action()
mark1 = b1.create_mark(None, new_end, True)
if chunk[1] == chunk[2]:
# TODO: Need a more specific colour here; conflict is wrong
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index b34cd2f..3c6d38e 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -42,6 +42,7 @@ class MeldBuffer(GtkSource.Buffer):
bind_settings(self)
self.data = MeldBufferData()
self.user_action_count = 0
+ self.undo_sequence = None
meldsettings.connect('changed', self.on_setting_changed)
self.set_style_scheme(meldsettings.style_scheme)
@@ -51,8 +52,12 @@ class MeldBuffer(GtkSource.Buffer):
def do_begin_user_action(self, *args):
self.user_action_count += 1
+ if self.undo_sequence:
+ self.undo_sequence.begin_group()
def do_end_user_action(self, *args):
+ if self.undo_sequence:
+ self.undo_sequence.end_group()
self.user_action_count -= 1
def do_apply_tag(self, tag, start, end):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]