forked from AuroraMiddleware/gtk
gtksearchengine: Add "got_results" argument to ::finished
The filechooser tries to figure out whether it got results by poking the model, but all files might go through the async GFileInfo querying state. Make all search engines (and the composite one) just notify about this fact, so the file chooser can behave appropriately without waiting for the async operations to finish.
This commit is contained in:
parent
e0f4e44044
commit
b890e87818
@ -6535,6 +6535,7 @@ search_engine_hits_added_cb (GtkSearchEngine *engine,
|
||||
/* Callback used from GtkSearchEngine when the query is done running */
|
||||
static void
|
||||
search_engine_finished_cb (GtkSearchEngine *engine,
|
||||
gboolean got_results,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (data);
|
||||
@ -6548,7 +6549,7 @@ search_engine_finished_cb (GtkSearchEngine *engine,
|
||||
impl->show_progress_timeout = 0;
|
||||
}
|
||||
|
||||
if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (impl->search_model), NULL) == 0)
|
||||
if (!got_results)
|
||||
{
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (impl->browse_files_stack), "empty");
|
||||
gtk_widget_grab_focus (impl->search_entry);
|
||||
|
@ -35,6 +35,7 @@
|
||||
struct _GtkSearchEnginePrivate {
|
||||
GtkSearchEngine *native;
|
||||
gboolean native_running;
|
||||
gboolean got_results;
|
||||
gchar *native_error;
|
||||
|
||||
GtkSearchEngine *model;
|
||||
@ -161,7 +162,7 @@ _gtk_search_engine_class_init (GtkSearchEngineClass *class)
|
||||
G_STRUCT_OFFSET (GtkSearchEngineClass, finished),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
||||
|
||||
signals[ERROR] =
|
||||
g_signal_new (I_("error"),
|
||||
@ -230,13 +231,16 @@ update_status (GtkSearchEngine *engine)
|
||||
else if (engine->priv->model_error)
|
||||
_gtk_search_engine_error (engine, engine->priv->model_error);
|
||||
else
|
||||
_gtk_search_engine_finished (engine);
|
||||
_gtk_search_engine_finished (engine, engine->priv->got_results);
|
||||
|
||||
engine->priv->got_results = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
finished (GtkSearchEngine *engine,
|
||||
gboolean got_results,
|
||||
gpointer data)
|
||||
{
|
||||
GtkSearchEngine *composite = GTK_SEARCH_ENGINE (data);
|
||||
@ -246,6 +250,7 @@ finished (GtkSearchEngine *engine,
|
||||
else if (engine == composite->priv->model)
|
||||
composite->priv->model_running = FALSE;
|
||||
|
||||
composite->priv->got_results |= got_results;
|
||||
update_status (composite);
|
||||
}
|
||||
|
||||
@ -391,11 +396,12 @@ _gtk_search_engine_hits_added (GtkSearchEngine *engine,
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_search_engine_finished (GtkSearchEngine *engine)
|
||||
_gtk_search_engine_finished (GtkSearchEngine *engine,
|
||||
gboolean got_results)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SEARCH_ENGINE (engine));
|
||||
|
||||
g_signal_emit (engine, signals[FINISHED], 0);
|
||||
g_signal_emit (engine, signals[FINISHED], 0, got_results);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -82,7 +82,8 @@ void _gtk_search_engine_stop (GtkSearchEngine *engine);
|
||||
|
||||
void _gtk_search_engine_hits_added (GtkSearchEngine *engine,
|
||||
GList *hits);
|
||||
void _gtk_search_engine_finished (GtkSearchEngine *engine);
|
||||
void _gtk_search_engine_finished (GtkSearchEngine *engine,
|
||||
gboolean got_results);
|
||||
void _gtk_search_engine_error (GtkSearchEngine *engine,
|
||||
const gchar *error_message);
|
||||
void _gtk_search_engine_set_recursive (GtkSearchEngine *engine,
|
||||
|
@ -124,7 +124,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GT
|
||||
|
||||
[self submitHits:ns_query];
|
||||
|
||||
_gtk_search_engine_finished (engine);
|
||||
_gtk_search_engine_finished (engine, submitted_hits > 0);
|
||||
submitted_hits = 0;
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ query_callback (GObject *object,
|
||||
|
||||
if (!reply)
|
||||
{
|
||||
_gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker));
|
||||
_gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker), FALSE);
|
||||
g_object_unref (tracker);
|
||||
return;
|
||||
}
|
||||
@ -315,7 +315,7 @@ query_callback (GObject *object,
|
||||
}
|
||||
|
||||
_gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (tracker), hits);
|
||||
_gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker));
|
||||
_gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker), i > 0);
|
||||
|
||||
g_list_free (hits);
|
||||
for (i = 0; i < n; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user