[meld: 1/4] Implement collapse and expand recursively
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 1/4] Implement collapse and expand recursively
- Date: Sat, 30 Jun 2018 21:32:30 +0000 (UTC)
commit bdaa8da0cd57da15212e433e156e43ec739629c7
Author: Jesus Arroyo <chuy max gmail com>
Date: Thu Jun 21 18:26:51 2018 -0400
Implement collapse and expand recursively
data/ui/dirdiff-ui.xml | 3 +++
data/ui/dirdiff.ui | 18 ++++++++++++++++++
meld/dirdiff.py | 30 ++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
---
diff --git a/data/ui/dirdiff-ui.xml b/data/ui/dirdiff-ui.xml
index 83af0a4f..d7299842 100644
--- a/data/ui/dirdiff-ui.xml
+++ b/data/ui/dirdiff-ui.xml
@@ -45,6 +45,9 @@
<popup name="Popup">
<menuitem action="DirCompare" />
<separator/>
+ <menuitem action="DirCollapseRecursively" />
+ <menuitem action="DirExpandRecursively" />
+ <separator/>
<menuitem action="DirCopyLeft" />
<menuitem action="DirCopyRight" />
<menuitem action="DirDelete" />
diff --git a/data/ui/dirdiff.ui b/data/ui/dirdiff.ui
index e60b335f..eb34edd9 100644
--- a/data/ui/dirdiff.ui
+++ b/data/ui/dirdiff.ui
@@ -12,6 +12,24 @@
<signal name="activate" handler="on_button_diff_clicked" swapped="no"/>
</object>
</child>
+ <child>
+ <object class="GtkAction" id="DirCollapseRecursively">
+ <property name="label" translatable="yes">Collapse Recursively</property>
+ <property name="tooltip" translatable="yes">Collapse Recursively</property>
+ <property name="stock_id">gtk-dialog-info</property>
+ <property name="is_important">True</property>
+ <signal name="activate" handler="on_collapse_recursive_clicked" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="DirExpandRecursively">
+ <property name="label" translatable="yes">Expand Recursively</property>
+ <property name="tooltip" translatable="yes">Expand Recursively</property>
+ <property name="stock_id">gtk-dialog-info</property>
+ <property name="is_important">True</property>
+ <signal name="activate" handler="on_expand_recursive_clicked" swapped="no"/>
+ </object>
+ </child>
<child>
<object class="GtkAction" id="DirCopyLeft">
<property name="label" translatable="yes">Copy to _Left</property>
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 286171c1..64ab20cc 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -1027,7 +1027,16 @@ class DirDiff(MeldDoc, Component):
busy = self._scan_in_progress > 0
+ is_single_foldable_row = False
+ if (selection.count_selected_rows() == 1):
+ path = selection.get_selected_rows()[1][0]
+ iter = self.model.get_iter(path)
+ os_path = self.model.value_path(iter, pane)
+ is_single_foldable_row = self.model.is_folder(iter, pane, os_path)
+
get_action("DirCompare").set_sensitive(True)
+ get_action("DirCollapseRecursively").set_sensitive(is_single_foldable_row)
+ get_action("DirExpandRecursively").set_sensitive(is_single_foldable_row)
get_action("Hide").set_sensitive(True)
get_action("DirDelete").set_sensitive(
is_valid and not busy)
@@ -1184,6 +1193,27 @@ class DirDiff(MeldDoc, Component):
for row in selected:
self.run_diff_from_iter(self.model.get_iter(row))
+ def on_collapse_recursive_clicked(self, action):
+ pane = self._get_focused_pane()
+ root_path = self._get_selected_paths(pane)[0]
+ filter_model = Gtk.TreeModelFilter(child_model=self.model, virtual_root=root_path)
+ paths_to_collapse = []
+ filter_model.foreach(self.append_paths_to_collapse, paths_to_collapse)
+ paths_to_collapse.insert(0, root_path)
+
+ for path in reversed(paths_to_collapse):
+ self.treeview[pane].collapse_row(path)
+
+ def append_paths_to_collapse(self, filter_model, filter_path, filter_iter, paths_to_collapse):
+ path = filter_model.convert_path_to_child_path(filter_path)
+ paths_to_collapse.append(path)
+
+ def on_expand_recursive_clicked(self, action):
+ pane = self._get_focused_pane()
+ paths = self._get_selected_paths(pane)
+ for path in paths:
+ self.treeview[pane].expand_row(path, True)
+
def on_button_copy_left_clicked(self, button):
self.copy_selected(-1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]