Was what you had in mind something along these lines? I had poked at
this a while ago, but never really finished...could probably flesh
this out if there is interest.

On Sat, Oct 3, 2015 at 3:35 PM, Kai Willadsen <[email protected]> wrote:
> On 29 August 2015 at 15:28, Karl Schmidt <[email protected]> wrote:
>>
>> On 08/22/2015 04:03 PM, Kai Willadsen wrote:
>>>
>>> On 23 August 2015 at 03:00, Karl Schmidt <[email protected]> wrote:
>>>>
>>>> Karl Schmidt a écrit :
>>>>>
>>>>>
>>>>> I think there was a way to collapse all folders when doing a directory
>>>>> compare before?  Can't find it now? Was it removed?  Could it be added?
>>>>>
>>>> Yes, and it was removed.  Hopefully it will be re-added soon.
>>>> In the meantime, I'm (almost always) using the latest 1.x version.
>>>> You can download older versions (which I did.)
>>>
>>>
>>> I don't think this is accurate. To the best of my recollection, I
>>> don't think we ever provided a way to collapse all folders. You
>>> *could* have collapsed and re-expanded the parent folder, because we
>>> incorrectly failed to remember the expansion state... which has been
>>> fixed.
>>>
>>> Can I ask why you want to do this?
>>
>>
>> Apparently, I was enjoying the effects of that bug<grin>..  In migrating
>> systems we often look at /etc and finding things in the order needed is much
>> faster if the directories are all closed - otherwise it ends up being a very
>> long list to scroll though and a pain to close the folders not needed at
>> that time. (I'm pretty sure others use meld for the same job.) It sure would
>> be cool to have a keystroke that would collapse-all.
>
>
> Sorry, I just completely lost this email.
>
> So I'm tempted to say we should just add a keybinding signal for expand-all
> and collapse-all, but not actually add a binding. This would mean you can
> customise it as desired, but also means that we don't need to worry about
> e.g., adding menu items, actions, making keybinding decisions, etc. I'm not
> sure when I'll get around to this though; could you please file a bug?
>
> cheers,
> Kai
>
> _______________________________________________
> meld-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/meld-list
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 @@
                         <signal name="row-activated" handler="on_treeview_row_activated" swapped="no"/>
                         <signal name="row-collapsed" handler="on_treeview_row_collapsed" swapped="no"/>
                         <signal name="popup-menu" handler="on_treeview_popup_menu" swapped="no"/>
+                        <signal name="collapse-all" handler="on_treeview_collapse_all" swapped="no"/>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" id="treeview-selection1"/>
                         </child>
@@ -423,6 +424,7 @@
                         <signal name="row-activated" handler="on_treeview_row_activated" swapped="no"/>
                         <signal name="row-collapsed" handler="on_treeview_row_collapsed" swapped="no"/>
                         <signal name="popup-menu" handler="on_treeview_popup_menu" swapped="no"/>
+                        <signal name="collapse-all" handler="on_treeview_collapse_all" swapped="no"/>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" id="treeview-selection2"/>
                         </child>
@@ -479,6 +481,7 @@
                         <signal name="row-activated" handler="on_treeview_row_activated" swapped="no"/>
                         <signal name="row-collapsed" handler="on_treeview_row_collapsed" swapped="no"/>
                         <signal name="popup-menu" handler="on_treeview_popup_menu" swapped="no"/>
+                        <signal name="collapse-all" handler="on_treeview_collapse_all" swapped="no"/>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" id="treeview-selection3"/>
                         </child>
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)
_______________________________________________
meld-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/meld-list

Reply via email to