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

Subscribers

People subscribed via source and target branches