diff options
author | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-17 19:30:16 +0200 |
---|---|---|
committer | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-30 16:01:22 +0200 |
commit | c7c204fc486619d337ca54c90419413841a76c28 (patch) | |
tree | c9fa21dde348f6f321295579c6c5cbf756a3bdc1 /src | |
parent | b5ba7bf8f6c388080cc0ed9bcf4622d1f0721e28 (diff) | |
download | baobab-c7c204fc486619d337ca54c90419413841a76c28.tar.gz |
Do not reroot at empty rows
Diffstat (limited to 'src')
-rw-r--r-- | src/baobab-chart.vala | 4 | ||||
-rw-r--r-- | src/baobab-window.vala | 18 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/baobab-chart.vala b/src/baobab-chart.vala index ea9ac3e..f726412 100644 --- a/src/baobab-chart.vala +++ b/src/baobab-chart.vala @@ -171,9 +171,7 @@ namespace Baobab { } } - public virtual signal void item_activated (Gtk.TreeIter iter) { - root = model.get_path (iter); - } + public signal void item_activated (Gtk.TreeIter iter); protected virtual void post_draw (Cairo.Context cr) { } diff --git a/src/baobab-window.vala b/src/baobab-window.vala index c75f7d4..a2a3f60 100644 --- a/src/baobab-window.vala +++ b/src/baobab-window.vala @@ -493,19 +493,27 @@ 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); - reroot_treeview (path); - treeview.set_cursor (new Gtk.TreePath.first (), null, false); + reroot_treeview (path, true); }); } - void reroot_treeview (Gtk.TreePath path) { + void reroot_treeview (Gtk.TreePath path, bool select_first = false) { + Gtk.TreeIter iter; + active_location.scanner.get_iter (out iter, path); + if (!active_location.scanner.iter_has_child (iter)) { + return; + } + rings_chart.root = path; treemap_chart.root = path; folder_display.path = path; pathbar.path = path; - var filter = new Gtk.TreeModelFilter (active_location.scanner, path); - treeview.model = filter; + treeview.model = new Gtk.TreeModelFilter (active_location.scanner, path); + + if (select_first) { + treeview.set_cursor (new Gtk.TreePath.first (), null, false); + } } void message (string primary_msg, string secondary_msg, Gtk.MessageType type) { |