[meld] Reinstate and improve tab label tooltip usage (#682)



commit 743f434492c93fb5a45d068becf6ee35fe8f422e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Jul 10 11:02:13 2022 +1000

    Reinstate and improve tab label tooltip usage (#682)
    
    We used to support custom tooltips for tabs ages ago, but
    support was unintentionally dropped and not noticed because the
    tooltips were never actually usefully different. This makes
    custom tooltips work again, and also makes them actually provide
    useful additional information.

 meld/dirdiff.py     | 14 +++++++++++---
 meld/filediff.py    |  4 +++-
 meld/ui/notebook.py |  3 ++-
 meld/vcview.py      |  8 ++++++--
 4 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 14a43264..5e3f9463 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -1824,12 +1824,20 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
         filenames = self.model.value_paths(root)
         filenames = [f or _('No folder') for f in filenames]
         if self.custom_labels:
-            label_options = zip(self.custom_labels, filenames)
-            shortnames = [l[0] or l[1] for l in label_options]
+            shortnames = [
+                custom or filename for custom, filename in
+                zip(self.custom_labels, filenames)
+            ]
+            tooltip_names = shortnames
         else:
             shortnames = misc.shorten_names(*filenames)
+            tooltip_names = filenames
+
         self.label_text = " : ".join(shortnames)
-        self.tooltip_text = self.label_text
+        self.tooltip_text = "\n".join((
+            _("Folder comparison:"),
+            *tooltip_names,
+        ))
         self.label_changed.emit(self.label_text, self.tooltip_text)
 
     def set_labels(self, labels):
diff --git a/meld/filediff.py b/meld/filediff.py
index 92101429..5a686c6d 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1518,9 +1518,11 @@ class FileDiff(Gtk.VBox, MeldDoc):
         label = self.meta.get("tablabel", "")
         if label:
             self.label_text = label
+            tooltip_names = [label]
         else:
             self.label_text = " — ".join(shortnames)
-        self.tooltip_text = self.label_text
+            tooltip_names = filenames
+        self.tooltip_text = "\n".join((_("File comparison:"), *tooltip_names))
         self.label_changed.emit(self.label_text, self.tooltip_text)
 
     def pre_comparison_init(self):
diff --git a/meld/ui/notebook.py b/meld/ui/notebook.py
index 90e185cf..e6fad77b 100644
--- a/meld/ui/notebook.py
+++ b/meld/ui/notebook.py
@@ -154,9 +154,10 @@ class MeldNotebook(Gtk.Notebook):
         child.disconnect_by_func(self.on_label_changed)
         self.props.show_tabs = self.get_n_pages() > 1
 
-    def on_label_changed(self, page, text, tooltip):
+    def on_label_changed(self, page, text: str, tooltip: str) -> None:
         nbl = self.get_tab_label(page)
         nbl.props.label_text = text
+        nbl.set_tooltip_text(tooltip)
 
         # Only update the window title if the current page is active
         if self.get_current_page() == self.page_num(page):
diff --git a/meld/vcview.py b/meld/vcview.py
index ef520a45..f98b89bc 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -408,8 +408,12 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
 
     def recompute_label(self):
         self.label_text = os.path.basename(self.location)
-        # TRANSLATORS: This is the location of the directory being viewed
-        self.tooltip_text = _("Location: {path}").format(path=self.location)
+        self.tooltip_text = "\n".join((
+            # TRANSLATORS: This is the name of the version control
+            # system being used, e.g., "Git" or "Subversion"
+            _("{vc} comparison:").format(vc=self.vc.NAME),
+            self.location,
+        ))
         self.label_changed.emit(self.label_text, self.tooltip_text)
 
     def _search_recursively_iter(self, start_path, replace=False):


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