Commit 13a09f1e authored by Theo Linkspfeifer's avatar Theo Linkspfeifer Committed by Alexander Schwinn

Use tre-view toplevel path of the cursor, if available, in order to

prevent jumping (Bug #16024)
parent 6850f6fe
......@@ -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 ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment