[Xfce4-commits] [xfce/thunar] 01/01: Use tre-view toplevel path of the cursor, if available, in order to prevent jumping (Bug #16024)
noreply at xfce.org
noreply at xfce.org
Mon Mar 23 19:03:23 CET 2020
This is an automated email from the git hooks/post-receive script.
a l e x p u s h e d a c o m m i t t o b r a n c h x f c e - 4 . 1 4
in repository xfce/thunar.
commit 13a09f1ea3de33fc24ca17aecb39fd5b43caa8dd
Author: Theo Linkspfeifer <lastonestanding at tutanota.com>
Date: Mon Mar 23 18:18:11 2020 +0100
Use tre-view toplevel path of the cursor, if available, in order to
prevent jumping (Bug #16024)
---
thunar/thunar-tree-view.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c
index d5d5294..d1f6b32 100644
--- a/thunar/thunar-tree-view.c
+++ b/thunar/thunar-tree-view.c
@@ -2866,8 +2866,8 @@ thunar_tree_view_set_show_hidden (ThunarTreeView *view,
*
* Searches for the best-matching toplevel path in the
* following order:
- * 1) any mounted device or network resource
- * 2) the user's desktop directory
+ * 1) the currently active one
+ * 2) any mounted device or network resource
* 3) the user's home directory
* 4) the root filesystem
*
@@ -2893,6 +2893,35 @@ thunar_tree_view_get_preferred_toplevel_path (ThunarTreeView *view,
if (!gtk_tree_model_get_iter_first (model, &iter))
return NULL;
+ /* get active toplevel path and check if we can use it */
+ gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &path, NULL);
+ if (path != NULL)
+ {
+ if (gtk_tree_path_get_depth (path) != 1)
+ while (gtk_tree_path_get_depth (path) > 1)
+ gtk_tree_path_up (path);
+
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (view->model), &iter, path))
+ {
+ /* lookup file for the toplevel item */
+ gtk_tree_model_get (GTK_TREE_MODEL (view->model), &iter, THUNAR_TREE_MODEL_COLUMN_FILE, &toplevel_file, -1);
+ if (toplevel_file)
+ {
+ /* check if the toplevel file is an ancestor */
+ if (thunar_file_is_ancestor (file, toplevel_file))
+ {
+ g_object_unref (toplevel_file);
+ return path;
+ }
+
+ g_object_unref (toplevel_file);
+ }
+ }
+
+ gtk_tree_path_free (path);
+ path = NULL;
+ }
+
/* get GFiles for special toplevel items */
desktop = thunar_g_file_new_for_desktop ();
home = thunar_g_file_new_for_home ();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list