diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index 2478d7e..48cae5f 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -192,6 +192,8 @@ static void thunar_standard_view_action_restore (Gtk static GClosure *thunar_standard_view_new_files_closure (ThunarStandardView *standard_view); static void thunar_standard_view_new_files (ThunarStandardView *standard_view, GList *path_list); +static void thunar_standard_view_select_new_files (ThunarStandardView *standard_view, + GList *path_list); static gboolean thunar_standard_view_button_release_event (GtkWidget *view, GdkEventButton *event, ThunarStandardView *standard_view); @@ -1283,20 +1285,6 @@ thunar_standard_view_set_loading (ThunarStandardView *standard_view, g_object_unref (G_OBJECT (file)); } - /* check if we have a path list from new_files pending */ - if (G_UNLIKELY (!loading && standard_view->priv->new_files_path_list != NULL)) - { - /* remember and reset the new_files_path_list */ - new_files_path_list = standard_view->priv->new_files_path_list; - standard_view->priv->new_files_path_list = NULL; - - /* and try again */ - thunar_standard_view_new_files (standard_view, new_files_path_list); - - /* cleanup */ - thunar_g_file_list_free (new_files_path_list); - } - /* check if we're done loading */ if (!loading) { @@ -1304,8 +1292,20 @@ thunar_standard_view_set_loading (ThunarStandardView *standard_view, selected_files = standard_view->priv->selected_files; standard_view->priv->selected_files = NULL; - /* and try setting the selected files again */ - thunar_component_set_selected_files (THUNAR_COMPONENT (standard_view), selected_files); + if (standard_view->priv->new_files_path_list != NULL) + { + /* select the new files */ + thunar_standard_view_select_new_files (standard_view, standard_view->priv->new_files_path_list); + + /* cleanup new files */ + thunar_g_file_list_free (standard_view->priv->new_files_path_list); + standard_view->priv->new_files_path_list = NULL; + } + else + { + /* and try setting the selected files again */ + thunar_component_set_selected_files (THUNAR_COMPONENT (standard_view), selected_files); + } /* cleanup */ thunar_file_list_free (selected_files); @@ -2373,10 +2373,6 @@ static void thunar_standard_view_new_files (ThunarStandardView *standard_view, GList *path_list) { - ThunarFile*file; - GList *file_list = NULL; - GList *lp; - _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view)); /* release the previous "new-files" paths (if any) */ @@ -2385,38 +2381,43 @@ thunar_standard_view_new_files (ThunarStandardView *standard_view, thunar_g_file_list_free (standard_view->priv->new_files_path_list); standard_view->priv->new_files_path_list = NULL; } + + /* manually reload the folder to avoid a delay */ + thunar_standard_view_reload (THUNAR_VIEW (standard_view)); + + /* schedule the "new-files" paths for selecting them when reload is done */ + standard_view->priv->new_files_path_list = thunar_g_file_list_copy (path_list); +} - /* check if the folder is currently being loaded */ - if (G_UNLIKELY (standard_view->loading)) + + +static void +thunar_standard_view_select_new_files (ThunarStandardView *standard_view, + GList *path_list) +{ + ThunarFile*file; + GList *file_list = NULL; + GList *lp; + + /* determine the files for the paths */ + for (lp = path_list; lp != NULL; lp = lp->next) { - /* schedule the "new-files" paths for later processing */ - standard_view->priv->new_files_path_list = thunar_g_file_list_copy (path_list); + file = thunar_file_cache_lookup (lp->data); + if (G_LIKELY (file != NULL)) + file_list = g_list_prepend (file_list, file); } - else if (G_LIKELY (path_list != NULL)) - { - /* determine the files for the paths */ - for (lp = path_list; lp != NULL; lp = lp->next) - { - file = thunar_file_cache_lookup (lp->data); - if (G_LIKELY (file != NULL)) - file_list = g_list_prepend (file_list, file); - } - /* check if we have any new files here */ - if (G_LIKELY (file_list != NULL)) - { - /* select the files */ - thunar_component_set_selected_files (THUNAR_COMPONENT (standard_view), file_list); - - /* release the file list */ - g_list_free (file_list); + /* check if we have any new files here */ + if (G_LIKELY (file_list != NULL)) + { + /* select the files */ + thunar_component_set_selected_files (THUNAR_COMPONENT (standard_view), file_list); - /* grab the focus to the view widget */ - gtk_widget_grab_focus (GTK_BIN (standard_view)->child); - } + /* release the file list */ + g_list_free (file_list); - /* manually reload the folder to avoid a delay */ - thunar_standard_view_reload (THUNAR_VIEW (standard_view)); + /* grab the focus to the view widget */ + gtk_widget_grab_focus (GTK_BIN (standard_view)->child); } }