[meld] Make filter headerbar buttons only visible in their related views
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Make filter headerbar buttons only visible in their related views
- Date: Thu, 23 Sep 2021 22:49:33 +0000 (UTC)
commit 4ac4143b4bad22a5699374a60b7aa7bf9d91f241
Author: Kai Willadsen <kai willadsen gmail com>
Date: Tue Aug 24 07:18:18 2021 +1000
Make filter headerbar buttons only visible in their related views
This is a very debatable change. I'm weighing up a desire for the
header bar to not be too wide (because it gives us a minimum size that
we can't easily work around) with the desire to have the UI be stable.
In this case, I've gone with having the available buttons change per
view, on the basis that there are three text buttons here and they take
up really quite a lot of horizontal allocation.
Ideally, I think this would be responsive and we'd try to always show
all three buttons, collapsing down to just the relevant one(s) if
necessary... but that's really quite a lot more work.
meld/dirdiff.py | 5 +++++
meld/filediff.py | 5 ++++-
meld/melddoc.py | 8 ++++++++
meld/vcview.py | 4 ++++
4 files changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 0d5e1c59..f4a6f805 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -25,6 +25,7 @@ import sys
from collections import namedtuple
from decimal import Decimal
from mmap import ACCESS_COPY, mmap
+from typing import Tuple
from gi.repository import Gdk, Gio, GLib, GObject, Gtk
@@ -622,6 +623,10 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
last_column = current_column
treeview.set_headers_visible(extra_cols)
+ def get_filter_visibility(self) -> Tuple[bool, bool, bool]:
+ # TODO: Make text filters available in folder comparison
+ return False, True, False
+
def on_file_filters_changed(self, app):
relevant_change = self.create_name_filters()
if relevant_change:
diff --git a/meld/filediff.py b/meld/filediff.py
index cfbb8f42..b2d72a0a 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -18,7 +18,7 @@ import copy
import functools
import logging
import math
-from typing import Optional, Type
+from typing import Optional, Tuple, Type
from gi.repository import Gdk, Gio, GLib, GObject, Gtk, GtkSource
@@ -529,6 +529,9 @@ class FileDiff(Gtk.VBox, MeldDoc):
for sourcemap in self.sourcemap:
sourcemap.props.compact_view = style == 'compact-sourcemap'
+ def get_filter_visibility(self) -> Tuple[bool, bool, bool]:
+ return True, False, False
+
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 8a3d0b20..47dd647b 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -209,6 +209,14 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
window.insert_action_group(
'view', getattr(self, 'view_action_group', None))
+ if hasattr(self, "get_filter_visibility"):
+ text, folder, vc = self.get_filter_visibility()
+ else:
+ text, folder, vc = False, False, False
+ window.text_filter_button.set_visible(text)
+ window.folder_filter_button.set_visible(folder)
+ window.vc_filter_button.set_visible(vc)
+
if hasattr(self, "focus_pane") and self.focus_pane:
self.scheduler.add_task(self.focus_pane.grab_focus)
diff --git a/meld/vcview.py b/meld/vcview.py
index 4a507727..dc180ac0 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -22,6 +22,7 @@ import shutil
import stat
import sys
import tempfile
+from typing import Tuple
from gi.repository import Gdk, Gio, GLib, GObject, Gtk, Pango
@@ -578,6 +579,9 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
kwargs,
)
+ def get_filter_visibility(self) -> Tuple[bool, bool, bool]:
+ return False, False, True
+
def action_filter_state_change(self, action, value):
action.set_state(value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]