[baobab/reroot-view: 27/35] Bring sorting back
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/reroot-view: 27/35] Bring sorting back
- Date: Fri, 26 Jun 2020 09:00:23 +0000 (UTC)
commit 02551534866ece35398876b129a2f1ee184fd4ab
Author: Stefano Facchini <stefano facchini gmail com>
Date: Sat Jun 20 23:14:57 2020 +0200
Bring sorting back
data/ui/baobab-main-window.ui | 1 -
src/baobab-window.vala | 33 +++++++++++++++++++++++++--------
2 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/data/ui/baobab-main-window.ui b/data/ui/baobab-main-window.ui
index c26746c..d679ed4 100644
--- a/data/ui/baobab-main-window.ui
+++ b/data/ui/baobab-main-window.ui
@@ -264,7 +264,6 @@
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">False</property>
<property name="activate_on_single_click">True</property>
<property name="hover_selection">True</property>
<child internal-child="selection">
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 41ab8a3..d46e8fe 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -391,17 +391,34 @@ namespace Baobab {
}
bool get_selected_iter (out Gtk.TreeIter iter) {
- Gtk.TreeIter filter_iter;
+ Gtk.TreeIter wrapper_iter;
var selection = treeview.get_selection ();
- var result = selection.get_selected (null, out filter_iter);
+ var result = selection.get_selected (null, out wrapper_iter);
- var filter = (Gtk.TreeModelFilter) treeview.model;
- filter.convert_iter_to_child_iter (out iter, filter_iter);
+ convert_iter_to_child_iter (out iter, wrapper_iter);
return result;
}
+ void convert_iter_to_child_iter (out Gtk.TreeIter child_iter, Gtk.TreeIter iter) {
+ Gtk.TreeIter filter_iter;
+
+ var sort = (Gtk.TreeModelSort) treeview.model;
+ sort.convert_iter_to_child_iter (out filter_iter, iter);
+
+ var filter = (Gtk.TreeModelFilter) sort.model;
+ filter.convert_iter_to_child_iter (out child_iter, filter_iter);
+ }
+
+ Gtk.TreePath convert_path_to_child_path (Gtk.TreePath path) {
+ var sort = (Gtk.TreeModelSort) treeview.model;
+ var filter_path = sort.convert_path_to_child_path (path);
+
+ var filter = (Gtk.TreeModelFilter) sort.model;
+ return filter.convert_path_to_child_path (filter_path);
+ }
+
void setup_treeview () {
treeview.button_press_event.connect ((event) => {
if (event.triggers_context_menu ()) {
@@ -440,9 +457,8 @@ namespace Baobab {
}
});
- treeview.row_activated.connect ((filter_path, column) => {
- var filter = (Gtk.TreeModelFilter) treeview.model;
- var path = filter.convert_path_to_child_path (filter_path);
+ treeview.row_activated.connect ((wrapper_path, column) => {
+ var path = convert_path_to_child_path (wrapper_path);
reroot_treeview (path, true);
});
}
@@ -459,7 +475,8 @@ namespace Baobab {
folder_display.path = path;
pathbar.path = path;
- treeview.model = new Gtk.TreeModelFilter (active_location.scanner, path);
+ var filter = new Gtk.TreeModelFilter (active_location.scanner, path);
+ treeview.model = new Gtk.TreeModelSort.with_model (filter);
if (select_first) {
treeview.set_cursor (new Gtk.TreePath.first (), null, false);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]