[meld/ui-next] filediff: Add in the new ChunkMap



commit f32c0c1d223c7324bb9fb99d06ffdd4c561558c6
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Mar 30 07:31:45 2019 +1000

    filediff: Add in the new ChunkMap
    
    Eventually this will either just take over from the SourceMap, or I'll
    add a user preference for whether the SourceMap or ChunkMap are to be
    used.

 meld/filediff.py              | 10 +++++
 meld/resources/ui/filediff.ui | 85 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 77 insertions(+), 18 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index a815a824..1bbfa71f 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -131,6 +131,9 @@ class FileDiff(Gtk.VBox, MeldDoc):
     actiongutter1 = Template.Child()
     actiongutter2 = Template.Child()
     actiongutter3 = Template.Child()
+    chunkmap0 = Template.Child()
+    chunkmap1 = Template.Child()
+    chunkmap2 = Template.Child()
     dummy_toolbar_actiongutter0 = Template.Child()
     dummy_toolbar_actiongutter1 = Template.Child()
     dummy_toolbar_actiongutter2 = Template.Child()
@@ -232,6 +235,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
             "dummy_toolbar_linkmap", "filelabel_toolitem", "filelabel",
             "file_open_button", "statusbar",
             "actiongutter", "dummy_toolbar_actiongutter",
+            "chunkmap",
         ]
         map_widgets_into_lists(self, widget_lists)
 
@@ -1555,6 +1559,10 @@ class FileDiff(Gtk.VBox, MeldDoc):
 
     def on_diffs_changed(self, linediffer, chunk_changes):
 
+        for pane in range(self.num_panes):
+            pane_changes = list(self.linediffer.single_changes(pane))
+            self.chunkmap[pane].chunks = pane_changes
+
         # TODO: Break out highlight recalculation to its own method,
         # and just update chunk lists in children here.
         for gutter in self.actiongutter:
@@ -2090,6 +2098,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
                 self.vbox[:n] + self.file_toolbar[:n] + self.sourcemap[:n] +
                 self.linkmap[:n - 1] + self.dummy_toolbar_linkmap[:n - 1] +
                 self.statusbar[:n] +
+                self.chunkmap[:n] +
                 self.actiongutter[:(n - 1) * 2] +
                 self.dummy_toolbar_actiongutter[:(n - 1) * 2]):
             widget.show()
@@ -2098,6 +2107,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
                 self.vbox[n:] + self.file_toolbar[n:] + self.sourcemap[n:] +
                 self.linkmap[n - 1:] + self.dummy_toolbar_linkmap[n - 1:] +
                 self.statusbar[n:] +
+                self.chunkmap[n:] +
                 self.actiongutter[(n - 1) * 2:] +
                 self.dummy_toolbar_actiongutter[(n - 1) * 2:]):
             widget.hide()
diff --git a/meld/resources/ui/filediff.ui b/meld/resources/ui/filediff.ui
index 8f13a1c9..c284d82b 100644
--- a/meld/resources/ui/filediff.ui
+++ b/meld/resources/ui/filediff.ui
@@ -3,6 +3,12 @@
 <interface>
   <requires lib="gtk+" version="3.20"/>
   <requires lib="meld.ui.gladesupport" version="0.0"/>
+  <object class="GtkAdjustment" id="pane_adjustment0">
+  </object>
+  <object class="GtkAdjustment" id="pane_adjustment1">
+  </object>
+  <object class="GtkAdjustment" id="pane_adjustment2">
+  </object>
   <template class="FileDiff" parent="GtkVBox">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -230,6 +236,7 @@
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
+                <property name="vadjustment">pane_adjustment0</property>
                 <signal name="size-allocate" handler="on_scrolledwindow_size_allocate" swapped="no"/>
                 <child>
                   <object class="MeldSourceView" id="textview0">
@@ -277,6 +284,7 @@
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
+                <property name="vadjustment">pane_adjustment2</property>
                 <signal name="size-allocate" handler="on_scrolledwindow_size_allocate" swapped="no"/>
                 <child>
                   <object class="MeldSourceView" id="textview2">
@@ -324,6 +332,7 @@
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
+                <property name="vadjustment">pane_adjustment1</property>
                 <signal name="size-allocate" handler="on_scrolledwindow_size_allocate" swapped="no"/>
                 <child>
                   <object class="MeldSourceView" id="textview1">
@@ -597,30 +606,70 @@
             <property name="reveal-child">True</property>
             <property name="transition-type">GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT</property>
             <child>
-              <object class="GtkBox" id="sourcemap_hbox">
+              <object class="GtkBox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="orientation">horizontal</property>
-                <property name="spacing">2</property>
-                <style>
-                  <class name="sourcemap-container"/>
-                </style>
                 <child>
-                  <object class="MeldSourceMap" id="sourcemap0">
-                    <property name="view">textview0</property>
-                    <property name="visible">True</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="MeldSourceMap" id="sourcemap1">
-                    <property name="view">textview1</property>
-                    <property name="visible">True</property>
+                  <object class="GtkBox" id="sourcemap_hbox">
+                    <property name="visible">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="orientation">horizontal</property>
+                    <property name="spacing">2</property>
+                    <style>
+                      <class name="sourcemap-container"/>
+                    </style>
+                    <child>
+                      <object class="MeldSourceMap" id="sourcemap0">
+                        <property name="view">textview0</property>
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="MeldSourceMap" id="sourcemap1">
+                        <property name="view">textview1</property>
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="MeldSourceMap" id="sourcemap2">
+                        <property name="view">textview2</property>
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
                   </object>
-                </child>
-                <child>
-                  <object class="MeldSourceMap" id="sourcemap2">
-                    <property name="view">textview2</property>
+                  <object class="GtkBox" id="chunkmap_hbox">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="orientation">horizontal</property>
+                    <property name="spacing">2</property>
+                    <style>
+                      <class name="sourcemap-container"/>
+                    </style>
+                    <child>
+                      <object class="ChunkMap" id="chunkmap0">
+                        <property name="visible">True</property>
+                        <property name="width_request">15</property>
+                        <property name="adjustment">pane_adjustment0</property>
+                        <property name="textview">textview0</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="ChunkMap" id="chunkmap1">
+                        <property name="visible">True</property>
+                        <property name="width_request">15</property>
+                        <property name="adjustment">pane_adjustment1</property>
+                        <property name="textview">textview1</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="ChunkMap" id="chunkmap2">
+                        <property name="visible">True</property>
+                        <property name="width_request">15</property>
+                        <property name="adjustment">pane_adjustment2</property>
+                        <property name="textview">textview2</property>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>


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