diff --git a/bin/meld b/bin/meld index 4756305..3d65ad2 100755 --- a/bin/meld +++ b/bin/meld @@ -191,6 +191,9 @@ def setup_resources(): icon_dir = os.path.join(meld.conf.DATADIR, "icons") Gtk.IconTheme.get_default().append_search_path(icon_dir) + GObject.signal_new('collapse-all', Gtk.TreeView, GObject.SIGNAL_ACTION, + GObject.TYPE_BOOLEAN, ()) + css_file = os.path.join(meld.conf.DATADIR, "meld.css") provider = Gtk.CssProvider() try: diff --git a/data/meld.css b/data/meld.css index 8aa1251..afbe342 100644 --- a/data/meld.css +++ b/data/meld.css @@ -27,3 +27,11 @@ LinkMap { background-image: none; background-color: rgb(237, 54, 54); } + + binding-set tree-view-collapse-all { + bind "underscore" { "collapse-all" () }; +} + +GtkTreeView { + gtk-key-bindings: tree-view-collapse-all; +} diff --git a/data/ui/dirdiff.ui b/data/ui/dirdiff.ui index 5624705..4eea18b 100644 --- a/data/ui/dirdiff.ui +++ b/data/ui/dirdiff.ui @@ -367,6 +367,7 @@ + @@ -423,6 +424,7 @@ + @@ -479,6 +481,7 @@ + diff --git a/meld/dirdiff.py b/meld/dirdiff.py index e5db9ef..84dc642 100644 --- a/meld/dirdiff.py +++ b/meld/dirdiff.py @@ -1174,6 +1174,10 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component): self._do_to_others(view, self.treeview, "collapse_row", (path,)) self._update_diffmaps() + def on_treeview_collapse_all(self, view, *rest): + for path in sorted(self.row_expansions, key=len, reverse=True): + view.collapse_row(Gtk.TreePath.new_from_string(path)) + def on_popup_deactivate_event(self, popup): for (treeview, inid, outid) in zip(self.treeview, self.focus_in_events, self.focus_out_events): treeview.handler_unblock(inid)