shell: pass the full query to the slot to preserve all settings

Instead of just opening a window with just the location and search terms,
we should pass to the window slot the full nautilus query with all the
shell search provider flags, so that they will be respected and that the
results in the overview will respect the ones in nautilus
This commit is contained in:
Marco Trevisan (Treviño) 2018-07-17 04:15:11 +02:00
parent 99f55748ef
commit 16d8b80cc4
7 changed files with 39 additions and 43 deletions

View file

@ -1611,15 +1611,12 @@ nautilus_application_new (void)
void
nautilus_application_search (NautilusApplication *self,
const gchar *uri,
const gchar *text)
NautilusQuery *query)
{
g_autoptr (GFile) location = NULL;
NautilusWindow *window;
GFile *location;
location = g_file_new_for_uri (uri);
location = nautilus_query_get_location (query);
window = open_window (self, location);
nautilus_window_search (window, text);
g_object_unref (location);
nautilus_window_search (window, query);
}

View file

@ -84,7 +84,6 @@ GtkWidget * nautilus_application_connect_server (NautilusApplication *applicatio
NautilusWindow *window);
void nautilus_application_search (NautilusApplication *application,
const gchar *uri,
const gchar *text);
NautilusQuery *query);
void nautilus_application_startup_common (NautilusApplication *application);
G_END_DECLS

View file

@ -426,15 +426,32 @@ search_add_volumes_and_bookmarks (PendingSearch *search)
g_object_unref (volume_monitor);
}
static NautilusQuery*
shell_query_new (gchar **terms)
{
NautilusQuery *query;
g_autoptr (GFile) home = NULL;
g_autofree gchar *terms_joined = NULL;
terms_joined = g_strjoinv (" ", terms);
home = g_file_new_for_path (g_get_home_dir ());
query = nautilus_query_new ();
nautilus_query_set_show_hidden_files (query, FALSE);
nautilus_query_set_recursive (query, NAUTILUS_QUERY_RECURSIVE_INDEXED_ONLY);
nautilus_query_set_text (query, terms_joined);
nautilus_query_set_location (query, home);
return query;
}
static void
execute_search (NautilusShellSearchProvider *self,
GDBusMethodInvocation *invocation,
gchar **terms)
{
gchar *terms_joined;
NautilusQuery *query;
PendingSearch *pending_search;
GFile *home;
cancel_current_search (self);
@ -446,14 +463,7 @@ execute_search (NautilusShellSearchProvider *self,
return;
}
terms_joined = g_strjoinv (" ", terms);
home = g_file_new_for_path (g_get_home_dir ());
query = nautilus_query_new ();
nautilus_query_set_show_hidden_files (query, FALSE);
nautilus_query_set_recursive (query, NAUTILUS_QUERY_RECURSIVE_INDEXED_ONLY);
nautilus_query_set_text (query, terms_joined);
nautilus_query_set_location (query, home);
query = shell_query_new (terms);
pending_search = g_slice_new0 (PendingSearch);
pending_search->invocation = g_object_ref (invocation);
@ -480,9 +490,6 @@ execute_search (NautilusShellSearchProvider *self,
nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (pending_search->engine),
query);
nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (pending_search->engine));
g_clear_object (&home);
g_free (terms_joined);
}
static gboolean
@ -714,13 +721,9 @@ handle_launch_search (NautilusShellSearchProvider2 *skeleton,
gpointer user_data)
{
GApplication *app = g_application_get_default ();
gchar *string = g_strjoinv (" ", terms);
gchar *uri = nautilus_get_home_directory_uri ();
g_autoptr (NautilusQuery) query = shell_query_new (terms);
nautilus_application_search (NAUTILUS_APPLICATION (app), uri, string);
g_free (string);
g_free (uri);
nautilus_application_search (NAUTILUS_APPLICATION (app), query);
nautilus_shell_search_provider2_complete_launch_search (skeleton, invocation);
return TRUE;

View file

@ -98,6 +98,7 @@ typedef struct
/* Query editor */
NautilusQueryEditor *query_editor;
NautilusQuery *pending_search_query;
gulong qe_changed_id;
gulong qe_cancel_id;
gulong qe_activated_id;
@ -111,7 +112,6 @@ typedef struct
* finish. Used for showing a spinner to provide feedback to the user. */
gboolean allow_stop;
gboolean needs_reload;
gchar *pending_search_text;
/* New location. */
GFile *pending_location;
@ -376,9 +376,9 @@ update_search_visible (NautilusWindowSlot *self)
}
}
if (priv->pending_search_text)
if (priv->pending_search_query)
{
nautilus_window_slot_search (self, g_strdup (priv->pending_search_text));
nautilus_window_slot_search (self, g_object_ref (priv->pending_search_query));
}
}
@ -599,17 +599,13 @@ nautilus_window_slot_get_search_visible (NautilusWindowSlot *self)
void
nautilus_window_slot_search (NautilusWindowSlot *self,
const gchar *text)
NautilusQuery *query)
{
NautilusWindowSlotPrivate *priv;
NautilusView *view;
priv = nautilus_window_slot_get_instance_private (self);
if (priv->pending_search_text)
{
g_free (priv->pending_search_text);
priv->pending_search_text = NULL;
}
g_clear_object (&priv->pending_search_query);
view = nautilus_window_slot_get_current_view (self);
/* We could call this when the location is still being checked in the
@ -618,11 +614,11 @@ nautilus_window_slot_search (NautilusWindowSlot *self,
if (view)
{
nautilus_window_slot_set_search_visible (self, TRUE);
nautilus_query_editor_set_text (priv->query_editor, text);
nautilus_query_editor_set_query (priv->query_editor, query);
}
else
{
priv->pending_search_text = g_strdup (text);
priv->pending_search_query = g_object_ref (query);
}
}
@ -3087,6 +3083,7 @@ nautilus_window_slot_dispose (GObject *object)
g_clear_object (&priv->current_location_bookmark);
g_clear_object (&priv->last_location_bookmark);
g_clear_object (&priv->slot_action_group);
g_clear_object (&priv->pending_search_query);
g_clear_pointer (&priv->find_mount_cancellable, g_cancellable_cancel);

View file

@ -115,7 +115,7 @@ gboolean nautilus_window_slot_get_searching (NautilusWindowSlot *
GList* nautilus_window_slot_get_selection (NautilusWindowSlot *slot);
void nautilus_window_slot_search (NautilusWindowSlot *slot,
const gchar *text);
NautilusQuery *query);
gboolean nautilus_window_slot_handles_location (NautilusWindowSlot *self,
GFile *location);

View file

@ -2884,14 +2884,14 @@ nautilus_window_show_about_dialog (NautilusWindow *window)
void
nautilus_window_search (NautilusWindow *window,
const gchar *text)
NautilusQuery *query)
{
NautilusWindowSlot *active_slot;
active_slot = nautilus_window_get_active_slot (window);
if (active_slot)
{
nautilus_window_slot_search (active_slot, text);
nautilus_window_slot_search (active_slot, query);
}
else
{

View file

@ -103,7 +103,7 @@ void nautilus_window_end_dnd (NautilusWindow *window,
GdkDragContext *context);
void nautilus_window_search (NautilusWindow *window,
const gchar *text);
NautilusQuery *query);
void nautilus_window_initialize_slot (NautilusWindow *window,
NautilusWindowSlot *slot,