[Xfce4-commits] <thunar:master> Auto-select subdirectories when walking through the history (bug #5538).

Jannis Pohlmann noreply at xfce.org
Mon Oct 4 17:32:05 CEST 2010


Updating branch refs/heads/master
         to 4ffb5b3c2ac77c8ff44f6aeee191b37cf7cecfbe (commit)
       from 263718553b0670d102afbd5f88a482d678806488 (commit)

commit 4ffb5b3c2ac77c8ff44f6aeee191b37cf7cecfbe
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Oct 4 17:28:01 2010 +0200

    Auto-select subdirectories when walking through the history (bug #5538).
    
    When entering a new directory, Thunar now checks if the next or previous
    directory in the history is an immediate child of the new directory. If
    one of these files is a child, it selects it automatically.
    
    This makes keyboard navigation much easier. I'm sure the behaviour can
    be confusing in some situations as well, but I hope it is an
    improvement.
    
    This partly fixes bug #5538 as well.

 thunar/thunar-window.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 6b1704e..c46ac70 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -2746,6 +2746,8 @@ thunar_window_set_current_directory (ThunarWindow *window,
                                      ThunarFile   *current_directory)
 {
   ThunarFile *file;
+  ThunarFile *selected_file;
+  GList       selected_files;
 
   _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
   _thunar_return_if_fail (current_directory == NULL || THUNAR_IS_FILE (current_directory));
@@ -2809,6 +2811,39 @@ thunar_window_set_current_directory (ThunarWindow *window,
       file = g_hash_table_lookup (window->scroll_to_files, window->current_directory);
       if (G_LIKELY (file != NULL))
         thunar_window_scroll_to_file (window, file, FALSE, TRUE, 0.0f, 0.0f);
+
+      /* reset the selected files list */
+      selected_files.data = NULL;
+      selected_files.prev = NULL;
+      selected_files.next = NULL;
+      
+      /* determine the next file in the history */
+      selected_file = thunar_history_peek_forward (window->history);
+      if (selected_file != NULL)
+        {
+          /* mark the file from history for selection if it is inside the new
+           * directory */
+          if (thunar_file_is_parent (window->current_directory, selected_file))
+            selected_files.data = selected_file;
+        }
+
+      /* do the same with the previous file in the history */
+      if (selected_files.data == NULL)
+        {
+          selected_file = thunar_history_peek_back (window->history);
+          if (selected_file != NULL)
+            {
+              /* mark the file from history for selection if it is inside the 
+               * new directory */
+              if (thunar_file_is_parent (window->current_directory, selected_file))
+                selected_files.data = selected_file;
+            }
+        }
+
+      /* select the previous or next file from the history if it is inside the
+       * new current directory */
+      if (selected_files.data != NULL)
+        thunar_component_set_selected_files (THUNAR_COMPONENT (window->view), &selected_files);
     }
 }
 



More information about the Xfce4-commits mailing list