[meld] filediff: Add pane-specific reload prompt when changing file selectors



commit 02b3daf316273926f87433bd08a2b1c5b6a6a99d
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Feb 9 06:58:21 2018 +1000

    filediff: Add pane-specific reload prompt when changing file selectors
    
    This is dealing with the same problem as the previous commit, but when
    using the file selectors to change the file loaded in to a single pane.

 meld/filediff.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 88581712..0dff0553 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -825,11 +825,12 @@ class FileDiff(MeldDoc, Component):
         self._after_text_modified(buf, starting_at, -self.lines_removed)
         self.lines_removed = 0
 
-    def check_save_modified(self):
+    def check_save_modified(self, buffers=None):
         response = Gtk.ResponseType.OK
-        modified = [b.get_modified() for b in self.textbuffer[:self.num_panes]]
-        labels = [b.data.label for b in self.textbuffer[:self.num_panes]]
-        if True in modified:
+        buffers = buffers or self.textbuffer[:self.num_panes]
+        modified = [b.get_modified() for b in buffers]
+        labels = [b.data.label for b in buffers]
+        if any(modified):
             dialog = Component("filediff.ui", "check_save_dialog")
             dialog.widget.set_transient_for(self.widget.get_toplevel())
             message_area = dialog.widget.get_message_area()
@@ -1691,11 +1692,12 @@ class FileDiff(MeldDoc, Component):
 
     def on_fileentry_file_set(self, entry):
         pane = self.fileentry[:self.num_panes].index(entry)
-        if self.check_save_modified() != Gtk.ResponseType.CANCEL:
+        buffer = self.textbuffer[pane]
+        if self.check_save_modified([buffer]) != Gtk.ResponseType.CANCEL:
             # TODO: Use encoding file selectors in FileDiff
             self.set_file(pane, entry.get_file())
         else:
-            existing_path = self.textbuffer[pane].data.filename
+            existing_path = buffer.data.filename
             entry.set_filename(existing_path)
         return True
 


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