[Xfce4-commits] [xfce/thunar] 01/03: Restore selection on row changes too (bug #9886)
noreply at xfce.org
noreply at xfce.org
Thu Apr 2 19:43:01 CEST 2015
This is an automated email from the git hooks/post-receive script.
hjudt pushed a commit to branch master
in repository xfce/thunar.
commit 4d19f45feb198b3a580ef2f777e2c50be2e3a0d3
Author: Harald Judt <h.judt at gmx.at>
Date: Tue Mar 31 22:05:22 2015 +0200
Restore selection on row changes too (bug #9886)
---
thunar/thunar-component.c | 21 +++++++++++++++++++++
thunar/thunar-component.h | 14 ++++++++------
thunar/thunar-standard-view.c | 14 ++++++--------
3 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/thunar/thunar-component.c b/thunar/thunar-component.c
index a9af2b2..0c578de 100644
--- a/thunar/thunar-component.c
+++ b/thunar/thunar-component.c
@@ -141,6 +141,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.
*
diff --git a/thunar/thunar-component.h b/thunar/thunar-component.h
index e33e57b..17fe705 100644
--- a/thunar/thunar-component.h
+++ b/thunar/thunar-component.h
@@ -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;
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index b0bc091..f980113 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -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);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list