[gtk+] file chooser: Use batched insertion for search results
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] file chooser: Use batched insertion for search results
- Date: Thu, 18 Jun 2015 17:11:53 +0000 (UTC)
commit 4b8df8c546a769d578437cec8bbf4e5d61d12965
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 18 12:20:21 2015 -0400
file chooser: Use batched insertion for search results
This helps avoiding excess work when procesing many search
results, as typically happens with short search strings
and recursive search.
https://bugzilla.gnome.org/show_bug.cgi?id=751169
gtk/gtkfilechooserwidget.c | 47 +++++++++++++++++--------------------------
1 files changed, 19 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 259b6f5..2bba902 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -6119,40 +6119,31 @@ search_get_selected_files (GtkFileChooserWidget *impl)
return result;
}
-/* Adds one hit from the search engine to the search_model */
+/* Callback used from GtkSearchEngine when we get new hits */
static void
-search_add_hit (GtkFileChooserWidget *impl,
- gchar *uri)
+search_engine_hits_added_cb (GtkSearchEngine *engine,
+ GList *hits,
+ GtkFileChooserWidget *impl)
{
- GtkFileChooserWidgetPrivate *priv = impl->priv;
+ GList *l, *files;
GFile *file;
+ const char *uri;
- file = g_file_new_for_uri (uri);
- if (!file)
- return;
-
- priv->search_model_empty = FALSE;
-
- _gtk_file_system_model_add_and_query_file (priv->search_model,
- file,
- MODEL_ATTRIBUTES);
-
- g_object_unref (file);
-}
-
-/* Callback used from GtkSearchEngine when we get new hits */
-static void
-search_engine_hits_added_cb (GtkSearchEngine *engine,
- GList *hits,
- gpointer data)
-{
- GtkFileChooserWidget *impl;
- GList *l;
+ files = NULL;
+ for (l = hits; l; l = l->next)
+ {
+ uri = (const gchar *)l->data;
+ file = g_file_new_for_uri (uri);
+ if (!file)
+ continue;
+ files = g_list_prepend (files, file);
+ }
- impl = GTK_FILE_CHOOSER_WIDGET (data);
+ _gtk_file_system_model_add_and_query_files (impl->priv->search_model,
+ files,
+ MODEL_ATTRIBUTES);
- for (l = hits; l; l = l->next)
- search_add_hit (impl, (gchar*)l->data);
+ g_list_free_full (files, g_object_unref);
}
/* Callback used from GtkSearchEngine when the query is done running */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]