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

Proposed by Marco Trevisan (Treviño) on 2018-09-05
Status: Needs review
Proposed branch: ~3v1n0/ubuntu/+source/nautilus:ubuntu/bionic-xubuntu-cancel-search
Merge into: ~ubuntu-desktop/ubuntu/+source/nautilus:ubuntu/bionic
Diff against target: 243 lines (+221/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/series (+1/-0)
debian/patches/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch (+212/-0)
Reviewer Review Type Date Requested Status
Ubuntu Desktop 2018-09-05 Pending
Review via email: mp+354346@code.launchpad.net
To post a comment you must log in.

Unmerged commits

45370f0... by Marco Trevisan (Treviño) on 2018-08-28

d/p/ubuntu/shell-search-provider-implement-XUbuntuCancel-to-request-.patch

shell-search-provider: implement XUbuntuCancel to request search cancellation

Stop search and Metadata fetching on XUbuntuCancel dbus method call.
Only allow this if the caller is the same who triggered the actual event.

Fixes LP: #1756826

Preview Diff

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

Subscribers

People subscribed via source and target branches