[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 18:29:57 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       m   a   s   t   e   r   
   in repository xfce/thunar.

commit b0332a19af79da580afebeef537dcb417bf773a8
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 | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c
index e3fc894..0dc4912 100644
--- a/thunar/thunar-tree-view.c
+++ b/thunar/thunar-tree-view.c
@@ -2866,9 +2866,10 @@ 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 home directory
- *   3) the root filesystem
+ *   1) the currently active one
+ *   2) any mounted device or network resource
+ *   3) the user's home directory
+ *   4) the root filesystem
  *
  * Returns the #GtkTreePath for the matching toplevel item,
  * or %NULL if not found. The path should be freed with gtk_tree_path_free().
@@ -2891,6 +2892,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 */
   home = thunar_g_file_new_for_home ();
   root = thunar_g_file_new_for_root ();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list