Commit 4d19f45f authored by Harald Judt's avatar Harald Judt

Restore selection on row changes too (bug #9886)

parent c6e67318
......@@ -140,6 +140,27 @@ thunar_component_set_selected_files (ThunarComponent *component,
/**
* thunar_component_restore_selection:
* @component : a #ThunarComponent instance.
*
* Make sure that the @selected_files stay selected when a @component
* updates. This may be necessary on row changes etc.
**/
void
thunar_component_restore_selection (ThunarComponent *component)
{
GList *selected_files;
_thunar_return_if_fail (THUNAR_IS_COMPONENT (component));
selected_files = thunar_g_file_list_copy (thunar_component_get_selected_files (component));
thunar_component_set_selected_files (component, selected_files);
thunar_g_file_list_free (selected_files);
}
/**
* thunar_component_get_ui_manager:
* @component : a #ThunarComponent instance.
......
......@@ -48,13 +48,15 @@ struct _ThunarComponentIface
GType thunar_component_get_type (void) G_GNUC_CONST;
GList *thunar_component_get_selected_files (ThunarComponent *component);
void thunar_component_set_selected_files (ThunarComponent *component,
GList *selected_files);
GList *thunar_component_get_selected_files (ThunarComponent *component);
void thunar_component_set_selected_files (ThunarComponent *component,
GList *selected_files);
GtkUIManager *thunar_component_get_ui_manager (ThunarComponent *component);
void thunar_component_set_ui_manager (ThunarComponent *component,
GtkUIManager *ui_manager);
void thunar_component_restore_selection (ThunarComponent *component);
GtkUIManager *thunar_component_get_ui_manager (ThunarComponent *component);
void thunar_component_set_ui_manager (ThunarComponent *component,
GtkUIManager *ui_manager);
G_END_DECLS;
......
......@@ -3670,6 +3670,10 @@ thunar_standard_view_row_changed (ThunarListModel *model,
_thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
_thunar_return_if_fail (standard_view->model == model);
/* the order of the paths might have changed, but the selection
stayed the same, so restore the selection of the proper files */
thunar_component_restore_selection (THUNAR_COMPONENT (standard_view));
if (standard_view->priv->thumbnail_request != 0)
return;
......@@ -3747,17 +3751,14 @@ static void
thunar_standard_view_sort_column_changed (GtkTreeSortable *tree_sortable,
ThunarStandardView *standard_view)
{
ThunarComponent *component;
GtkSortType sort_order;
gint sort_column;
GList *selected_files;
_thunar_return_if_fail (GTK_IS_TREE_SORTABLE (tree_sortable));
_thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
component = THUNAR_COMPONENT (standard_view);
selected_files = thunar_g_file_list_copy (thunar_component_get_selected_files (component));
/* keep the currently selected files selected after the change */
thunar_component_restore_selection (THUNAR_COMPONENT (standard_view));
/* determine the new sort column and sort order */
if (gtk_tree_sortable_get_sort_column_id (tree_sortable, &sort_column, &sort_order))
......@@ -3768,9 +3769,6 @@ thunar_standard_view_sort_column_changed (GtkTreeSortable *tree_sortable,
"last-sort-order", sort_order,
NULL);
}
thunar_component_set_selected_files (component, selected_files);
thunar_g_file_list_free (selected_files);
}
......
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