[nautilus] nautilus-list-view: Clear selection and cursor in clear()
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] nautilus-list-view: Clear selection and cursor in clear()
- Date: Tue, 19 Feb 2019 10:02:16 +0000 (UTC)
commit 335fbbc28f80bc77b79311450a16522a7ae6b337
Author: Xiang Fan <sfanxiang gmail com>
Date: Thu Feb 14 14:52:59 2019 +0800
nautilus-list-view: Clear selection and cursor in clear()
When the current cursor's row gets deleted, GTK will move the cursor to
the next row, and when setting the cursor it also selects the new
cursor's row, thereby triggering selection signals. The new cursor will
soon be deleted again and the loop repeats.
Since clear() removes all entries, those selections are useless but they
take up most of the time in clear(). For example, when a search returns
a large list, exiting from the search view would make nautilus hang.
At the time simply removing the cursor solves the problem, but to be
future-proof in case GTK does anything fancy with the current selection,
this commit also removes the selection.
Because GTK internally seeking the cursor takes time, only blocking the
selection signal like everywhere else will not remove that overhead.
src/nautilus-list-view.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index e8a00f27c..9b7b7826b 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -2692,11 +2692,42 @@ static void
nautilus_list_view_clear (NautilusFilesView *view)
{
NautilusListView *list_view;
+ GtkTreeView *tree_view;
+ GtkTreeSelection *tree_selection;
+ GtkTreePath *path;
list_view = NAUTILUS_LIST_VIEW (view);
if (list_view->details->model != NULL)
{
+ tree_view = list_view->details->tree_view;
+
+ /* When the current cursor's row gets deleted, GTK will move the cursor to
+ * the next row, and when setting the cursor it also selects the new
+ * cursor's row, thereby triggering selection signals. The new cursor will
+ * soon be deleted again and the loop repeats.
+ *
+ * Since clear() removes all entries, those selections are useless but they
+ * take up most of the time in clear(). For example, when a search returns
+ * a large list, exiting from the search view would make nautilus hang.
+ *
+ * At the time the code is written simply removing the cursor solves the
+ * problem, but to be future-proof in case GTK does anything fancy with
+ * the current selection, we also remove the selection.
+ *
+ * Because GTK internally seeking the cursor takes time, only blocking the
+ * selection signal like everywhere else will not remove that overhead.
+ */
+
+ /* Clear the current selection */
+ tree_selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_unselect_all (tree_selection);
+
+ /* Clear the current cursor */
+ path = gtk_tree_path_new ();
+ gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
+ gtk_tree_path_free (path);
+
nautilus_list_model_clear (list_view->details->model);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]