[nautilus/gnome-3-20] general: allow to search from any part of the stack
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-3-20] general: allow to search from any part of the stack
- Date: Thu, 3 Mar 2016 15:51:13 +0000 (UTC)
commit 24de92b3d8b0af47fade6d95d633f7094f319b54
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Mar 3 16:38:09 2016 +0100
general: allow to search from any part of the stack
Expose the search function on the whole stack.
We will need it for searches from the gnome-shell provider.
https://bugzilla.gnome.org/show_bug.cgi?id=762076
src/nautilus-application.c | 15 +++++++++++++++
src/nautilus-application.h | 4 ++++
src/nautilus-query-editor.c | 12 ++++++++++++
src/nautilus-query-editor.h | 2 ++
src/nautilus-window-slot.c | 27 +++++++++++++++++++++++++++
src/nautilus-window-slot.h | 3 +++
src/nautilus-window.c | 13 +++++++++++++
src/nautilus-window.h | 3 +++
8 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index b25021f..0547c29 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -1372,3 +1372,18 @@ nautilus_application_new (void)
"register-session", TRUE,
NULL);
}
+
+void
+nautilus_application_search (NautilusApplication *application,
+ const gchar *uri,
+ const gchar *text)
+{
+ NautilusWindow *window;
+ GFile *location;
+
+ location = g_file_new_for_uri (uri);
+ window = open_window (application, location);
+ nautilus_window_search (window, text);
+
+ g_object_unref (location);
+}
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index 4aaa90c..a57da53 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -85,4 +85,8 @@ void nautilus_application_edit_bookmarks (NautilusApplication *application,
GtkWidget * nautilus_application_connect_server (NautilusApplication *application,
NautilusWindow *window);
+
+void nautilus_application_search (NautilusApplication *application,
+ const gchar *uri,
+ const gchar *text);
#endif /* __NAUTILUS_APPLICATION_H__ */
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 0421fb9..a9e452a 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -726,3 +726,15 @@ nautilus_query_editor_set_query (NautilusQueryEditor *editor,
g_free (text);
}
+
+void
+nautilus_query_editor_set_text (NautilusQueryEditor *editor,
+ const gchar *text)
+{
+ NautilusQueryEditorPrivate *priv;
+
+ priv = nautilus_query_editor_get_instance_private (editor);
+
+ /* The handler of the entry will take care of everything */
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), text);
+}
diff --git a/src/nautilus-query-editor.h b/src/nautilus-query-editor.h
index d166c6d..11aa8ac 100644
--- a/src/nautilus-query-editor.h
+++ b/src/nautilus-query-editor.h
@@ -52,5 +52,7 @@ void nautilus_query_editor_set_query (NautilusQueryEditor *editor,
GFile * nautilus_query_editor_get_location (NautilusQueryEditor *editor);
void nautilus_query_editor_set_location (NautilusQueryEditor *editor,
GFile *location);
+void nautilus_query_editor_set_text (NautilusQueryEditor *editor,
+ const gchar *text);
#endif /* NAUTILUS_QUERY_EDITOR_H */
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 839badc..16e2710 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -110,6 +110,7 @@ struct NautilusWindowSlotDetails {
* 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;
@@ -267,6 +268,9 @@ update_search_visible (NautilusWindowSlot *slot)
nautilus_window_slot_set_search_visible (slot, FALSE);
g_object_unref (query);
}
+
+ if (slot->details->pending_search_text)
+ nautilus_window_slot_search (slot, g_strdup (slot->details->pending_search_text));
}
static void
@@ -456,6 +460,29 @@ nautilus_window_slot_get_search_visible (NautilusWindowSlot *slot)
return searching;
}
+void
+nautilus_window_slot_search (NautilusWindowSlot *slot,
+ const gchar *text)
+{
+ NautilusView *view;
+
+ if (slot->details->pending_search_text) {
+ g_free (slot->details->pending_search_text);
+ slot->details->pending_search_text = NULL;
+ }
+
+ view = nautilus_window_slot_get_current_view (slot);
+ /* We could call this when the location is still being checked in the
+ * window slot. For that, save the search we want to do for once we have
+ * a view set up */
+ if (view) {
+ nautilus_window_slot_set_search_visible (slot, TRUE);
+ nautilus_query_editor_set_text (slot->details->query_editor, text);
+ } else {
+ slot->details->pending_search_text = g_strdup (text);
+ }
+}
+
gboolean
nautilus_window_slot_handle_event (NautilusWindowSlot *slot,
GdkEventKey *event)
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index 14fa425..1c4b4af 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -107,6 +107,9 @@ void nautilus_window_slot_set_active (NautilusWindowSlot *
gboolean active);
gboolean nautilus_window_slot_get_loading (NautilusWindowSlot *slot);
+void nautilus_window_slot_search (NautilusWindowSlot *slot,
+ const gchar *text);
+
/* Only used by slot-dnd */
NautilusView* nautilus_window_slot_get_current_view (NautilusWindowSlot *slot);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 4c91709..ce1d9aa 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2737,3 +2737,16 @@ nautilus_window_show_about_dialog (NautilusWindow *window)
"logo-icon-name", "system-file-manager",
NULL);
}
+
+void
+nautilus_window_search (NautilusWindow *window,
+ const gchar *text)
+{
+ NautilusWindowSlot *active_slot;
+
+ active_slot = nautilus_window_get_active_slot (window);
+ if (active_slot)
+ nautilus_window_slot_search (active_slot, text);
+ else
+ g_warning ("Trying search on a slot but no active slot present");
+}
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index ec53ab7..12b755c 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -147,4 +147,7 @@ void nautilus_window_start_dnd (NautilusWindow *window,
GdkDragContext *context);
void nautilus_window_end_dnd (NautilusWindow *window,
GdkDragContext *context);
+
+void nautilus_window_search (NautilusWindow *window,
+ const gchar *text);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]