Merge ~3v1n0/ubuntu/+source/nautilus:ubuntu/bionic-xubuntu-cancel-search into ~ubuntu-desktop/ubuntu/+source/nautilus:ubuntu/bionic

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: b56b8e9d7507d2432b2da481a274c54e91dce5cd
Proposed branch: ~3v1n0/ubuntu/+source/nautilus:ubuntu/bionic-xubuntu-cancel-search
Merge into: ~ubuntu-desktop/ubuntu/+source/nautilus:ubuntu/bionic
Prerequisite: ~3v1n0/ubuntu/+source/nautilus:ubuntu/bionic
Diff against target: 244 lines (+222/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/series (+1/-0)
debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch (+213/-0)
Reviewer Review Type Date Requested Status
Ubuntu Desktop Pending
Review via email: mp+374711@code.launchpad.net

This proposal supersedes a proposal from 2018-09-05.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index ad6d1f5..abea57d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
1nautilus (1:3.26.4-0~ubuntu18.04.5) bionic; urgency=medium
2
3 * d/p/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch:
4 - shell-search-provider: implement XUbuntuCancel to request pending search
5 cancellation from gnome-shell (LP: #1756826)
6
7 -- Marco Trevisan (Treviño) <marco@ubuntu.com> Fri, 25 Oct 2019 05:38:04 +0200
8
1nautilus (1:3.26.4-0~ubuntu18.04.4) bionic; urgency=medium9nautilus (1:3.26.4-0~ubuntu18.04.4) bionic; urgency=medium
210
3 * d/p/0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch:11 * d/p/0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch:
diff --git a/debian/patches/series b/debian/patches/series
index 9417da4..3ec0d73 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -26,3 +26,4 @@ appstream-compulsory.patch
26nautilusgtkplacesview-show-error-if-volume-is-not-mo.patch26nautilusgtkplacesview-show-error-if-volume-is-not-mo.patch
27file-view-Always-unset-pending_selection-after-freeing-it.patch27file-view-Always-unset-pending_selection-after-freeing-it.patch
28git_captions_order.patch28git_captions_order.patch
29ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch
diff --git a/debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch b/debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch
29new file mode 10064430new file mode 100644
index 0000000..85fa0c2
--- /dev/null
+++ b/debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch
@@ -0,0 +1,213 @@
1From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
2Date: Tue, 28 Aug 2018 01:44:49 +0200
3Subject: shell-search-provider: implement XUbuntuCancel to request search
4 cancellation
5
6Stop search and Metadata fetching on XUbuntuCancel dbus method call.
7Only allow this if the caller is the same who triggered the actual event.
8
9Bug-GNOME: https://gitlab.gnome.org/GNOME/gnome-shell/issues/183
10Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/nautilus/+bug/1756826
11Forwarded: not-needed
12---
13 data/shell-search-provider-dbus-interfaces.xml | 1 +
14 src/nautilus-shell-search-provider.c | 96 +++++++++++++++++++++++---
15 2 files changed, 88 insertions(+), 9 deletions(-)
16
17diff --git a/data/shell-search-provider-dbus-interfaces.xml b/data/shell-search-provider-dbus-interfaces.xml
18index f6840e2..4529c1e 100644
19--- a/data/shell-search-provider-dbus-interfaces.xml
20+++ b/data/shell-search-provider-dbus-interfaces.xml
21@@ -40,5 +40,6 @@
22 <arg type='as' name='Terms' direction='in' />
23 <arg type='u' name='Timestamp' direction='in' />
24 </method>
25+ <method name = 'XUbuntuCancel' />
26 </interface>
27 </node>
28diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
29index ffc2b7f..58864d6 100644
30--- a/src/nautilus-shell-search-provider.c
31+++ b/src/nautilus-shell-search-provider.c
32@@ -60,6 +60,7 @@ struct _NautilusShellSearchProvider
33
34 PendingSearch *current_search;
35
36+ GList *metas_requests;
37 GHashTable *metas_cache;
38 };
39
40@@ -143,11 +144,25 @@ pending_search_finish (PendingSearch *search,
41 }
42
43 static void
44-cancel_current_search (NautilusShellSearchProvider *self)
45+cancel_current_search (NautilusShellSearchProvider *self,
46+ gboolean ignore_partial_results)
47 {
48- if (self->current_search != NULL)
49+ PendingSearch *search = self->current_search;
50+
51+ if (search != NULL)
52 {
53- nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (self->current_search->engine));
54+ g_debug ("*** Cancel current search");
55+
56+ nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (search->engine));
57+
58+ if (ignore_partial_results)
59+ {
60+ g_signal_handlers_disconnect_by_data (G_OBJECT (search->engine),
61+ search);
62+
63+ pending_search_finish (search, search->invocation,
64+ g_variant_new ("(as)", NULL));
65+ }
66 }
67 }
68
69@@ -451,7 +466,7 @@ execute_search (NautilusShellSearchProvider *self,
70 NautilusQuery *query;
71 PendingSearch *pending_search;
72
73- cancel_current_search (self);
74+ cancel_current_search (self, FALSE);
75
76 /* don't attempt searches for a single character */
77 if (g_strv_length (terms) == 1 &&
78@@ -524,6 +539,7 @@ typedef struct
79 NautilusShellSearchProvider *self;
80
81 gint64 start_time;
82+ NautilusFileListHandle *handle;
83 GDBusMethodInvocation *invocation;
84
85 gchar **uris;
86@@ -532,6 +548,8 @@ typedef struct
87 static void
88 result_metas_data_free (ResultMetasData *data)
89 {
90+ g_clear_pointer (&data->handle, nautilus_file_list_cancel_call_when_ready);
91+
92 g_clear_object (&data->self);
93 g_clear_object (&data->invocation);
94 g_strfreev (data->uris);
95@@ -549,7 +567,7 @@ result_metas_return_from_cache (ResultMetasData *data)
96
97 g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
98
99- for (idx = 0; data->uris[idx] != NULL; idx++)
100+ for (idx = 0; data->uris && data->uris[idx] != NULL; idx++)
101 {
102 meta = g_hash_table_lookup (data->self->metas_cache,
103 data->uris[idx]);
104@@ -564,6 +582,37 @@ result_metas_return_from_cache (ResultMetasData *data)
105 g_variant_new ("(aa{sv})", &builder));
106 }
107
108+static void
109+cancel_result_meta_requests (NautilusShellSearchProvider *self,
110+ GDBusMethodInvocation *invocation)
111+{
112+ GList *l;
113+ GList *to_remove = NULL;
114+
115+ g_debug ("*** Cancel Results Meta requests");
116+
117+ for (l = self->metas_requests; l; l = l->next)
118+ {
119+ ResultMetasData *data = l->data;
120+
121+ if (invocation == NULL ||
122+ g_strcmp0 (g_dbus_method_invocation_get_sender (data->invocation),
123+ g_dbus_method_invocation_get_sender (invocation)) == 0)
124+ {
125+ g_clear_pointer (&data->uris, g_strfreev);
126+ result_metas_return_from_cache (data);
127+ to_remove = g_list_prepend (to_remove, data);
128+ }
129+ }
130+
131+ for (l = to_remove; l; l = l->next)
132+ {
133+ self->metas_requests = g_list_remove (self->metas_requests, l->data);
134+ }
135+
136+ g_list_free (to_remove);
137+}
138+
139 static void
140 result_list_attributes_ready_cb (GList *file_list,
141 gpointer user_data)
142@@ -639,6 +688,9 @@ result_list_attributes_ready_cb (GList *file_list,
143 g_free (uri);
144 }
145
146+ data->handle = NULL;
147+ data->self->metas_requests = g_list_remove (data->self->metas_requests, data);
148+
149 result_metas_return_from_cache (data);
150 result_metas_data_free (data);
151 }
152@@ -682,9 +734,10 @@ handle_get_result_metas (NautilusShellSearchProvider2 *skeleton,
153
154 nautilus_file_list_call_when_ready (missing_files,
155 NAUTILUS_FILE_ATTRIBUTES_FOR_ICON,
156- NULL,
157+ &data->handle,
158 result_list_attributes_ready_cb,
159 data);
160+ self->metas_requests = g_list_prepend (self->metas_requests, data);
161 nautilus_file_list_free (missing_files);
162 return TRUE;
163 }
164@@ -743,14 +796,37 @@ handle_launch_search (NautilusShellSearchProvider2 *skeleton,
165 return TRUE;
166 }
167
168-static void
169-search_provider_dispose (GObject *obj)
170+static gboolean
171+handle_xubuntu_cancel (NautilusShellSearchProvider2 *skeleton,
172+ GDBusMethodInvocation *invocation,
173+ gpointer user_data)
174 {
175+ NautilusShellSearchProvider *self = user_data;
176+ PendingSearch *search = self->current_search;
177+
178+ g_debug ("*** XUbuntuCancel called");
179+
180+ if (search != NULL &&
181+ g_strcmp0 (g_dbus_method_invocation_get_sender (search->invocation),
182+ g_dbus_method_invocation_get_sender (invocation)) == 0)
183+ {
184+ cancel_current_search (self, TRUE);
185+ }
186+
187+ cancel_result_meta_requests (self, invocation);
188+
189+ nautilus_shell_search_provider2_complete_xubuntu_cancel (skeleton, invocation);
190+
191+ return TRUE;
192+}
193+
194+ static void search_provider_dispose(GObject * obj) {
195 NautilusShellSearchProvider *self = NAUTILUS_SHELL_SEARCH_PROVIDER (obj);
196
197 g_clear_object (&self->skeleton);
198 g_hash_table_destroy (self->metas_cache);
199- cancel_current_search (self);
200+ cancel_current_search (self, TRUE);
201+ cancel_result_meta_requests (self, NULL);
202
203 G_OBJECT_CLASS (nautilus_shell_search_provider_parent_class)->dispose (obj);
204 }
205@@ -773,6 +849,8 @@ nautilus_shell_search_provider_init (NautilusShellSearchProvider *self)
206 G_CALLBACK (handle_activate_result), self);
207 g_signal_connect (self->skeleton, "handle-launch-search",
208 G_CALLBACK (handle_launch_search), self);
209+ g_signal_connect (self->skeleton, "handle-xubuntu-cancel",
210+ G_CALLBACK (handle_xubuntu_cancel), self);
211 }
212
213 static void

Subscribers

People subscribed via source and target branches