[meld] Make conflict navigation buttons only visible where appropriate



commit 6d90881cf0a93bccf1ebdae4f604361c1697bd79
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Sep 24 07:14:18 2021 +1000

    Make conflict navigation buttons only visible where appropriate
    
    At the moment, we have no support for conflict navigation in folder or
    VC comparisons, so this new logic simply only shows the conflict
    navigation buttons in three-pane file comparisons.

 meld/filediff.py               | 3 +++
 meld/melddoc.py                | 9 +++++++++
 meld/meldwindow.py             | 2 ++
 meld/resources/ui/appwindow.ui | 4 ++--
 4 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index b2d72a0a..922f287f 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -532,6 +532,9 @@ class FileDiff(Gtk.VBox, MeldDoc):
     def get_filter_visibility(self) -> Tuple[bool, bool, bool]:
         return True, False, False
 
+    def get_conflict_visibility(self) -> bool:
+        return self.num_panes == 3
+
     def on_text_filters_changed(self, app):
         relevant_change = self.create_text_filters()
         if relevant_change:
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 47dd647b..15f01860 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -213,10 +213,19 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
             text, folder, vc = self.get_filter_visibility()
         else:
             text, folder, vc = False, False, False
+
+        if hasattr(self, "get_conflict_visibility"):
+            show_conflict_actions = self.get_conflict_visibility()
+        else:
+            show_conflict_actions = False
+
         window.text_filter_button.set_visible(text)
         window.folder_filter_button.set_visible(folder)
         window.vc_filter_button.set_visible(vc)
 
+        window.next_conflict_button.set_visible(show_conflict_actions)
+        window.previous_conflict_button.set_visible(show_conflict_actions)
+
         if hasattr(self, "focus_pane") and self.focus_pane:
             self.scheduler.add_task(self.focus_pane.grab_focus)
 
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 0235a1e6..69b2e618 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -52,7 +52,9 @@ class MeldWindow(Gtk.ApplicationWindow):
     folder_filter_button = Gtk.Template.Child()
     text_filter_button = Gtk.Template.Child()
     gear_menu_button = Gtk.Template.Child()
+    next_conflict_button = Gtk.Template.Child()
     notebook = Gtk.Template.Child()
+    previous_conflict_button = Gtk.Template.Child()
     spinner = Gtk.Template.Child()
     vc_filter_button = Gtk.Template.Child()
     view_toolbar = Gtk.Template.Child()
diff --git a/meld/resources/ui/appwindow.ui b/meld/resources/ui/appwindow.ui
index f0122083..fed1c086 100644
--- a/meld/resources/ui/appwindow.ui
+++ b/meld/resources/ui/appwindow.ui
@@ -117,7 +117,7 @@
               <class name="linked"/>
             </style>
             <child>
-              <object class="GtkButton">
+              <object class="GtkButton" id="previous_conflict_button">
                 <property name="visible">True</property>
                 <property name="action-name">view.file-previous-conflict</property>
                 <property name="tooltip-text" translatable="yes">Go to the previous conflict</property>
@@ -137,7 +137,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton">
+              <object class="GtkButton" id="next_conflict_button">
                 <property name="visible">True</property>
                 <property name="action-name">view.file-next-conflict</property>
                 <property name="tooltip-text" translatable="yes">Go to the next conflict</property>


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