Merge lp:~3v1n0/nautilus/recent-files-patches-update into lp:~ubuntu-desktop/nautilus/ubuntu
- recent-files-patches-update
- Merge into ubuntu
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Merged at revision: | 568 |
Proposed branch: | lp:~3v1n0/nautilus/recent-files-patches-update |
Merge into: | lp:~ubuntu-desktop/nautilus/ubuntu |
Diff against target: |
2551 lines (+1718/-668) 9 files modified
debian/changelog (+13/-0) debian/patches/0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch (+72/-0) debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch (+538/-0) debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch (+294/-0) debian/patches/0018-search-engine-add-locate-based-search-engine.patch (+739/-0) debian/patches/12_unity_launcher_support.patch (+58/-29) debian/patches/directory-update-recent-files-manager-on-rename-or-f.patch (+0/-208) debian/patches/search-engine-add-a-recent-search-engine-listing-Gtk.patch (+0/-429) debian/patches/series (+4/-2) |
To merge this branch: | bzr merge lp:~3v1n0/nautilus/recent-files-patches-update |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeremy Bícha | Approve | ||
Review via email: mp+343140@code.launchpad.net |
Commit message
debian/patches: readd missing locate search and update unity and recent files ones
Description of the change
gbp pq generated branch at https:/
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
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2018-03-24 20:07:05 +0000 |
3 | +++ debian/changelog 2018-04-12 23:13:34 +0000 |
4 | @@ -1,3 +1,16 @@ |
5 | +nautilus (1:3.26.3-0ubuntu2) UNRELEASED; urgency=medium |
6 | + |
7 | + * Readded wrongly removed patches: |
8 | + - 0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch |
9 | + - 0018-search-engine-add-locate-based-search-engine.patch |
10 | + * debian/patches/12_unity_launcher_support.patch: |
11 | + - Fix not to break builds when --enable-unity is not set |
12 | + * Updated patches as per upstream reviews: |
13 | + - 0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch |
14 | + - 0017-recent-add-function-to-update-manager-on-file-rename.patch |
15 | + |
16 | + -- Marco Trevisan (Treviño) <marco@ubuntu.com> Thu, 12 Apr 2018 19:00:28 -0400 |
17 | + |
18 | nautilus (1:3.26.3-0ubuntu1) bionic; urgency=medium |
19 | |
20 | * New upstream release |
21 | |
22 | === added file 'debian/patches/0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch' |
23 | --- debian/patches/0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch 1970-01-01 00:00:00 +0000 |
24 | +++ debian/patches/0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch 2018-04-12 23:13:34 +0000 |
25 | @@ -0,0 +1,72 @@ |
26 | +From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net> |
27 | +Date: Thu, 1 Mar 2018 08:14:04 +0100 |
28 | +Subject: tracker-search-engine: don't start it if not available on system |
29 | + |
30 | +--- |
31 | + src/nautilus-search-engine-tracker.c | 24 ++++++++++++++++++++---- |
32 | + 1 file changed, 20 insertions(+), 4 deletions(-) |
33 | + |
34 | +diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c |
35 | +index 4c917dd..8218ea3 100644 |
36 | +--- a/src/nautilus-search-engine-tracker.c |
37 | ++++ b/src/nautilus-search-engine-tracker.c |
38 | +@@ -42,6 +42,7 @@ struct _NautilusSearchEngineTracker |
39 | + gboolean query_pending; |
40 | + GQueue *hits_pending; |
41 | + |
42 | ++ gboolean available; |
43 | + gboolean recursive; |
44 | + gboolean fts_enabled; |
45 | + |
46 | +@@ -305,8 +306,15 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) |
47 | + return; |
48 | + } |
49 | + |
50 | +- DEBUG ("Tracker engine start"); |
51 | + g_object_ref (tracker); |
52 | ++ |
53 | ++ if (!tracker->available) |
54 | ++ { |
55 | ++ g_idle_add (search_finished_idle, provider); |
56 | ++ return; |
57 | ++ } |
58 | ++ |
59 | ++ DEBUG ("Tracker engine start"); |
60 | + tracker->query_pending = TRUE; |
61 | + |
62 | + g_object_notify (G_OBJECT (provider), "running"); |
63 | +@@ -472,6 +480,9 @@ nautilus_search_engine_tracker_set_query (NautilusSearchProvider *provider, |
64 | + |
65 | + tracker = NAUTILUS_SEARCH_ENGINE_TRACKER (provider); |
66 | + |
67 | ++ if (!tracker->available) |
68 | ++ return; |
69 | ++ |
70 | + g_object_ref (query); |
71 | + g_clear_object (&tracker->query); |
72 | + tracker->query = query; |
73 | +@@ -539,16 +550,21 @@ static void |
74 | + nautilus_search_engine_tracker_init (NautilusSearchEngineTracker *engine) |
75 | + { |
76 | + GError *error = NULL; |
77 | ++ static gboolean tracker_available = TRUE; |
78 | + |
79 | +- engine->hits_pending = g_queue_new (); |
80 | +- |
81 | +- engine->connection = tracker_sparql_connection_get (NULL, &error); |
82 | ++ if (!tracker_available) |
83 | ++ engine->connection = tracker_sparql_connection_get (NULL, &error); |
84 | + |
85 | + if (error) |
86 | + { |
87 | ++ tracker_available = FALSE; |
88 | + g_warning ("Could not establish a connection to Tracker: %s", error->message); |
89 | + g_error_free (error); |
90 | ++ return; |
91 | + } |
92 | ++ |
93 | ++ engine->available = TRUE; |
94 | ++ engine->hits_pending = g_queue_new (); |
95 | + } |
96 | + |
97 | + |
98 | |
99 | === added file 'debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch' |
100 | --- debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch 1970-01-01 00:00:00 +0000 |
101 | +++ debian/patches/0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch 2018-04-12 23:13:34 +0000 |
102 | @@ -0,0 +1,538 @@ |
103 | +From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net> |
104 | +Date: Wed, 21 Feb 2018 17:05:51 +0100 |
105 | +Subject: search-engine: add a recent-search-engine listing GtkRecentManager |
106 | + stuff |
107 | + |
108 | +Using GtkRecent items as search engine source in nautilus |
109 | +--- |
110 | + src/meson.build | 2 + |
111 | + src/nautilus-file.h | 1 + |
112 | + src/nautilus-search-engine-recent.c | 385 ++++++++++++++++++++++++++++++++++++ |
113 | + src/nautilus-search-engine-recent.h | 36 ++++ |
114 | + src/nautilus-search-engine.c | 11 ++ |
115 | + 5 files changed, 435 insertions(+) |
116 | + create mode 100644 src/nautilus-search-engine-recent.c |
117 | + create mode 100644 src/nautilus-search-engine-recent.h |
118 | + |
119 | +diff --git a/src/meson.build b/src/meson.build |
120 | +index a771d12..0ea9165 100644 |
121 | +--- a/src/meson.build |
122 | ++++ b/src/meson.build |
123 | +@@ -228,6 +228,8 @@ libnautilus_sources = [ |
124 | + 'nautilus-search-engine.h', |
125 | + 'nautilus-search-engine-model.c', |
126 | + 'nautilus-search-engine-model.h', |
127 | ++ 'nautilus-search-engine-recent.c', |
128 | ++ 'nautilus-search-engine-recent.h', |
129 | + 'nautilus-search-engine-simple.c', |
130 | + 'nautilus-search-engine-simple.h', |
131 | + 'nautilus-search-hit.c', |
132 | +diff --git a/src/nautilus-file.h b/src/nautilus-file.h |
133 | +index 3a83bd4..fd72d7a 100644 |
134 | +--- a/src/nautilus-file.h |
135 | ++++ b/src/nautilus-file.h |
136 | +@@ -49,6 +49,7 @@ typedef struct NautilusFile NautilusFile; |
137 | + (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_FILE)) |
138 | + #define NAUTILUS_FILE_GET_CLASS(obj) \ |
139 | + (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_FILE, NautilusFileClass)) |
140 | ++G_DEFINE_AUTOPTR_CLEANUP_FUNC (NautilusFile, g_object_unref) |
141 | + |
142 | + typedef enum { |
143 | + NAUTILUS_FILE_SORT_NONE, |
144 | +diff --git a/src/nautilus-search-engine-recent.c b/src/nautilus-search-engine-recent.c |
145 | +new file mode 100644 |
146 | +index 0000000..f052e8f |
147 | +--- /dev/null |
148 | ++++ b/src/nautilus-search-engine-recent.c |
149 | +@@ -0,0 +1,385 @@ |
150 | ++/* |
151 | ++ * Copyright (C) 2018 Canonical Ltd |
152 | ++ * |
153 | ++ * Nautilus is free software; you can redistribute it and/or |
154 | ++ * modify it under the terms of the GNU General Public License as |
155 | ++ * published by the Free Software Foundation; either version 3 of the |
156 | ++ * License, or (at your option) any later version. |
157 | ++ * |
158 | ++ * Nautilus is distributed in the hope that it will be useful, |
159 | ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
160 | ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
161 | ++ * General Public License for more details. |
162 | ++ * |
163 | ++ * You should have received a copy of the GNU General Public |
164 | ++ * License along with this program; see the file COPYING. If not, |
165 | ++ * see <http://www.gnu.org/licenses/>. |
166 | ++ * |
167 | ++ * Author: Marco Trevisan <marco.trevisan@canonical.com> |
168 | ++ */ |
169 | ++ |
170 | ++#include <config.h> |
171 | ++#include "nautilus-search-hit.h" |
172 | ++#include "nautilus-search-provider.h" |
173 | ++#include "nautilus-search-engine-recent.h" |
174 | ++#include "nautilus-ui-utilities.h" |
175 | ++#define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH |
176 | ++#include "nautilus-debug.h" |
177 | ++ |
178 | ++#include <string.h> |
179 | ++#include <glib.h> |
180 | ++#include <gio/gio.h> |
181 | ++ |
182 | ++#define FILE_ATTRIBS G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN "," \ |
183 | ++ G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP "," \ |
184 | ++ G_FILE_ATTRIBUTE_ACCESS_CAN_READ "," |
185 | ++ |
186 | ++struct _NautilusSearchEngineRecent |
187 | ++{ |
188 | ++ GObject parent_instance; |
189 | ++ |
190 | ++ NautilusQuery *query; |
191 | ++ GCancellable *cancellable; |
192 | ++ GtkRecentManager *recent_manager; |
193 | ++}; |
194 | ++ |
195 | ++static void nautilus_search_provider_init (NautilusSearchProviderInterface *iface); |
196 | ++ |
197 | ++G_DEFINE_TYPE_WITH_CODE (NautilusSearchEngineRecent, |
198 | ++ nautilus_search_engine_recent, |
199 | ++ G_TYPE_OBJECT, |
200 | ++ G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_SEARCH_PROVIDER, |
201 | ++ nautilus_search_provider_init)) |
202 | ++ |
203 | ++enum |
204 | ++{ |
205 | ++ PROP_0, |
206 | ++ PROP_RUNNING, |
207 | ++ LAST_PROP |
208 | ++}; |
209 | ++ |
210 | ++ |
211 | ++NautilusSearchEngineRecent * |
212 | ++nautilus_search_engine_recent_new (void) |
213 | ++{ |
214 | ++ return g_object_new (NAUTILUS_TYPE_SEARCH_ENGINE_RECENT, NULL); |
215 | ++} |
216 | ++ |
217 | ++static void |
218 | ++nautilus_search_engine_recent_finalize (GObject *object) |
219 | ++{ |
220 | ++ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (object); |
221 | ++ |
222 | ++ if (self->cancellable) |
223 | ++ { |
224 | ++ g_cancellable_cancel (self->cancellable); |
225 | ++ } |
226 | ++ |
227 | ++ g_clear_object (&self->query); |
228 | ++ g_clear_object (&self->cancellable); |
229 | ++ |
230 | ++ G_OBJECT_CLASS (nautilus_search_engine_recent_parent_class)->finalize (object); |
231 | ++} |
232 | ++ |
233 | ++typedef struct |
234 | ++{ |
235 | ++ NautilusSearchEngineRecent *recent; |
236 | ++ GList *hits; |
237 | ++} SearchHitsData; |
238 | ++ |
239 | ++ |
240 | ++static gboolean |
241 | ++search_thread_add_hits_idle (gpointer user_data) |
242 | ++{ |
243 | ++ SearchHitsData *search_hits = user_data; |
244 | ++ NautilusSearchEngineRecent *self = search_hits->recent; |
245 | ++ NautilusSearchProvider *provider = NAUTILUS_SEARCH_PROVIDER (self); |
246 | ++ |
247 | ++ if (!g_cancellable_is_cancelled (self->cancellable)) |
248 | ++ { |
249 | ++ nautilus_search_provider_hits_added (provider, search_hits->hits); |
250 | ++ DEBUG ("Recent engine add hits"); |
251 | ++ } |
252 | ++ |
253 | ++ g_list_free_full (search_hits->hits, g_object_unref); |
254 | ++ g_object_unref (self->query); |
255 | ++ g_clear_object (&self->cancellable); |
256 | ++ g_object_unref (self); |
257 | ++ g_free (search_hits); |
258 | ++ |
259 | ++ nautilus_search_provider_finished (provider, |
260 | ++ NAUTILUS_SEARCH_PROVIDER_STATUS_NORMAL); |
261 | ++ g_object_notify (G_OBJECT (provider), "running"); |
262 | ++ |
263 | ++ return FALSE; |
264 | ++} |
265 | ++ |
266 | ++static gpointer |
267 | ++recent_thread_func (gpointer user_data) |
268 | ++{ |
269 | ++ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (user_data); |
270 | ++ g_autoptr (GPtrArray) date_range = NULL; |
271 | ++ g_autoptr (GFile) query_location = NULL; |
272 | ++ SearchHitsData *search_hits; |
273 | ++ GList *recent_items; |
274 | ++ GList *mime_types; |
275 | ++ GList *hits; |
276 | ++ GList *l; |
277 | ++ |
278 | ++ g_return_val_if_fail (self->query, NULL); |
279 | ++ |
280 | ++ hits = NULL; |
281 | ++ recent_items = gtk_recent_manager_get_items (self->recent_manager); |
282 | ++ mime_types = nautilus_query_get_mime_types (self->query); |
283 | ++ date_range = nautilus_query_get_date_range (self->query); |
284 | ++ query_location = nautilus_query_get_location (self->query); |
285 | ++ |
286 | ++ for (l = recent_items; l != NULL; l = l->next) |
287 | ++ { |
288 | ++ GtkRecentInfo *info = l->data; |
289 | ++ g_autoptr (GFile) file = NULL; |
290 | ++ const gchar *uri; |
291 | ++ const gchar *name; |
292 | ++ gdouble rank; |
293 | ++ |
294 | ++ uri = gtk_recent_info_get_uri (info); |
295 | ++ file = g_file_new_for_uri (uri); |
296 | ++ |
297 | ++ if (!g_file_has_prefix (file, query_location)) |
298 | ++ { |
299 | ++ continue; |
300 | ++ } |
301 | ++ |
302 | ++ if (gtk_recent_info_is_local (info)) |
303 | ++ { |
304 | ++ g_autofree gchar *path = NULL; |
305 | ++ g_autoptr (GFileInfo) file_info = NULL; |
306 | ++ g_autoptr (GError) error = NULL; |
307 | ++ |
308 | ++ file_info = g_file_query_info (file, FILE_ATTRIBS, |
309 | ++ G_FILE_QUERY_INFO_NONE, |
310 | ++ self->cancellable, &error); |
311 | ++ if (error != NULL) |
312 | ++ { |
313 | ++ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) |
314 | ++ { |
315 | ++ break; |
316 | ++ } |
317 | ++ |
318 | ++ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) |
319 | ++ { |
320 | ++ g_debug("Impossible to read locate file info: %s", |
321 | ++ error->message); |
322 | ++ } |
323 | ++ |
324 | ++ continue; |
325 | ++ } |
326 | ++ |
327 | ++ if (!g_file_info_get_attribute_boolean (file_info, |
328 | ++ G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) |
329 | ++ { |
330 | ++ continue; |
331 | ++ } |
332 | ++ |
333 | ++ path = g_file_get_path (file); |
334 | ++ |
335 | ++ if (!nautilus_query_get_show_hidden_files (self->query) && |
336 | ++ (g_file_info_get_is_hidden (file_info) || |
337 | ++ g_file_info_get_is_backup (file_info) || |
338 | ++ g_strrstr (path, G_DIR_SEPARATOR_S ".") != NULL)) |
339 | ++ { |
340 | ++ continue; |
341 | ++ } |
342 | ++ } |
343 | ++ |
344 | ++ if (g_cancellable_is_cancelled (self->cancellable)) |
345 | ++ { |
346 | ++ break; |
347 | ++ } |
348 | ++ |
349 | ++ name = gtk_recent_info_get_display_name (info); |
350 | ++ rank = nautilus_query_matches_string (self->query, name); |
351 | ++ |
352 | ++ if (rank <= 0) |
353 | ++ { |
354 | ++ name = gtk_recent_info_get_short_name (info); |
355 | ++ rank = nautilus_query_matches_string (self->query, name); |
356 | ++ } |
357 | ++ |
358 | ++ if (rank > 0) |
359 | ++ { |
360 | ++ NautilusSearchHit *hit; |
361 | ++ time_t modified, visited; |
362 | ++ g_autoptr (GDateTime) gmodified = NULL; |
363 | ++ g_autoptr (GDateTime) gvisited = NULL; |
364 | ++ |
365 | ++ if (mime_types) |
366 | ++ { |
367 | ++ GList *ml; |
368 | ++ const gchar *mime_type = gtk_recent_info_get_mime_type (info); |
369 | ++ gboolean found = FALSE; |
370 | ++ |
371 | ++ for (ml = mime_types; mime_type != NULL && ml != NULL; |
372 | ++ ml = ml->next) |
373 | ++ { |
374 | ++ if (g_content_type_is_a (mime_type, ml->data)) |
375 | ++ { |
376 | ++ found = TRUE; |
377 | ++ break; |
378 | ++ } |
379 | ++ } |
380 | ++ |
381 | ++ if (!found) |
382 | ++ { |
383 | ++ continue; |
384 | ++ } |
385 | ++ } |
386 | ++ |
387 | ++ modified = gtk_recent_info_get_modified (info); |
388 | ++ visited = gtk_recent_info_get_visited (info); |
389 | ++ |
390 | ++ gmodified = g_date_time_new_from_unix_local (modified); |
391 | ++ gvisited = g_date_time_new_from_unix_local (visited); |
392 | ++ |
393 | ++ if (date_range != NULL) |
394 | ++ { |
395 | ++ NautilusQuerySearchType type; |
396 | ++ guint64 target_time; |
397 | ++ GDateTime *initial_date; |
398 | ++ GDateTime *end_date; |
399 | ++ |
400 | ++ initial_date = g_ptr_array_index (date_range, 0); |
401 | ++ end_date = g_ptr_array_index (date_range, 1); |
402 | ++ type = nautilus_query_get_search_type (self->query); |
403 | ++ target_time = (type == NAUTILUS_QUERY_SEARCH_TYPE_LAST_ACCESS) ? |
404 | ++ visited : modified; |
405 | ++ |
406 | ++ if (!nautilus_file_date_in_between (target_time, |
407 | ++ initial_date, end_date)) |
408 | ++ { |
409 | ++ continue; |
410 | ++ } |
411 | ++ } |
412 | ++ |
413 | ++ hit = nautilus_search_hit_new (uri); |
414 | ++ nautilus_search_hit_set_fts_rank (hit, rank); |
415 | ++ nautilus_search_hit_set_modification_time (hit, gmodified); |
416 | ++ nautilus_search_hit_set_access_time (hit, gvisited); |
417 | ++ |
418 | ++ hits = g_list_prepend (hits, hit); |
419 | ++ } |
420 | ++ } |
421 | ++ |
422 | ++ search_hits = g_new0 (SearchHitsData, 1); |
423 | ++ search_hits->recent = self; |
424 | ++ search_hits->hits = hits; |
425 | ++ |
426 | ++ g_idle_add (search_thread_add_hits_idle, search_hits); |
427 | ++ |
428 | ++ g_list_free_full (recent_items, (GDestroyNotify) gtk_recent_info_unref); |
429 | ++ g_list_free_full (mime_types, g_free); |
430 | ++ |
431 | ++ return NULL; |
432 | ++} |
433 | ++ |
434 | ++static void |
435 | ++nautilus_search_engine_recent_start (NautilusSearchProvider *provider) |
436 | ++{ |
437 | ++ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
438 | ++ GThread *thread; |
439 | ++ |
440 | ++ g_return_if_fail (self->query); |
441 | ++ g_return_if_fail (self->cancellable == NULL); |
442 | ++ |
443 | ++ g_object_ref (self); |
444 | ++ g_object_ref (self->query); |
445 | ++ self->cancellable = g_cancellable_new (); |
446 | ++ |
447 | ++ thread = g_thread_new ("nautilus-search-recent", recent_thread_func, self); |
448 | ++ g_object_notify (G_OBJECT (provider), "running"); |
449 | ++ |
450 | ++ g_thread_unref (thread); |
451 | ++} |
452 | ++ |
453 | ++static void |
454 | ++nautilus_search_engine_recent_stop (NautilusSearchProvider *provider) |
455 | ++{ |
456 | ++ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
457 | ++ |
458 | ++ if (self->cancellable != NULL) |
459 | ++ { |
460 | ++ DEBUG ("Recent engine stop"); |
461 | ++ g_cancellable_cancel (self->cancellable); |
462 | ++ g_clear_object (&self->cancellable); |
463 | ++ |
464 | ++ g_object_notify (G_OBJECT (provider), "running"); |
465 | ++ } |
466 | ++} |
467 | ++ |
468 | ++static void |
469 | ++nautilus_search_engine_recent_set_query (NautilusSearchProvider *provider, |
470 | ++ NautilusQuery *query) |
471 | ++{ |
472 | ++ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
473 | ++ |
474 | ++ g_clear_object (&self->query); |
475 | ++ self->query = g_object_ref (query); |
476 | ++} |
477 | ++ |
478 | ++static gboolean |
479 | ++nautilus_search_engine_recent_is_running (NautilusSearchProvider *provider) |
480 | ++{ |
481 | ++ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
482 | ++ |
483 | ++ return self->cancellable != NULL && |
484 | ++ !g_cancellable_is_cancelled (self->cancellable); |
485 | ++} |
486 | ++ |
487 | ++static void |
488 | ++nautilus_search_engine_recent_get_property (GObject *object, |
489 | ++ guint prop_id, |
490 | ++ GValue *value, |
491 | ++ GParamSpec *pspec) |
492 | ++{ |
493 | ++ NautilusSearchProvider *provider = NAUTILUS_SEARCH_PROVIDER (object); |
494 | ++ |
495 | ++ switch (prop_id) |
496 | ++ { |
497 | ++ case PROP_RUNNING: |
498 | ++ { |
499 | ++ gboolean running; |
500 | ++ running = nautilus_search_engine_recent_is_running (provider); |
501 | ++ g_value_set_boolean (value, running); |
502 | ++ } |
503 | ++ break; |
504 | ++ |
505 | ++ default: |
506 | ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
507 | ++ } |
508 | ++} |
509 | ++ |
510 | ++static void |
511 | ++nautilus_search_provider_init (NautilusSearchProviderInterface *iface) |
512 | ++{ |
513 | ++ iface->set_query = nautilus_search_engine_recent_set_query; |
514 | ++ iface->start = nautilus_search_engine_recent_start; |
515 | ++ iface->stop = nautilus_search_engine_recent_stop; |
516 | ++ iface->is_running = nautilus_search_engine_recent_is_running; |
517 | ++} |
518 | ++ |
519 | ++static void |
520 | ++nautilus_search_engine_recent_class_init (NautilusSearchEngineRecentClass *klass) |
521 | ++{ |
522 | ++ GObjectClass *object_class = G_OBJECT_CLASS (klass); |
523 | ++ |
524 | ++ object_class->finalize = nautilus_search_engine_recent_finalize; |
525 | ++ object_class->get_property = nautilus_search_engine_recent_get_property; |
526 | ++ |
527 | ++ g_object_class_override_property (object_class, PROP_RUNNING, "running"); |
528 | ++} |
529 | ++ |
530 | ++static void |
531 | ++nautilus_search_engine_recent_init (NautilusSearchEngineRecent *self) |
532 | ++{ |
533 | ++ self->recent_manager = gtk_recent_manager_get_default (); |
534 | ++} |
535 | +diff --git a/src/nautilus-search-engine-recent.h b/src/nautilus-search-engine-recent.h |
536 | +new file mode 100644 |
537 | +index 0000000..bcd73b9 |
538 | +--- /dev/null |
539 | ++++ b/src/nautilus-search-engine-recent.h |
540 | +@@ -0,0 +1,36 @@ |
541 | ++/* |
542 | ++ * Copyright (C) 2018 Canonical Ltd |
543 | ++ * |
544 | ++ * Nautilus is free software; you can redistribute it and/or |
545 | ++ * modify it under the terms of the GNU General Public License as |
546 | ++ * published by the Free Software Foundation; either version 3 of the |
547 | ++ * License, or (at your option) any later version. |
548 | ++ * |
549 | ++ * Nautilus is distributed in the hope that it will be useful, |
550 | ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
551 | ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
552 | ++ * General Public License for more details. |
553 | ++ * |
554 | ++ * You should have received a copy of the GNU General Public |
555 | ++ * License along with this program; see the file COPYING. If not, |
556 | ++ * see <http://www.gnu.org/licenses/>. |
557 | ++ * |
558 | ++ * Author: Marco Trevisan <marco.trevisan@canonical.com> |
559 | ++ */ |
560 | ++ |
561 | ++#ifndef __NAUTILUS_SEARCH_ENGINE_RECENT_H__ |
562 | ++#define __NAUTILUS_SEARCH_ENGINE_RECENT_H__ |
563 | ++ |
564 | ++#include <glib-object.h> |
565 | ++ |
566 | ++G_BEGIN_DECLS |
567 | ++ |
568 | ++#define NAUTILUS_TYPE_SEARCH_ENGINE_RECENT (nautilus_search_engine_recent_get_type ()) |
569 | ++ |
570 | ++G_DECLARE_FINAL_TYPE (NautilusSearchEngineRecent, nautilus_search_engine_recent, NAUTILUS, SEARCH_ENGINE_RECENT, GObject); |
571 | ++ |
572 | ++NautilusSearchEngineRecent *nautilus_search_engine_recent_new (void); |
573 | ++ |
574 | ++G_END_DECLS |
575 | ++ |
576 | ++#endif /* __NAUTILUS_SEARCH_ENGINE_RECENT_H__ */ |
577 | +diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c |
578 | +index 209bd4f..aef91b7 100644 |
579 | +--- a/src/nautilus-search-engine.c |
580 | ++++ b/src/nautilus-search-engine.c |
581 | +@@ -24,6 +24,7 @@ |
582 | + #include <glib/gi18n.h> |
583 | + #include "nautilus-search-provider.h" |
584 | + #include "nautilus-search-engine.h" |
585 | ++#include "nautilus-search-engine-recent.h" |
586 | + #include "nautilus-search-engine-simple.h" |
587 | + #include "nautilus-search-engine-model.h" |
588 | + #define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH |
589 | +@@ -33,6 +34,7 @@ |
590 | + typedef struct |
591 | + { |
592 | + NautilusSearchEngineTracker *tracker; |
593 | ++ NautilusSearchEngineRecent *recent; |
594 | + NautilusSearchEngineSimple *simple; |
595 | + NautilusSearchEngineModel *model; |
596 | + |
597 | +@@ -74,6 +76,7 @@ nautilus_search_engine_set_query (NautilusSearchProvider *provider, |
598 | + priv = nautilus_search_engine_get_instance_private (engine); |
599 | + |
600 | + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->tracker), query); |
601 | ++ nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->recent), query); |
602 | + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->model), query); |
603 | + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->simple), query); |
604 | + } |
605 | +@@ -98,6 +101,9 @@ search_engine_start_real (NautilusSearchEngine *engine) |
606 | + nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->tracker)); |
607 | + priv->providers_running++; |
608 | + |
609 | ++ priv->providers_running++; |
610 | ++ nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
611 | ++ |
612 | + if (nautilus_search_engine_model_get_model (priv->model)) |
613 | + { |
614 | + nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->model)); |
615 | +@@ -159,6 +165,7 @@ nautilus_search_engine_stop (NautilusSearchProvider *provider) |
616 | + DEBUG ("Search engine stop"); |
617 | + |
618 | + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->tracker)); |
619 | ++ nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
620 | + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->model)); |
621 | + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->simple)); |
622 | + |
623 | +@@ -334,6 +341,7 @@ nautilus_search_engine_finalize (GObject *object) |
624 | + g_hash_table_destroy (priv->uris); |
625 | + |
626 | + g_clear_object (&priv->tracker); |
627 | ++ g_clear_object (&priv->recent); |
628 | + g_clear_object (&priv->model); |
629 | + g_clear_object (&priv->simple); |
630 | + |
631 | +@@ -395,6 +403,9 @@ nautilus_search_engine_init (NautilusSearchEngine *engine) |
632 | + |
633 | + priv->simple = nautilus_search_engine_simple_new (); |
634 | + connect_provider_signals (engine, NAUTILUS_SEARCH_PROVIDER (priv->simple)); |
635 | ++ |
636 | ++ priv->recent = nautilus_search_engine_recent_new (); |
637 | ++ connect_provider_signals (engine, NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
638 | + } |
639 | + |
640 | + NautilusSearchEngine * |
641 | |
642 | === added file 'debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch' |
643 | --- debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch 1970-01-01 00:00:00 +0000 |
644 | +++ debian/patches/0017-recent-add-function-to-update-manager-on-file-rename.patch 2018-04-12 23:13:34 +0000 |
645 | @@ -0,0 +1,294 @@ |
646 | +From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net> |
647 | +Date: Wed, 11 Apr 2018 18:51:34 -0400 |
648 | +Subject: recent: add function to update manager on file rename or move |
649 | + |
650 | +When files have been moved or renamed nautilus should inform |
651 | +recent manager about this change for the files that |
652 | +are listed there. |
653 | +--- |
654 | + src/nautilus-directory.c | 8 +++ |
655 | + src/nautilus-file.c | 25 +++++----- |
656 | + src/nautilus-recent.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++ |
657 | + src/nautilus-recent.h | 8 ++- |
658 | + 4 files changed, 152 insertions(+), 15 deletions(-) |
659 | + |
660 | +diff --git a/src/nautilus-directory.c b/src/nautilus-directory.c |
661 | +index ad3bb03..f1a3bf8 100644 |
662 | +--- a/src/nautilus-directory.c |
663 | ++++ b/src/nautilus-directory.c |
664 | +@@ -33,6 +33,7 @@ |
665 | + #include "nautilus-lib-self-check-functions.h" |
666 | + #include "nautilus-metadata.h" |
667 | + #include "nautilus-profile.h" |
668 | ++#include "nautilus-recent.h" |
669 | + #include "nautilus-vfs-directory.h" |
670 | + #include <eel/eel-glib-extensions.h> |
671 | + #include <eel/eel-string.h> |
672 | +@@ -1546,9 +1547,14 @@ nautilus_directory_notify_files_moved (GList *file_pairs) |
673 | + |
674 | + for (p = file_pairs; p != NULL; p = p->next) |
675 | + { |
676 | ++ g_autofree char *from_uri = NULL; |
677 | ++ g_autofree char *to_uri = NULL; |
678 | ++ |
679 | + pair = p->data; |
680 | + from_location = pair->from; |
681 | + to_location = pair->to; |
682 | ++ from_uri = g_file_get_uri (from_location); |
683 | ++ to_uri = g_file_get_uri (to_location); |
684 | + |
685 | + /* Handle overwriting a file. */ |
686 | + file = nautilus_file_get_existing (to_location); |
687 | +@@ -1626,6 +1632,8 @@ nautilus_directory_notify_files_moved (GList *file_pairs) |
688 | + /* Unref each file once to balance out nautilus_file_get_by_uri. */ |
689 | + unref_list = g_list_prepend (unref_list, file); |
690 | + } |
691 | ++ |
692 | ++ nautilus_recent_update_file_moved (from_uri, to_uri, NULL, NULL); |
693 | + } |
694 | + |
695 | + /* Now send out the changed and added signals for existing file objects. */ |
696 | +diff --git a/src/nautilus-file.c b/src/nautilus-file.c |
697 | +index 2135801..15e5d05 100644 |
698 | +--- a/src/nautilus-file.c |
699 | ++++ b/src/nautilus-file.c |
700 | +@@ -34,6 +34,7 @@ |
701 | + #include "nautilus-link.h" |
702 | + #include "nautilus-metadata.h" |
703 | + #include "nautilus-module.h" |
704 | ++#include "nautilus-recent.h" |
705 | + #include "nautilus-thumbnails.h" |
706 | + #include "nautilus-ui-utilities.h" |
707 | + #include "nautilus-video-mime-types.h" |
708 | +@@ -1952,14 +1953,12 @@ rename_get_info_callback (GObject *source_object, |
709 | + GAsyncResult *res, |
710 | + gpointer callback_data) |
711 | + { |
712 | ++ g_autoptr (GFileInfo) new_info = NULL; |
713 | ++ g_autoptr (GError) error = NULL; |
714 | + NautilusFileOperation *op; |
715 | + NautilusDirectory *directory; |
716 | + NautilusFile *existing_file; |
717 | +- char *old_uri; |
718 | +- char *new_uri; |
719 | + const char *new_name; |
720 | +- GFileInfo *new_info; |
721 | +- GError *error; |
722 | + |
723 | + op = callback_data; |
724 | + |
725 | +@@ -1967,8 +1966,12 @@ rename_get_info_callback (GObject *source_object, |
726 | + new_info = g_file_query_info_finish (G_FILE (source_object), res, &error); |
727 | + if (new_info != NULL) |
728 | + { |
729 | +- directory = op->file->details->directory; |
730 | ++ g_autofree char *old_uri = NULL; |
731 | ++ g_autofree char *new_uri = NULL; |
732 | ++ g_autofree char *new_display_name = NULL; |
733 | ++ g_autofree char *old_display_name = NULL; |
734 | + |
735 | ++ directory = op->file->details->directory; |
736 | + new_name = g_file_info_get_name (new_info); |
737 | + |
738 | + /* If there was another file by the same name in this |
739 | +@@ -1983,6 +1986,7 @@ rename_get_info_callback (GObject *source_object, |
740 | + } |
741 | + |
742 | + old_uri = nautilus_file_get_uri (op->file); |
743 | ++ old_display_name = nautilus_file_get_display_name (op->file); |
744 | + |
745 | + update_info_and_name (op->file, new_info); |
746 | + |
747 | +@@ -2010,9 +2014,10 @@ rename_get_info_callback (GObject *source_object, |
748 | + g_object_unref (subject); |
749 | + g_free (origin); |
750 | + |
751 | ++ new_display_name = nautilus_file_get_display_name (op->file); |
752 | + nautilus_directory_moved (old_uri, new_uri); |
753 | +- g_free (new_uri); |
754 | +- g_free (old_uri); |
755 | ++ nautilus_recent_update_file_moved (old_uri, new_uri, |
756 | ++ old_display_name, new_display_name); |
757 | + |
758 | + /* the rename could have affected the display name if e.g. |
759 | + * we're in a vfolder where the name comes from a desktop file |
760 | +@@ -2024,14 +2029,8 @@ rename_get_info_callback (GObject *source_object, |
761 | + NAUTILUS_FILE_ATTRIBUTE_INFO | |
762 | + NAUTILUS_FILE_ATTRIBUTE_LINK_INFO); |
763 | + } |
764 | +- |
765 | +- g_object_unref (new_info); |
766 | + } |
767 | + nautilus_file_operation_complete (op, NULL, error); |
768 | +- if (error) |
769 | +- { |
770 | +- g_error_free (error); |
771 | +- } |
772 | + } |
773 | + |
774 | + static void |
775 | +diff --git a/src/nautilus-recent.c b/src/nautilus-recent.c |
776 | +index ab50fef..c69a3a7 100644 |
777 | +--- a/src/nautilus-recent.c |
778 | ++++ b/src/nautilus-recent.c |
779 | +@@ -1,5 +1,6 @@ |
780 | + /* |
781 | + * Copyright (C) 2002 James Willcox |
782 | ++ * Copyright (C) 2018 Canonical Ltd |
783 | + * |
784 | + * This program is free software; you can redistribute it and/or modify |
785 | + * it under the terms of the GNU General Public License as published by |
786 | +@@ -17,6 +18,7 @@ |
787 | + |
788 | + #include "config.h" |
789 | + #include "nautilus-recent.h" |
790 | ++#include "nautilus-file-private.h" |
791 | + |
792 | + #include <eel/eel-vfs-extensions.h> |
793 | + |
794 | +@@ -85,3 +87,127 @@ nautilus_recent_add_file (NautilusFile *file, |
795 | + |
796 | + g_free (uri); |
797 | + } |
798 | ++ |
799 | ++void |
800 | ++nautilus_recent_update_file_moved (const gchar *old_uri, |
801 | ++ const gchar *new_uri, |
802 | ++ const gchar *old_display_name, |
803 | ++ const gchar *new_display_name) |
804 | ++{ |
805 | ++ GtkRecentManager *recent_manager = nautilus_recent_get_manager (); |
806 | ++ g_autoptr (NautilusFile) file = NULL; |
807 | ++ NautilusFile *existing_file; |
808 | ++ |
809 | ++ if (new_uri == NULL || old_uri == NULL) |
810 | ++ { |
811 | ++ return; |
812 | ++ } |
813 | ++ |
814 | ++ existing_file = nautilus_file_get_existing_by_uri (new_uri); |
815 | ++ |
816 | ++ if (existing_file) |
817 | ++ { |
818 | ++ file = g_object_ref (existing_file); |
819 | ++ } |
820 | ++ else |
821 | ++ { |
822 | ++ g_autoptr (GFile) location = g_file_new_for_uri (new_uri); |
823 | ++ g_autoptr (GFileInfo) file_info = NULL; |
824 | ++ |
825 | ++ file_info = g_file_query_info (location, |
826 | ++ NAUTILUS_FILE_DEFAULT_ATTRIBUTES, |
827 | ++ 0, NULL, NULL); |
828 | ++ if (file_info == NULL) |
829 | ++ { |
830 | ++ return; |
831 | ++ } |
832 | ++ |
833 | ++ file = nautilus_file_get (location); |
834 | ++ nautilus_file_update_info (file, file_info); |
835 | ++ } |
836 | ++ |
837 | ++ if (nautilus_file_is_directory (file)) |
838 | ++ { |
839 | ++ GList *recent_items; |
840 | ++ GList *l; |
841 | ++ |
842 | ++ recent_items = gtk_recent_manager_get_items (recent_manager); |
843 | ++ |
844 | ++ for (l = recent_items; l; l = l->next) |
845 | ++ { |
846 | ++ GtkRecentInfo *info = l->data; |
847 | ++ const gchar *item_uri = gtk_recent_info_get_uri (info); |
848 | ++ |
849 | ++ if (g_str_has_prefix (item_uri, old_uri)) |
850 | ++ { |
851 | ++ const gchar *relative_path = item_uri + strlen (old_uri); |
852 | ++ g_autofree gchar *new_item_uri = NULL; |
853 | ++ |
854 | ++ new_item_uri = g_build_filename (new_uri, relative_path, NULL); |
855 | ++ |
856 | ++ gtk_recent_manager_move_item (recent_manager, |
857 | ++ item_uri, new_item_uri, NULL); |
858 | ++ } |
859 | ++ } |
860 | ++ |
861 | ++ g_list_free_full (recent_items, (GDestroyNotify) gtk_recent_info_unref); |
862 | ++ } |
863 | ++ else |
864 | ++ { |
865 | ++ GtkRecentInfo *old_recent; |
866 | ++ |
867 | ++ old_recent = gtk_recent_manager_lookup_item (recent_manager, |
868 | ++ old_uri, NULL); |
869 | ++ if (old_recent) |
870 | ++ { |
871 | ++ gboolean recreated = FALSE; |
872 | ++ |
873 | ++ if ((new_display_name != NULL && old_display_name == NULL) || |
874 | ++ (g_strcmp0 (old_display_name, new_display_name) != 0 && |
875 | ++ g_strcmp0 (old_display_name, |
876 | ++ gtk_recent_info_get_display_name (old_recent)) == 0)) |
877 | ++ { |
878 | ++ /* If old display name, matches the one in the recent file |
879 | ++ * We can't just move it, but we need to recreate the |
880 | ++ * GtkRecentInfo |
881 | ++ */ |
882 | ++ GtkRecentData recent_data = |
883 | ++ { |
884 | ++ .display_name = (gchar *) new_display_name, |
885 | ++ .description = (gchar *) gtk_recent_info_get_description (old_recent), |
886 | ++ .mime_type = (gchar *) gtk_recent_info_get_mime_type (old_recent), |
887 | ++ .app_name = gtk_recent_info_last_application (old_recent), |
888 | ++ .groups = gtk_recent_info_get_groups (old_recent, NULL), |
889 | ++ .is_private = gtk_recent_info_get_private_hint (old_recent), |
890 | ++ }; |
891 | ++ |
892 | ++ if (recent_data.app_name) |
893 | ++ { |
894 | ++ gtk_recent_info_get_application_info (old_recent, |
895 | ++ recent_data.app_name, |
896 | ++ (const gchar **) &(recent_data.app_exec), |
897 | ++ NULL, NULL); |
898 | ++ } |
899 | ++ |
900 | ++ if (gtk_recent_manager_add_full (recent_manager, |
901 | ++ new_uri, |
902 | ++ &recent_data)) |
903 | ++ { |
904 | ++ recreated = gtk_recent_manager_remove_item (recent_manager, |
905 | ++ old_uri, |
906 | ++ NULL); |
907 | ++ } |
908 | ++ } |
909 | ++ |
910 | ++ if (!recreated) |
911 | ++ { |
912 | ++ gtk_recent_manager_move_item (recent_manager, |
913 | ++ old_uri, new_uri, NULL); |
914 | ++ } |
915 | ++ } |
916 | ++ else |
917 | ++ { |
918 | ++ gtk_recent_manager_remove_item (recent_manager, old_uri, NULL); |
919 | ++ } |
920 | ++ } |
921 | ++} |
922 | +diff --git a/src/nautilus-recent.h b/src/nautilus-recent.h |
923 | +index 5c64f6c..841854e 100644 |
924 | +--- a/src/nautilus-recent.h |
925 | ++++ b/src/nautilus-recent.h |
926 | +@@ -7,7 +7,11 @@ |
927 | + #include "nautilus-file.h" |
928 | + #include <gio/gio.h> |
929 | + |
930 | +-void nautilus_recent_add_file (NautilusFile *file, |
931 | +- GAppInfo *application); |
932 | ++void nautilus_recent_add_file (NautilusFile *file, |
933 | ++ GAppInfo *application); |
934 | ++void nautilus_recent_update_file_moved (const char *old_uri, |
935 | ++ const char *new_uri, |
936 | ++ const char *old_display_name, |
937 | ++ const char *new_dispaly_name); |
938 | + |
939 | + #endif |
940 | |
941 | === added file 'debian/patches/0018-search-engine-add-locate-based-search-engine.patch' |
942 | --- debian/patches/0018-search-engine-add-locate-based-search-engine.patch 1970-01-01 00:00:00 +0000 |
943 | +++ debian/patches/0018-search-engine-add-locate-based-search-engine.patch 2018-04-12 23:13:34 +0000 |
944 | @@ -0,0 +1,739 @@ |
945 | +From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net> |
946 | +Date: Thu, 1 Mar 2018 05:37:08 +0100 |
947 | +Subject: search-engine: add locate based search engine |
948 | + |
949 | +Look for files in the (m)locate database using |
950 | +command line and parsing output to provide more and |
951 | +quicker results to the shell and nautilus |
952 | +--- |
953 | + src/meson.build | 2 + |
954 | + src/nautilus-search-engine-locate.c | 597 ++++++++++++++++++++++++++++++++++++ |
955 | + src/nautilus-search-engine-locate.h | 37 +++ |
956 | + src/nautilus-search-engine.c | 11 + |
957 | + 4 files changed, 647 insertions(+) |
958 | + create mode 100644 src/nautilus-search-engine-locate.c |
959 | + create mode 100644 src/nautilus-search-engine-locate.h |
960 | + |
961 | +diff --git a/src/meson.build b/src/meson.build |
962 | +index 0ea9165..06e6633 100644 |
963 | +--- a/src/meson.build |
964 | ++++ b/src/meson.build |
965 | +@@ -228,6 +228,8 @@ libnautilus_sources = [ |
966 | + 'nautilus-search-engine.h', |
967 | + 'nautilus-search-engine-model.c', |
968 | + 'nautilus-search-engine-model.h', |
969 | ++ 'nautilus-search-engine-locate.c', |
970 | ++ 'nautilus-search-engine-locate.h', |
971 | + 'nautilus-search-engine-recent.c', |
972 | + 'nautilus-search-engine-recent.h', |
973 | + 'nautilus-search-engine-simple.c', |
974 | +diff --git a/src/nautilus-search-engine-locate.c b/src/nautilus-search-engine-locate.c |
975 | +new file mode 100644 |
976 | +index 0000000..16f9f21 |
977 | +--- /dev/null |
978 | ++++ b/src/nautilus-search-engine-locate.c |
979 | +@@ -0,0 +1,597 @@ |
980 | ++/* |
981 | ++ * Copyright (C) 2018 Canonical Ltd |
982 | ++ * |
983 | ++ * Nautilus is free software; you can redistribute it and/or |
984 | ++ * modify it under the terms of the GNU General Public License as |
985 | ++ * published by the Free Software Foundation; either version 2 of the |
986 | ++ * License, or (at your option) any later version. |
987 | ++ * |
988 | ++ * Nautilus is distributed in the hope that it will be useful, |
989 | ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
990 | ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
991 | ++ * General Public License for more details. |
992 | ++ * |
993 | ++ * You should have received a copy of the GNU General Public |
994 | ++ * License along with this program; see the file COPYING. If not, |
995 | ++ * see <http://www.gnu.org/licenses/>. |
996 | ++ * |
997 | ++ * Author: Marco Trevisan <marco.trevisan@canonical.com> |
998 | ++ * |
999 | ++ */ |
1000 | ++ |
1001 | ++#include "nautilus-search-hit.h" |
1002 | ++#include "nautilus-search-provider.h" |
1003 | ++#include "nautilus-search-engine-locate.h" |
1004 | ++#include "nautilus-ui-utilities.h" |
1005 | ++#define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH |
1006 | ++#include "nautilus-debug.h" |
1007 | ++ |
1008 | ++#include <string.h> |
1009 | ++#include <glib.h> |
1010 | ++#include <gio/gio.h> |
1011 | ++ |
1012 | ++#define LOCATE_BINARY "locate" |
1013 | ++#define WORD_SEPARATORS "\t\n !\"#$%&'()*+,-./:;<=>?[\\]^_`{|}~" |
1014 | ++#define BATCH_SIZE 300 |
1015 | ++#define FILE_ATTRIBS G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN "," \ |
1016 | ++ G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP "," \ |
1017 | ++ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," \ |
1018 | ++ G_FILE_ATTRIBUTE_ACCESS_CAN_READ "," \ |
1019 | ++ G_FILE_ATTRIBUTE_TIME_MODIFIED "," \ |
1020 | ++ G_FILE_ATTRIBUTE_TIME_ACCESS |
1021 | ++ |
1022 | ++enum |
1023 | ++{ |
1024 | ++ LOCATE_INSTALLED = (1 << 0), |
1025 | ++ LOCATE_SUPPORTS_IGNORE_CASE = (1 << 1), |
1026 | ++ LOCATE_SUPPORTS_BASENAME_MATCHING = (1 << 2), |
1027 | ++ LOCATE_SUPPORTS_TRANSLITERATION = (1 << 3), |
1028 | ++ LOCATE_SUPPORTS_IGNORE_SEPARATORS = (1 << 4), |
1029 | ++}; |
1030 | ++ |
1031 | ++struct _NautilusSearchEngineLocate |
1032 | ++{ |
1033 | ++ GObject parent_instance; |
1034 | ++ |
1035 | ++ NautilusQuery *query; |
1036 | ++ GCancellable *cancellable; |
1037 | ++ gint locate_features; |
1038 | ++ GSubprocess *locate_process; |
1039 | ++}; |
1040 | ++ |
1041 | ++typedef struct |
1042 | ++{ |
1043 | ++ NautilusSearchEngineLocate *locate; |
1044 | ++ gboolean completed; |
1045 | ++ gsize pending_ops; |
1046 | ++ |
1047 | ++ GPtrArray *date_range; |
1048 | ++ GList *mime_types; |
1049 | ++ |
1050 | ++ gsize n_processed_paths; |
1051 | ++ GList *hits; |
1052 | ++ |
1053 | ++ NautilusQuery *query; |
1054 | ++ gchar *query_path; |
1055 | ++} LocateSearchData; |
1056 | ++ |
1057 | ++static void nautilus_search_provider_init (NautilusSearchProviderInterface *iface); |
1058 | ++ |
1059 | ++G_DEFINE_TYPE_WITH_CODE (NautilusSearchEngineLocate, |
1060 | ++ nautilus_search_engine_locate, |
1061 | ++ G_TYPE_OBJECT, |
1062 | ++ G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_SEARCH_PROVIDER, |
1063 | ++ nautilus_search_provider_init)) |
1064 | ++ |
1065 | ++enum |
1066 | ++{ |
1067 | ++ PROP_0, |
1068 | ++ PROP_RUNNING, |
1069 | ++ LAST_PROP |
1070 | ++}; |
1071 | ++ |
1072 | ++NautilusSearchEngineLocate * |
1073 | ++nautilus_search_engine_locate_new (void) |
1074 | ++{ |
1075 | ++ return g_object_new (NAUTILUS_TYPE_SEARCH_ENGINE_LOCATE, NULL); |
1076 | ++} |
1077 | ++ |
1078 | ++static void |
1079 | ++nautilus_search_engine_locate_finalize (GObject *object) |
1080 | ++{ |
1081 | ++ NautilusSearchEngineLocate *self = NAUTILUS_SEARCH_ENGINE_LOCATE (object); |
1082 | ++ |
1083 | ++ if (self->cancellable) |
1084 | ++ g_cancellable_cancel (self->cancellable); |
1085 | ++ |
1086 | ++ if (self->locate_process) |
1087 | ++ g_subprocess_force_exit(self->locate_process); |
1088 | ++ |
1089 | ++ g_clear_object (&self->query); |
1090 | ++ g_clear_object (&self->cancellable); |
1091 | ++ g_clear_object (&self->locate_process); |
1092 | ++ |
1093 | ++ G_OBJECT_CLASS (nautilus_search_engine_locate_parent_class)->finalize (object); |
1094 | ++} |
1095 | ++ |
1096 | ++typedef struct |
1097 | ++{ |
1098 | ++ NautilusSearchEngineLocate *locate; |
1099 | ++ GList *hits; |
1100 | ++} SearchHitsData; |
1101 | ++ |
1102 | ++ |
1103 | ++static void |
1104 | ++submit_available_hits (LocateSearchData *sdata) |
1105 | ++{ |
1106 | ++ NautilusSearchEngineLocate *self = sdata->locate; |
1107 | ++ NautilusSearchProvider *provider = NAUTILUS_SEARCH_PROVIDER (self); |
1108 | ++ |
1109 | ++ if (sdata->hits) |
1110 | ++ { |
1111 | ++ nautilus_search_provider_hits_added (provider, sdata->hits); |
1112 | ++ g_list_free_full (sdata->hits, g_object_unref); |
1113 | ++ sdata->hits = NULL; |
1114 | ++ } |
1115 | ++ |
1116 | ++ sdata->n_processed_paths = 0; |
1117 | ++} |
1118 | ++ |
1119 | ++static void |
1120 | ++submit_results (LocateSearchData *sdata) |
1121 | ++{ |
1122 | ++ NautilusSearchEngineLocate *self = sdata->locate; |
1123 | ++ |
1124 | ++ if (!g_cancellable_is_cancelled (self->cancellable)) |
1125 | ++ submit_available_hits (sdata); |
1126 | ++ |
1127 | ++ g_clear_object (&self->cancellable); |
1128 | ++ g_clear_object (&self->locate_process); |
1129 | ++ |
1130 | ++ g_object_notify (G_OBJECT (self), "running"); |
1131 | ++ nautilus_search_provider_finished (NAUTILUS_SEARCH_PROVIDER (self), |
1132 | ++ NAUTILUS_SEARCH_PROVIDER_STATUS_NORMAL); |
1133 | ++ g_object_unref (self); |
1134 | ++ |
1135 | ++ g_clear_object (&sdata->query); |
1136 | ++ g_clear_pointer (&sdata->date_range, g_ptr_array_unref); |
1137 | ++ g_list_free_full (sdata->hits, g_object_unref); |
1138 | ++ g_list_free_full (sdata->mime_types, g_free); |
1139 | ++ g_free (sdata->query_path); |
1140 | ++ g_free (sdata); |
1141 | ++} |
1142 | ++ |
1143 | ++static void |
1144 | ++maybe_submit_available_hits (LocateSearchData *sdata) |
1145 | ++{ |
1146 | ++ if (G_UNLIKELY (sdata->completed && sdata->pending_ops == 0)) |
1147 | ++ { |
1148 | ++ submit_results (sdata); |
1149 | ++ } |
1150 | ++ else if (sdata->n_processed_paths > BATCH_SIZE) |
1151 | ++ { |
1152 | ++ submit_available_hits (sdata); |
1153 | ++ } |
1154 | ++} |
1155 | ++ |
1156 | ++static void |
1157 | ++maybe_add_search_hit (LocateSearchData *sdata, |
1158 | ++ GFile *file, |
1159 | ++ GFileInfo *info) |
1160 | ++{ |
1161 | ++ guint64 atime; |
1162 | ++ guint64 mtime; |
1163 | ++ gdouble rank; |
1164 | ++ NautilusSearchHit *hit; |
1165 | ++ const gchar *display_name; |
1166 | ++ g_autofree gchar *uri = NULL; |
1167 | ++ g_autoptr (GDateTime) gmodified = NULL; |
1168 | ++ g_autoptr (GDateTime) gaccessed = NULL; |
1169 | ++ |
1170 | ++ if (g_file_info_get_is_backup (info) || g_file_info_get_is_hidden (info) || |
1171 | ++ !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) |
1172 | ++ return; |
1173 | ++ |
1174 | ++ atime = g_file_info_get_attribute_uint64 (info, "time::access"); |
1175 | ++ mtime = g_file_info_get_attribute_uint64 (info, "time::modified"); |
1176 | ++ |
1177 | ++ if (sdata->date_range != NULL) |
1178 | ++ { |
1179 | ++ NautilusQuerySearchType type; |
1180 | ++ GDateTime *initial_date; |
1181 | ++ GDateTime *end_date; |
1182 | ++ guint64 file_time; |
1183 | ++ |
1184 | ++ initial_date = g_ptr_array_index (sdata->date_range, 0); |
1185 | ++ end_date = g_ptr_array_index (sdata->date_range, 1); |
1186 | ++ type = nautilus_query_get_search_type (sdata->query); |
1187 | ++ |
1188 | ++ file_time = (type == NAUTILUS_QUERY_SEARCH_TYPE_LAST_ACCESS) ? |
1189 | ++ atime : mtime; |
1190 | ++ |
1191 | ++ if (!nautilus_file_date_in_between (file_time, initial_date, end_date)) |
1192 | ++ return; |
1193 | ++ } |
1194 | ++ |
1195 | ++ uri = g_file_get_uri (file); |
1196 | ++ display_name = g_file_info_get_display_name (info); |
1197 | ++ rank = nautilus_query_matches_string (sdata->query, display_name); |
1198 | ++ gaccessed = g_date_time_new_from_unix_local (atime); |
1199 | ++ gmodified = g_date_time_new_from_unix_local (mtime); |
1200 | ++ |
1201 | ++ hit = nautilus_search_hit_new (uri); |
1202 | ++ nautilus_search_hit_set_modification_time (hit, gmodified); |
1203 | ++ nautilus_search_hit_set_access_time (hit, gaccessed); |
1204 | ++ nautilus_search_hit_set_fts_rank (hit, rank); |
1205 | ++ |
1206 | ++ sdata->hits = g_list_prepend (sdata->hits, hit); |
1207 | ++} |
1208 | ++ |
1209 | ++static void |
1210 | ++path_info_callback (GObject *source_object, |
1211 | ++ GAsyncResult *res, |
1212 | ++ gpointer user_data) |
1213 | ++{ |
1214 | ++ LocateSearchData *sdata = user_data; |
1215 | ++ g_autoptr (GFile) file = G_FILE (source_object); |
1216 | ++ g_autoptr (GFileInfo) info = NULL; |
1217 | ++ g_autoptr (GError) error = NULL; |
1218 | ++ |
1219 | ++ info = g_file_query_info_finish (file, res, &error); |
1220 | ++ sdata->pending_ops--; |
1221 | ++ |
1222 | ++ if (!error) |
1223 | ++ { |
1224 | ++ maybe_add_search_hit (sdata, file, info); |
1225 | ++ } |
1226 | ++ else |
1227 | ++ { |
1228 | ++ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) |
1229 | ++ return; |
1230 | ++ |
1231 | ++ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) |
1232 | ++ g_debug ("Impossible to read locate file info: %s", error->message); |
1233 | ++ } |
1234 | ++ |
1235 | ++ maybe_submit_available_hits (sdata); |
1236 | ++} |
1237 | ++ |
1238 | ++static void |
1239 | ++check_path (LocateSearchData *sdata, |
1240 | ++ gchar *path) |
1241 | ++{ |
1242 | ++ NautilusSearchEngineLocate *self = sdata->locate; |
1243 | ++ |
1244 | ++ sdata->n_processed_paths++; |
1245 | ++ |
1246 | ++ if (g_str_has_prefix (path, sdata->query_path) && |
1247 | ++ g_strrstr (path, G_DIR_SEPARATOR_S ".") == NULL) |
1248 | ++ { |
1249 | ++ GFile *file; |
1250 | ++ const char *file_attribs = FILE_ATTRIBS; |
1251 | ++ |
1252 | ++ if (sdata->mime_types) |
1253 | ++ file_attribs = FILE_ATTRIBS "," \ |
1254 | ++ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE; |
1255 | ++ |
1256 | ++ file = g_file_new_for_path (path); |
1257 | ++ |
1258 | ++ sdata->pending_ops++; |
1259 | ++ g_file_query_info_async (file, file_attribs, G_FILE_QUERY_INFO_NONE, |
1260 | ++ G_PRIORITY_DEFAULT, self->cancellable, |
1261 | ++ path_info_callback, sdata); |
1262 | ++ } |
1263 | ++ else |
1264 | ++ { |
1265 | ++ maybe_submit_available_hits (sdata); |
1266 | ++ } |
1267 | ++} |
1268 | ++ |
1269 | ++static void |
1270 | ++read_line_callback (GObject *input_stream, |
1271 | ++ GAsyncResult *res, |
1272 | ++ gpointer user_data) |
1273 | ++{ |
1274 | ++ LocateSearchData *sdata = user_data; |
1275 | ++ NautilusSearchEngineLocate *self = sdata->locate; |
1276 | ++ GDataInputStream *data_input = G_DATA_INPUT_STREAM (input_stream); |
1277 | ++ g_autofree gchar *path = NULL; |
1278 | ++ g_autoptr (GError) error = NULL; |
1279 | ++ gsize length; |
1280 | ++ |
1281 | ++ path = g_data_input_stream_read_line_finish_utf8 (data_input, res, |
1282 | ++ &length, &error); |
1283 | ++ sdata->pending_ops--; |
1284 | ++ |
1285 | ++ if (path != NULL) |
1286 | ++ { |
1287 | ++ check_path (sdata, path); |
1288 | ++ sdata->pending_ops++; |
1289 | ++ g_data_input_stream_read_line_async (data_input, G_PRIORITY_DEFAULT, |
1290 | ++ self->cancellable, |
1291 | ++ read_line_callback, sdata); |
1292 | ++ } |
1293 | ++ else |
1294 | ++ { |
1295 | ++ if (error) |
1296 | ++ { |
1297 | ++ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) |
1298 | ++ sdata->pending_ops = 0; |
1299 | ++ else |
1300 | ++ g_warning ("Impossible to read locate output path: %s", |
1301 | ++ error->message); |
1302 | ++ } |
1303 | ++ |
1304 | ++ sdata->completed = TRUE; |
1305 | ++ maybe_submit_available_hits (sdata); |
1306 | ++ } |
1307 | ++} |
1308 | ++ |
1309 | ++static void |
1310 | ++search_string_rewrite_with_wildcards (gchar **query) |
1311 | ++{ |
1312 | ++ gsize query_len; |
1313 | ++ gsize rewritten_len; |
1314 | ++ gchar *arg; |
1315 | ++ gchar *query_text; |
1316 | ++ gboolean needs_leading; |
1317 | ++ gboolean needs_trailing; |
1318 | ++ |
1319 | ++ g_return_if_fail (*query); |
1320 | ++ |
1321 | ++ query_text = *query; |
1322 | ++ query_len = strlen (query_text); |
1323 | ++ rewritten_len = query_len; |
1324 | ++ needs_leading = FALSE; |
1325 | ++ needs_trailing = FALSE; |
1326 | ++ |
1327 | ++ if (query_text[0] != '*') |
1328 | ++ { |
1329 | ++ needs_leading = TRUE; |
1330 | ++ rewritten_len++; |
1331 | ++ } |
1332 | ++ |
1333 | ++ if (query_text[query_len-1] != '*' && (!needs_leading || query_len > 0)) |
1334 | ++ { |
1335 | ++ needs_trailing = TRUE; |
1336 | ++ rewritten_len++; |
1337 | ++ } |
1338 | ++ |
1339 | ++ if (!needs_leading && !needs_trailing) |
1340 | ++ return; |
1341 | ++ |
1342 | ++ arg = g_malloc0 (rewritten_len + 1); |
1343 | ++ *query = arg; |
1344 | ++ |
1345 | ++ if (needs_trailing) |
1346 | ++ arg[rewritten_len-1] = '*'; |
1347 | ++ |
1348 | ++ if (needs_leading) |
1349 | ++ { |
1350 | ++ arg[0] = '*'; |
1351 | ++ arg += 1; |
1352 | ++ } |
1353 | ++ |
1354 | ++ memcpy (arg, query_text, query_len); |
1355 | ++ |
1356 | ++ g_free (query_text); |
1357 | ++} |
1358 | ++ |
1359 | ++static void |
1360 | ++search_string_replace_separators (gchar **query) |
1361 | ++{ |
1362 | ++ g_auto (GStrv) words = NULL; |
1363 | ++ g_autofree gchar *query_text = *query; |
1364 | ++ |
1365 | ++ /* Using generated WORD_SEPARATORS, it uses this rule: |
1366 | ++ * gsize i; |
1367 | ++ * gchar c; |
1368 | ++ * gchar separators[0xff] = {0}; |
1369 | ++ * for (c = 0, i = 0; c < sizeof (separators); ++c) |
1370 | ++ * { |
1371 | ++ * if (g_ascii_isspace (c) || (g_ascii_ispunct (c) && c != '@')) |
1372 | ++ * separators[i++] = c; |
1373 | ++ * } |
1374 | ++ */ |
1375 | ++ |
1376 | ++ words = g_strsplit_set (query_text, WORD_SEPARATORS, -1); |
1377 | ++ *query = g_strjoinv ("*", words); |
1378 | ++} |
1379 | ++ |
1380 | ++static void |
1381 | ++nautilus_search_engine_locate_start (NautilusSearchProvider *provider) |
1382 | ++{ |
1383 | ++ NautilusSearchEngineLocate *self = NAUTILUS_SEARCH_ENGINE_LOCATE (provider); |
1384 | ++ GInputStream *output; |
1385 | ++ GDataInputStream *input; |
1386 | ++ LocateSearchData *sdata; |
1387 | ++ g_autoptr (GError) error = NULL; |
1388 | ++ g_autoptr (GFile) query_location = NULL; |
1389 | ++ g_autoptr (GPtrArray) args = NULL; |
1390 | ++ char *query_text; |
1391 | ++ |
1392 | ++ g_return_if_fail (self->query); |
1393 | ++ g_return_if_fail (self->cancellable == NULL || |
1394 | ++ !g_cancellable_is_cancelled (self->cancellable)); |
1395 | ++ |
1396 | ++ sdata = g_new0 (LocateSearchData, 1); |
1397 | ++ sdata->locate = g_object_ref (self); |
1398 | ++ |
1399 | ++ if (!(self->locate_features & LOCATE_INSTALLED)) |
1400 | ++ { |
1401 | ++ g_idle_add ((GSourceFunc) submit_results, sdata); |
1402 | ++ return; |
1403 | ++ } |
1404 | ++ |
1405 | ++ args = g_ptr_array_new_full (3, g_free); |
1406 | ++ g_ptr_array_add (args, g_strdup (LOCATE_BINARY)); |
1407 | ++ |
1408 | ++ if (self->locate_features & LOCATE_SUPPORTS_IGNORE_CASE) |
1409 | ++ g_ptr_array_add (args, g_strdup ("--ignore-case")); |
1410 | ++ |
1411 | ++ if (self->locate_features & LOCATE_SUPPORTS_IGNORE_SEPARATORS) |
1412 | ++ g_ptr_array_add (args, g_strdup ("--ignore-spaces")); |
1413 | ++ |
1414 | ++ if (self->locate_features & LOCATE_SUPPORTS_BASENAME_MATCHING) |
1415 | ++ g_ptr_array_add (args, g_strdup ("--basename")); |
1416 | ++ |
1417 | ++ if (self->locate_features & LOCATE_SUPPORTS_TRANSLITERATION) |
1418 | ++ g_ptr_array_add (args, g_strdup ("--transliterate")); |
1419 | ++ |
1420 | ++ query_text = nautilus_query_get_text (self->query); |
1421 | ++ |
1422 | ++ if (!(self->locate_features & LOCATE_SUPPORTS_IGNORE_SEPARATORS)) |
1423 | ++ search_string_replace_separators (&query_text); |
1424 | ++ |
1425 | ++ search_string_rewrite_with_wildcards (&query_text); |
1426 | ++ |
1427 | ++ g_ptr_array_add (args, query_text); |
1428 | ++ g_ptr_array_add (args, NULL); |
1429 | ++ |
1430 | ++ g_autoptr (GSubprocess) proc = NULL; |
1431 | ++ proc = g_subprocess_newv ((const gchar * const *) args->pdata, |
1432 | ++ G_SUBPROCESS_FLAGS_STDOUT_PIPE, &error); |
1433 | ++ |
1434 | ++ if (error) |
1435 | ++ { |
1436 | ++ g_warning ("Can't start locate process: %s", error->message); |
1437 | ++ return; |
1438 | ++ } |
1439 | ++ |
1440 | ++ query_location = nautilus_query_get_location (self->query); |
1441 | ++ |
1442 | ++ sdata->query = g_object_ref (self->query); |
1443 | ++ sdata->date_range = nautilus_query_get_date_range (self->query); |
1444 | ++ sdata->mime_types = nautilus_query_get_mime_types (self->query); |
1445 | ++ sdata->query_path = g_file_get_path (query_location); |
1446 | ++ |
1447 | ++ output = g_subprocess_get_stdout_pipe (proc); |
1448 | ++ input = g_data_input_stream_new (output); |
1449 | ++ |
1450 | ++ self->locate_process = g_steal_pointer (&proc); |
1451 | ++ self->cancellable = g_cancellable_new (); |
1452 | ++ |
1453 | ++ g_object_notify (G_OBJECT (provider), "running"); |
1454 | ++ |
1455 | ++ g_object_set_data (G_OBJECT (self->locate_process), "search-data", sdata); |
1456 | ++ g_object_set_data_full (G_OBJECT (self->locate_process), "input-stream", |
1457 | ++ input, g_object_unref); |
1458 | ++ |
1459 | ++ sdata->pending_ops++; |
1460 | ++ g_data_input_stream_read_line_async (input, G_PRIORITY_DEFAULT, |
1461 | ++ self->cancellable, |
1462 | ++ read_line_callback, sdata); |
1463 | ++} |
1464 | ++ |
1465 | ++static void |
1466 | ++nautilus_search_engine_locate_stop (NautilusSearchProvider *provider) |
1467 | ++{ |
1468 | ++ NautilusSearchEngineLocate *self = NAUTILUS_SEARCH_ENGINE_LOCATE (provider); |
1469 | ++ |
1470 | ++ if (self->locate_process != NULL) |
1471 | ++ { |
1472 | ++ DEBUG ("Locate engine stop"); |
1473 | ++ g_cancellable_cancel (self->cancellable); |
1474 | ++ |
1475 | ++ g_subprocess_force_exit (self->locate_process); |
1476 | ++ } |
1477 | ++} |
1478 | ++ |
1479 | ++static void |
1480 | ++nautilus_search_engine_locate_set_query (NautilusSearchProvider *provider, |
1481 | ++ NautilusQuery *query) |
1482 | ++{ |
1483 | ++ NautilusSearchEngineLocate *self = NAUTILUS_SEARCH_ENGINE_LOCATE (provider); |
1484 | ++ |
1485 | ++ g_clear_object (&self->query); |
1486 | ++ self->query = g_object_ref (query); |
1487 | ++} |
1488 | ++ |
1489 | ++static gboolean |
1490 | ++nautilus_search_engine_locate_is_running (NautilusSearchProvider *provider) |
1491 | ++{ |
1492 | ++ NautilusSearchEngineLocate *self = NAUTILUS_SEARCH_ENGINE_LOCATE (provider); |
1493 | ++ |
1494 | ++ return self->locate_process != NULL; |
1495 | ++} |
1496 | ++ |
1497 | ++static void |
1498 | ++check_locate_features (NautilusSearchEngineLocate *self) |
1499 | ++{ |
1500 | ++ gint exit_status; |
1501 | ++ g_autofree gchar *output = NULL; |
1502 | ++ g_autoptr (GError) error = NULL; |
1503 | ++ |
1504 | ++ g_spawn_command_line_sync (LOCATE_BINARY " -h", &output, NULL, |
1505 | ++ &exit_status, &error); |
1506 | ++ |
1507 | ++ if (error) |
1508 | ++ { |
1509 | ++ g_warning ("locate can't be properly inspected for supported features: " |
1510 | ++ "%s", error->message); |
1511 | ++ return; |
1512 | ++ } |
1513 | ++ |
1514 | ++ self->locate_features |= LOCATE_INSTALLED; |
1515 | ++ |
1516 | ++ if (g_strrstr (output, "--basename")) |
1517 | ++ self->locate_features |= LOCATE_SUPPORTS_BASENAME_MATCHING; |
1518 | ++ |
1519 | ++ if (g_strrstr (output, "--transliterate")) |
1520 | ++ self->locate_features |= LOCATE_SUPPORTS_TRANSLITERATION; |
1521 | ++ |
1522 | ++ if (g_strrstr (output, "--ignore-case")) |
1523 | ++ self->locate_features |= LOCATE_SUPPORTS_IGNORE_CASE; |
1524 | ++ |
1525 | ++ if (g_strrstr (output, "--ignore-spaces")) |
1526 | ++ self->locate_features |= LOCATE_SUPPORTS_IGNORE_SEPARATORS; |
1527 | ++} |
1528 | ++ |
1529 | ++static void |
1530 | ++nautilus_search_engine_locate_get_property (GObject *object, |
1531 | ++ guint prop_id, |
1532 | ++ GValue *value, |
1533 | ++ GParamSpec *pspec) |
1534 | ++{ |
1535 | ++ NautilusSearchProvider *provider = NAUTILUS_SEARCH_PROVIDER (object); |
1536 | ++ |
1537 | ++ switch (prop_id) |
1538 | ++ { |
1539 | ++ case PROP_RUNNING: |
1540 | ++ { |
1541 | ++ gboolean running; |
1542 | ++ running = nautilus_search_engine_locate_is_running (provider); |
1543 | ++ g_value_set_boolean (value, running); |
1544 | ++ } |
1545 | ++ break; |
1546 | ++ |
1547 | ++ default: |
1548 | ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
1549 | ++ } |
1550 | ++} |
1551 | ++ |
1552 | ++static void |
1553 | ++nautilus_search_provider_init (NautilusSearchProviderInterface *iface) |
1554 | ++{ |
1555 | ++ iface->set_query = nautilus_search_engine_locate_set_query; |
1556 | ++ iface->start = nautilus_search_engine_locate_start; |
1557 | ++ iface->stop = nautilus_search_engine_locate_stop; |
1558 | ++ iface->is_running = nautilus_search_engine_locate_is_running; |
1559 | ++} |
1560 | ++ |
1561 | ++static void |
1562 | ++nautilus_search_engine_locate_class_init (NautilusSearchEngineLocateClass *klass) |
1563 | ++{ |
1564 | ++ GObjectClass *object_class = G_OBJECT_CLASS (klass); |
1565 | ++ |
1566 | ++ object_class->finalize = nautilus_search_engine_locate_finalize; |
1567 | ++ object_class->get_property = nautilus_search_engine_locate_get_property; |
1568 | ++ |
1569 | ++ g_object_class_override_property (object_class, PROP_RUNNING, "running"); |
1570 | ++} |
1571 | ++ |
1572 | ++static void |
1573 | ++nautilus_search_engine_locate_init (NautilusSearchEngineLocate *self) |
1574 | ++{ |
1575 | ++ check_locate_features (self); |
1576 | ++} |
1577 | +diff --git a/src/nautilus-search-engine-locate.h b/src/nautilus-search-engine-locate.h |
1578 | +new file mode 100644 |
1579 | +index 0000000..ac5e3fc |
1580 | +--- /dev/null |
1581 | ++++ b/src/nautilus-search-engine-locate.h |
1582 | +@@ -0,0 +1,37 @@ |
1583 | ++/* |
1584 | ++ * Copyright (C) 2018 Canonical Ltd |
1585 | ++ * |
1586 | ++ * Nautilus is free software; you can redistribute it and/or |
1587 | ++ * modify it under the terms of the GNU General Public License as |
1588 | ++ * published by the Free Software Foundation; either version 2 of the |
1589 | ++ * License, or (at your option) any later version. |
1590 | ++ * |
1591 | ++ * Nautilus is distributed in the hope that it will be useful, |
1592 | ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1593 | ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1594 | ++ * General Public License for more details. |
1595 | ++ * |
1596 | ++ * You should have received a copy of the GNU General Public |
1597 | ++ * License along with this program; see the file COPYING. If not, |
1598 | ++ * see <http://www.gnu.org/licenses/>. |
1599 | ++ * |
1600 | ++ * Author: Marco Trevisan <marco.trevisan@canonical.com> |
1601 | ++ * |
1602 | ++ */ |
1603 | ++ |
1604 | ++#ifndef __NAUTILUS_SEARCH_ENGINE_LOCATE_H__ |
1605 | ++#define __NAUTILUS_SEARCH_ENGINE_LOCATE_H__ |
1606 | ++ |
1607 | ++#include <glib-object.h> |
1608 | ++ |
1609 | ++G_BEGIN_DECLS |
1610 | ++ |
1611 | ++#define NAUTILUS_TYPE_SEARCH_ENGINE_LOCATE (nautilus_search_engine_locate_get_type ()) |
1612 | ++ |
1613 | ++G_DECLARE_FINAL_TYPE (NautilusSearchEngineLocate, nautilus_search_engine_locate, NAUTILUS, SEARCH_ENGINE_LOCATE, GObject); |
1614 | ++ |
1615 | ++NautilusSearchEngineLocate *nautilus_search_engine_locate_new (void); |
1616 | ++ |
1617 | ++G_END_DECLS |
1618 | ++ |
1619 | ++#endif /* __NAUTILUS_SEARCH_ENGINE_LOCATE_H__ */ |
1620 | +diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c |
1621 | +index aef91b7..bf0e85d 100644 |
1622 | +--- a/src/nautilus-search-engine.c |
1623 | ++++ b/src/nautilus-search-engine.c |
1624 | +@@ -25,6 +25,7 @@ |
1625 | + #include "nautilus-search-provider.h" |
1626 | + #include "nautilus-search-engine.h" |
1627 | + #include "nautilus-search-engine-recent.h" |
1628 | ++#include "nautilus-search-engine-locate.h" |
1629 | + #include "nautilus-search-engine-simple.h" |
1630 | + #include "nautilus-search-engine-model.h" |
1631 | + #define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH |
1632 | +@@ -35,6 +36,7 @@ typedef struct |
1633 | + { |
1634 | + NautilusSearchEngineTracker *tracker; |
1635 | + NautilusSearchEngineRecent *recent; |
1636 | ++ NautilusSearchEngineLocate *locate; |
1637 | + NautilusSearchEngineSimple *simple; |
1638 | + NautilusSearchEngineModel *model; |
1639 | + |
1640 | +@@ -77,6 +79,7 @@ nautilus_search_engine_set_query (NautilusSearchProvider *provider, |
1641 | + |
1642 | + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->tracker), query); |
1643 | + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->recent), query); |
1644 | ++ nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->locate), query); |
1645 | + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->model), query); |
1646 | + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->simple), query); |
1647 | + } |
1648 | +@@ -104,6 +107,9 @@ search_engine_start_real (NautilusSearchEngine *engine) |
1649 | + priv->providers_running++; |
1650 | + nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
1651 | + |
1652 | ++ priv->providers_running++; |
1653 | ++ nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->locate)); |
1654 | ++ |
1655 | + if (nautilus_search_engine_model_get_model (priv->model)) |
1656 | + { |
1657 | + nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->model)); |
1658 | +@@ -166,6 +172,7 @@ nautilus_search_engine_stop (NautilusSearchProvider *provider) |
1659 | + |
1660 | + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->tracker)); |
1661 | + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
1662 | ++ nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->locate)); |
1663 | + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->model)); |
1664 | + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->simple)); |
1665 | + |
1666 | +@@ -342,6 +349,7 @@ nautilus_search_engine_finalize (GObject *object) |
1667 | + |
1668 | + g_clear_object (&priv->tracker); |
1669 | + g_clear_object (&priv->recent); |
1670 | ++ g_clear_object (&priv->locate); |
1671 | + g_clear_object (&priv->model); |
1672 | + g_clear_object (&priv->simple); |
1673 | + |
1674 | +@@ -406,6 +414,9 @@ nautilus_search_engine_init (NautilusSearchEngine *engine) |
1675 | + |
1676 | + priv->recent = nautilus_search_engine_recent_new (); |
1677 | + connect_provider_signals (engine, NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
1678 | ++ |
1679 | ++ priv->locate = nautilus_search_engine_locate_new (); |
1680 | ++ connect_provider_signals (engine, NAUTILUS_SEARCH_PROVIDER (priv->locate)); |
1681 | + } |
1682 | + |
1683 | + NautilusSearchEngine * |
1684 | |
1685 | === modified file 'debian/patches/12_unity_launcher_support.patch' |
1686 | --- debian/patches/12_unity_launcher_support.patch 2018-03-24 20:06:53 +0000 |
1687 | +++ debian/patches/12_unity_launcher_support.patch 2018-04-12 23:13:34 +0000 |
1688 | @@ -1,16 +1,26 @@ |
1689 | +From: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
1690 | +Date: Thu, 12 Apr 2018 16:54:13 -0500 |
1691 | +Subject: _unity_launcher_support |
1692 | + |
1693 | --- |
1694 | - config.h.meson | 1 |
1695 | - meson.build | 8 ++ |
1696 | - meson_options.txt | 3 |
1697 | - src/meson.build | 8 ++ |
1698 | - src/nautilus-application.c | 8 ++ |
1699 | - src/nautilus-toolbar.c | 19 +++++ |
1700 | - src/unity-bookmarks-handler.c | 148 ++++++++++++++++++++++++++++++++++++++++ |
1701 | - src/unity-bookmarks-handler.h | 31 ++++++++ |
1702 | - src/unity-quicklist-handler.c | 154 ++++++++++++++++++++++++++++++++++++++++++ |
1703 | - src/unity-quicklist-handler.h | 72 +++++++++++++++++++ |
1704 | - 10 files changed, 452 insertions(+) |
1705 | + config.h.meson | 1 + |
1706 | + meson.build | 8 +++ |
1707 | + meson_options.txt | 4 ++ |
1708 | + src/meson.build | 10 +++ |
1709 | + src/nautilus-application.c | 8 +++ |
1710 | + src/nautilus-toolbar.c | 21 ++++++ |
1711 | + src/unity-bookmarks-handler.c | 147 +++++++++++++++++++++++++++++++++++++ |
1712 | + src/unity-bookmarks-handler.h | 31 ++++++++ |
1713 | + src/unity-quicklist-handler.c | 163 ++++++++++++++++++++++++++++++++++++++++++ |
1714 | + src/unity-quicklist-handler.h | 72 +++++++++++++++++++ |
1715 | + 10 files changed, 465 insertions(+) |
1716 | + create mode 100644 src/unity-bookmarks-handler.c |
1717 | + create mode 100644 src/unity-bookmarks-handler.h |
1718 | + create mode 100644 src/unity-quicklist-handler.c |
1719 | + create mode 100644 src/unity-quicklist-handler.h |
1720 | |
1721 | +diff --git a/config.h.meson b/config.h.meson |
1722 | +index 4f5cb58..9ddb88d 100644 |
1723 | --- a/config.h.meson |
1724 | +++ b/config.h.meson |
1725 | @@ -4,6 +4,7 @@ |
1726 | @@ -21,6 +31,8 @@ |
1727 | #mesondefine ENABLE_DESKTOP |
1728 | #mesondefine ENABLE_PACKAGEKIT |
1729 | #mesondefine LOCALEDIR |
1730 | +diff --git a/meson.build b/meson.build |
1731 | +index 18e645a..495101f 100644 |
1732 | --- a/meson.build |
1733 | +++ b/meson.build |
1734 | @@ -30,6 +30,8 @@ exempi_ver = '>=2.1.0' |
1735 | @@ -45,6 +57,8 @@ |
1736 | tracker_sparql = dependency ('tracker-sparql-2.0', required: false) |
1737 | if not tracker_sparql.found() |
1738 | tracker_sparql = dependency ('tracker-sparql-1.0') |
1739 | +diff --git a/meson_options.txt b/meson_options.txt |
1740 | +index c934dd8..2e4d0af 100644 |
1741 | --- a/meson_options.txt |
1742 | +++ b/meson_options.txt |
1743 | @@ -15,6 +15,10 @@ option ('enable-xmp', |
1744 | @@ -58,30 +72,29 @@ |
1745 | option ('enable-desktop', |
1746 | type: 'boolean', |
1747 | value: true) |
1748 | +diff --git a/src/meson.build b/src/meson.build |
1749 | +index cc08345..59703df 100644 |
1750 | --- a/src/meson.build |
1751 | +++ b/src/meson.build |
1752 | -@@ -254,6 +254,10 @@ libnautilus_sources = [ |
1753 | - 'nautilus-file-undo-operations.h', |
1754 | - 'nautilus-file-undo-manager.c', |
1755 | - 'nautilus-file-undo-manager.h', |
1756 | -+ 'unity-quicklist-handler.c', |
1757 | -+ 'unity-quicklist-handler.h', |
1758 | -+ 'unity-bookmarks-handler.c', |
1759 | -+ 'unity-bookmarks-handler.h', |
1760 | - 'nautilus-batch-rename-dialog.c', |
1761 | - 'nautilus-batch-rename-dialog.h', |
1762 | - 'nautilus-batch-rename-utilities.c', |
1763 | -@@ -284,6 +288,10 @@ if get_option ('enable-selinux') |
1764 | +@@ -285,6 +285,16 @@ if get_option ('enable-selinux') |
1765 | nautilus_deps += selinux |
1766 | endif |
1767 | |
1768 | +if get_option ('enable-unity') |
1769 | + nautilus_deps += [unity, dbusmenu] |
1770 | ++ libnautilus_sources += [ |
1771 | ++ 'unity-quicklist-handler.c', |
1772 | ++ 'unity-quicklist-handler.h', |
1773 | ++ 'unity-bookmarks-handler.c', |
1774 | ++ 'unity-bookmarks-handler.h' |
1775 | ++ ] |
1776 | +endif |
1777 | + |
1778 | if get_option ('enable-xmp') |
1779 | nautilus_deps += exempi |
1780 | endif |
1781 | +diff --git a/src/nautilus-application.c b/src/nautilus-application.c |
1782 | +index 98e6f35..ae19115 100644 |
1783 | --- a/src/nautilus-application.c |
1784 | +++ b/src/nautilus-application.c |
1785 | @@ -54,6 +54,10 @@ |
1786 | @@ -95,7 +108,7 @@ |
1787 | #include <sys/types.h> |
1788 | #include <sys/stat.h> |
1789 | #include <fcntl.h> |
1790 | -@@ -1275,6 +1279,10 @@ nautilus_application_startup (GApplicati |
1791 | +@@ -1301,6 +1305,10 @@ nautilus_application_startup (GApplication *app) |
1792 | nautilus_application_startup_common (self); |
1793 | |
1794 | nautilus_profile_end (NULL); |
1795 | @@ -106,6 +119,8 @@ |
1796 | } |
1797 | |
1798 | static gboolean |
1799 | +diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c |
1800 | +index a6d01b8..2b47275 100644 |
1801 | --- a/src/nautilus-toolbar.c |
1802 | +++ b/src/nautilus-toolbar.c |
1803 | @@ -40,6 +40,10 @@ |
1804 | @@ -119,15 +134,17 @@ |
1805 | #include <glib/gi18n.h> |
1806 | #include <math.h> |
1807 | |
1808 | -@@ -99,6 +103,7 @@ struct _NautilusToolbar |
1809 | +@@ -100,6 +104,9 @@ struct _NautilusToolbar |
1810 | NautilusWindowSlot *active_slot; |
1811 | GBinding *icon_binding; |
1812 | GBinding *view_widget_binding; |
1813 | ++#if HAVE_UNITY |
1814 | + UnityLauncherEntry *ulauncher; |
1815 | ++#endif |
1816 | }; |
1817 | |
1818 | enum |
1819 | -@@ -388,6 +393,9 @@ on_remove_finished_operations_timeout (N |
1820 | +@@ -389,6 +396,9 @@ on_remove_finished_operations_timeout (NautilusToolbar *self) |
1821 | { |
1822 | gtk_revealer_set_reveal_child (GTK_REVEALER (self->operations_revealer), |
1823 | FALSE); |
1824 | @@ -137,7 +154,7 @@ |
1825 | } |
1826 | else |
1827 | { |
1828 | -@@ -574,6 +582,10 @@ update_operations (NautilusToolbar *self |
1829 | +@@ -575,6 +585,10 @@ update_operations (NautilusToolbar *self) |
1830 | TRUE); |
1831 | gtk_widget_queue_draw (self->operations_icon); |
1832 | |
1833 | @@ -148,7 +165,7 @@ |
1834 | /* Show the popover at start to increase visibility. |
1835 | * Check whether the toolbar is visible or not before showing the |
1836 | * popover. This can happens if the window has the disables-chrome |
1837 | -@@ -741,6 +753,10 @@ on_operations_icon_draw (GtkWidget |
1838 | +@@ -742,6 +756,10 @@ on_operations_icon_draw (GtkWidget *widget, |
1839 | } |
1840 | |
1841 | |
1842 | @@ -159,7 +176,7 @@ |
1843 | width = gtk_widget_get_allocated_width (widget); |
1844 | height = gtk_widget_get_allocated_height (widget); |
1845 | |
1846 | -@@ -895,6 +911,9 @@ nautilus_toolbar_init (NautilusToolbar * |
1847 | +@@ -943,6 +961,9 @@ nautilus_toolbar_init (NautilusToolbar *self) |
1848 | self->location_entry); |
1849 | |
1850 | self->progress_manager = nautilus_progress_info_manager_dup_singleton (); |
1851 | @@ -169,6 +186,9 @@ |
1852 | g_signal_connect (self->progress_manager, "new-progress-info", |
1853 | G_CALLBACK (on_new_progress_info), self); |
1854 | g_signal_connect (self->progress_manager, "has-viewers-changed", |
1855 | +diff --git a/src/unity-bookmarks-handler.c b/src/unity-bookmarks-handler.c |
1856 | +new file mode 100644 |
1857 | +index 0000000..5c1a234 |
1858 | --- /dev/null |
1859 | +++ b/src/unity-bookmarks-handler.c |
1860 | @@ -0,0 +1,147 @@ |
1861 | @@ -319,6 +339,9 @@ |
1862 | + g_signal_connect (bookmarks, "changed", |
1863 | + G_CALLBACK (unity_bookmarks_handler_refresh_bookmarks), 0); |
1864 | +} |
1865 | +diff --git a/src/unity-bookmarks-handler.h b/src/unity-bookmarks-handler.h |
1866 | +new file mode 100644 |
1867 | +index 0000000..a887648 |
1868 | --- /dev/null |
1869 | +++ b/src/unity-bookmarks-handler.h |
1870 | @@ -0,0 +1,31 @@ |
1871 | @@ -353,6 +376,9 @@ |
1872 | +void unity_bookmarks_handler_initialize (void); |
1873 | + |
1874 | +#endif /* __UNITY_BOOKMARKS_HANDLER_H__*/ |
1875 | +diff --git a/src/unity-quicklist-handler.c b/src/unity-quicklist-handler.c |
1876 | +new file mode 100644 |
1877 | +index 0000000..e11da55 |
1878 | --- /dev/null |
1879 | +++ b/src/unity-quicklist-handler.c |
1880 | @@ -0,0 +1,163 @@ |
1881 | @@ -519,6 +545,9 @@ |
1882 | +{ |
1883 | + return g_object_new (UNITY_TYPE_QUICKLIST_HANDLER, NULL); |
1884 | +} |
1885 | +diff --git a/src/unity-quicklist-handler.h b/src/unity-quicklist-handler.h |
1886 | +new file mode 100644 |
1887 | +index 0000000..8ffbb06 |
1888 | --- /dev/null |
1889 | +++ b/src/unity-quicklist-handler.h |
1890 | @@ -0,0 +1,72 @@ |
1891 | |
1892 | === removed file 'debian/patches/directory-update-recent-files-manager-on-rename-or-f.patch' |
1893 | --- debian/patches/directory-update-recent-files-manager-on-rename-or-f.patch 2018-02-23 15:14:39 +0000 |
1894 | +++ debian/patches/directory-update-recent-files-manager-on-rename-or-f.patch 1970-01-01 00:00:00 +0000 |
1895 | @@ -1,208 +0,0 @@ |
1896 | -From 1a5a391ca1a4e6982e0fd973cb65b9e1275cec73 Mon Sep 17 00:00:00 2001 |
1897 | -From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net> |
1898 | -Date: Thu, 22 Feb 2018 05:20:36 +0100 |
1899 | -Subject: [PATCH 2/2] directory: update recent files manager on rename or file |
1900 | - move |
1901 | - |
1902 | -When files have been moved or renamed nautilus should inform |
1903 | -recent manager about this change for the files that |
1904 | -are listed there. |
1905 | ---- |
1906 | - src/nautilus-directory-private.h | 4 ++ |
1907 | - src/nautilus-directory.c | 110 +++++++++++++++++++++++++++++++++++++++ |
1908 | - src/nautilus-file.c | 9 ++++ |
1909 | - 3 files changed, 123 insertions(+) |
1910 | - |
1911 | -diff --git a/src/nautilus-directory-private.h b/src/nautilus-directory-private.h |
1912 | -index dae1b96ce..82283f69e 100644 |
1913 | ---- a/src/nautilus-directory-private.h |
1914 | -+++ b/src/nautilus-directory-private.h |
1915 | -@@ -217,6 +217,10 @@ void nautilus_directory_end_file_name_change (NautilusD |
1916 | - GList *node); |
1917 | - void nautilus_directory_moved (const char *from_uri, |
1918 | - const char *to_uri); |
1919 | -+void nautilus_directory_recent_update (const char *from_uri, |
1920 | -+ const char *to_uri, |
1921 | -+ const char *old_display_name, |
1922 | -+ const char *new_display_name); |
1923 | - /* Interface to the work queue. */ |
1924 | - |
1925 | - void nautilus_directory_add_file_to_work_queue (NautilusDirectory *directory, |
1926 | -diff --git a/src/nautilus-directory.c b/src/nautilus-directory.c |
1927 | -index ad3bb03db..b2b52752b 100644 |
1928 | ---- a/src/nautilus-directory.c |
1929 | -+++ b/src/nautilus-directory.c |
1930 | -@@ -1549,6 +1549,8 @@ nautilus_directory_notify_files_moved (GList *file_pairs) |
1931 | - pair = p->data; |
1932 | - from_location = pair->from; |
1933 | - to_location = pair->to; |
1934 | -+ g_autofree char *from_uri = g_file_get_uri (from_location); |
1935 | -+ g_autofree char *to_uri = g_file_get_uri (to_location); |
1936 | - |
1937 | - /* Handle overwriting a file. */ |
1938 | - file = nautilus_file_get_existing (to_location); |
1939 | -@@ -1626,6 +1628,8 @@ nautilus_directory_notify_files_moved (GList *file_pairs) |
1940 | - /* Unref each file once to balance out nautilus_file_get_by_uri. */ |
1941 | - unref_list = g_list_prepend (unref_list, file); |
1942 | - } |
1943 | -+ |
1944 | -+ nautilus_directory_recent_update (from_uri, to_uri, NULL, NULL); |
1945 | - } |
1946 | - |
1947 | - /* Now send out the changed and added signals for existing file objects. */ |
1948 | -@@ -1710,6 +1714,112 @@ nautilus_directory_schedule_position_set (GList *position_setting_list) |
1949 | - } |
1950 | - } |
1951 | - |
1952 | -+void |
1953 | -+nautilus_directory_recent_update (const char *old_uri, |
1954 | -+ const char *new_uri, |
1955 | -+ const char *old_display_name, |
1956 | -+ const char *new_dispaly_name) |
1957 | -+{ |
1958 | -+ GtkRecentManager *recent_manager = gtk_recent_manager_get_default (); |
1959 | -+ NautilusFile *file; |
1960 | -+ NautilusFile *existing_file; |
1961 | -+ |
1962 | -+ if (!new_uri || !old_uri) |
1963 | -+ return; |
1964 | -+ |
1965 | -+ existing_file = nautilus_file_get_existing_by_uri (new_uri); |
1966 | -+ |
1967 | -+ if (existing_file) |
1968 | -+ file = g_object_ref (existing_file); |
1969 | -+ else |
1970 | -+ file = nautilus_file_get_by_uri (new_uri); |
1971 | -+ |
1972 | -+ if (nautilus_file_is_directory (file)) |
1973 | -+ { |
1974 | -+ GList *recent_items, *l; |
1975 | -+ |
1976 | -+ recent_items = gtk_recent_manager_get_items (recent_manager); |
1977 | -+ |
1978 | -+ for (l = recent_items; l; l = l->next) |
1979 | -+ { |
1980 | -+ GtkRecentInfo *info = l->data; |
1981 | -+ const char *item_uri = gtk_recent_info_get_uri (info); |
1982 | -+ |
1983 | -+ if (g_str_has_prefix (item_uri, old_uri)) |
1984 | -+ { |
1985 | -+ const char *relative_path = item_uri + strlen (old_uri); |
1986 | -+ g_autofree char *new_item_uri = NULL; |
1987 | -+ |
1988 | -+ new_item_uri = g_build_filename (new_uri, relative_path, NULL); |
1989 | -+ |
1990 | -+ gtk_recent_manager_move_item (recent_manager, |
1991 | -+ item_uri, new_item_uri, NULL); |
1992 | -+ } |
1993 | -+ } |
1994 | -+ |
1995 | -+ g_list_free_full (recent_items, (GDestroyNotify) gtk_recent_info_unref); |
1996 | -+ } |
1997 | -+ else |
1998 | -+ { |
1999 | -+ GtkRecentInfo *old_recent = |
2000 | -+ gtk_recent_manager_lookup_item (recent_manager, old_uri, NULL); |
2001 | -+ |
2002 | -+ if (old_recent) |
2003 | -+ { |
2004 | -+ gboolean recreated = FALSE; |
2005 | -+ |
2006 | -+ if ((new_dispaly_name != NULL && old_display_name == NULL) || |
2007 | -+ (g_strcmp0 (old_display_name, new_dispaly_name) != 0 && |
2008 | -+ g_strcmp0 (old_display_name, |
2009 | -+ gtk_recent_info_get_display_name (old_recent)) == 0)) |
2010 | -+ { |
2011 | -+ /* If old display name, matches the one in the recent file |
2012 | -+ * We can't just move it, but we need to recreate the |
2013 | -+ * GtkRecentInfo |
2014 | -+ */ |
2015 | -+ GtkRecentData recent_data = { |
2016 | -+ .display_name = (char *) new_dispaly_name, |
2017 | -+ .description = (char *) gtk_recent_info_get_description (old_recent), |
2018 | -+ .mime_type = (char *) gtk_recent_info_get_mime_type (old_recent), |
2019 | -+ .app_name = gtk_recent_info_last_application (old_recent), |
2020 | -+ .groups = gtk_recent_info_get_groups (old_recent, NULL), |
2021 | -+ .is_private = gtk_recent_info_get_private_hint (old_recent), |
2022 | -+ }; |
2023 | -+ |
2024 | -+ if (recent_data.app_name) |
2025 | -+ { |
2026 | -+ gtk_recent_info_get_application_info (old_recent, |
2027 | -+ recent_data.app_name, |
2028 | -+ (const char **) |
2029 | -+ &(recent_data.app_exec), |
2030 | -+ NULL, NULL); |
2031 | -+ } |
2032 | -+ |
2033 | -+ if (gtk_recent_manager_add_full (recent_manager, |
2034 | -+ new_uri, |
2035 | -+ &recent_data)) |
2036 | -+ { |
2037 | -+ recreated = gtk_recent_manager_remove_item (recent_manager, |
2038 | -+ old_uri, |
2039 | -+ NULL); |
2040 | -+ } |
2041 | -+ } |
2042 | -+ |
2043 | -+ if (!recreated) |
2044 | -+ { |
2045 | -+ gtk_recent_manager_move_item (recent_manager, |
2046 | -+ old_uri, new_uri, NULL); |
2047 | -+ } |
2048 | -+ } |
2049 | -+ else |
2050 | -+ { |
2051 | -+ gtk_recent_manager_remove_item (recent_manager, old_uri, NULL); |
2052 | -+ } |
2053 | -+ } |
2054 | -+ |
2055 | -+ g_object_unref (file); |
2056 | -+} |
2057 | -+ |
2058 | - gboolean |
2059 | - nautilus_directory_contains_file (NautilusDirectory *directory, |
2060 | - NautilusFile *file) |
2061 | -diff --git a/src/nautilus-file.c b/src/nautilus-file.c |
2062 | -index c8f918969..7d4e85ee2 100644 |
2063 | ---- a/src/nautilus-file.c |
2064 | -+++ b/src/nautilus-file.c |
2065 | -@@ -1957,6 +1957,8 @@ rename_get_info_callback (GObject *source_object, |
2066 | - NautilusFile *existing_file; |
2067 | - char *old_uri; |
2068 | - char *new_uri; |
2069 | -+ char *new_display_name; |
2070 | -+ char *old_display_name; |
2071 | - const char *new_name; |
2072 | - GFileInfo *new_info; |
2073 | - GError *error; |
2074 | -@@ -1983,10 +1985,12 @@ rename_get_info_callback (GObject *source_object, |
2075 | - } |
2076 | - |
2077 | - old_uri = nautilus_file_get_uri (op->file); |
2078 | -+ old_display_name = nautilus_file_get_display_name (op->file); |
2079 | - |
2080 | - update_info_and_name (op->file, new_info); |
2081 | - |
2082 | - new_uri = nautilus_file_get_uri (op->file); |
2083 | -+ new_display_name = nautilus_file_get_display_name (op->file); |
2084 | - |
2085 | - /* Send event to Zeitgeist */ |
2086 | - ZeitgeistLog *log = zeitgeist_log_get_default (); |
2087 | -@@ -2011,8 +2015,13 @@ rename_get_info_callback (GObject *source_object, |
2088 | - g_free (origin); |
2089 | - |
2090 | - nautilus_directory_moved (old_uri, new_uri); |
2091 | -+ nautilus_directory_recent_update (old_uri, new_uri, |
2092 | -+ old_display_name, new_display_name); |
2093 | -+ |
2094 | - g_free (new_uri); |
2095 | - g_free (old_uri); |
2096 | -+ g_free (new_display_name); |
2097 | -+ g_free (old_display_name); |
2098 | - |
2099 | - /* the rename could have affected the display name if e.g. |
2100 | - * we're in a vfolder where the name comes from a desktop file |
2101 | --- |
2102 | -2.15.1 |
2103 | - |
2104 | |
2105 | === removed file 'debian/patches/search-engine-add-a-recent-search-engine-listing-Gtk.patch' |
2106 | --- debian/patches/search-engine-add-a-recent-search-engine-listing-Gtk.patch 2018-03-02 17:39:58 +0000 |
2107 | +++ debian/patches/search-engine-add-a-recent-search-engine-listing-Gtk.patch 1970-01-01 00:00:00 +0000 |
2108 | @@ -1,429 +0,0 @@ |
2109 | -From 3f4cb4ada813d115a271138b8ae6c16132732446 Mon Sep 17 00:00:00 2001 |
2110 | -From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net> |
2111 | -Date: Wed, 21 Feb 2018 17:05:51 +0100 |
2112 | -Subject: [PATCH 1/2] search-engine: add a recent-search-engine listing |
2113 | - GtkRecentManager stuff |
2114 | - |
2115 | -Using GtkRecent items as search engine source in nautilus |
2116 | ---- |
2117 | - src/meson.build | 2 + |
2118 | - src/nautilus-search-engine-recent.c | 283 ++++++++++++++++++++++++++++++++++++ |
2119 | - src/nautilus-search-engine-recent.h | 37 +++++ |
2120 | - src/nautilus-search-engine.c | 11 ++ |
2121 | - 4 files changed, 333 insertions(+) |
2122 | - create mode 100644 src/nautilus-search-engine-recent.c |
2123 | - create mode 100644 src/nautilus-search-engine-recent.h |
2124 | - |
2125 | -diff --git a/src/meson.build b/src/meson.build |
2126 | -index 0c0833ee2..91ad1f704 100644 |
2127 | ---- a/src/meson.build |
2128 | -+++ b/src/meson.build |
2129 | -@@ -228,6 +228,8 @@ libnautilus_sources = [ |
2130 | - 'nautilus-search-engine.h', |
2131 | - 'nautilus-search-engine-model.c', |
2132 | - 'nautilus-search-engine-model.h', |
2133 | -+ 'nautilus-search-engine-recent.c', |
2134 | -+ 'nautilus-search-engine-recent.h', |
2135 | - 'nautilus-search-engine-simple.c', |
2136 | - 'nautilus-search-engine-simple.h', |
2137 | - 'nautilus-search-hit.c', |
2138 | -diff --git a/src/nautilus-search-engine-recent.c b/src/nautilus-search-engine-recent.c |
2139 | -new file mode 100644 |
2140 | -index 000000000..517e9b705 |
2141 | ---- /dev/null |
2142 | -+++ b/src/nautilus-search-engine-recent.c |
2143 | -@@ -0,0 +1,284 @@ |
2144 | -+/* |
2145 | -+ * Copyright (C) 2018 Canonical Ltd |
2146 | -+ * |
2147 | -+ * Nautilus is free software; you can redistribute it and/or |
2148 | -+ * modify it under the terms of the GNU General Public License as |
2149 | -+ * published by the Free Software Foundation; either version 2 of the |
2150 | -+ * License, or (at your option) any later version. |
2151 | -+ * |
2152 | -+ * Nautilus is distributed in the hope that it will be useful, |
2153 | -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2154 | -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2155 | -+ * General Public License for more details. |
2156 | -+ * |
2157 | -+ * You should have received a copy of the GNU General Public |
2158 | -+ * License along with this program; see the file COPYING. If not, |
2159 | -+ * see <http://www.gnu.org/licenses/>. |
2160 | -+ * |
2161 | -+ * Author: Marco Trevisan <marco.trevisan@canonical.com> |
2162 | -+ * |
2163 | -+ */ |
2164 | -+ |
2165 | -+#include <config.h> |
2166 | -+#include "nautilus-search-hit.h" |
2167 | -+#include "nautilus-search-provider.h" |
2168 | -+#include "nautilus-search-engine-recent.h" |
2169 | -+#include "nautilus-ui-utilities.h" |
2170 | -+#define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH |
2171 | -+#include "nautilus-debug.h" |
2172 | -+ |
2173 | -+#include <string.h> |
2174 | -+#include <glib.h> |
2175 | -+#include <gio/gio.h> |
2176 | -+ |
2177 | -+struct _NautilusSearchEngineRecent |
2178 | -+{ |
2179 | -+ GObject parent_instance; |
2180 | -+ |
2181 | -+ NautilusQuery *query; |
2182 | -+ GCancellable *cancellable; |
2183 | -+ GtkRecentManager *recent_manager; |
2184 | -+}; |
2185 | -+ |
2186 | -+static void nautilus_search_provider_init (NautilusSearchProviderInterface *iface); |
2187 | -+ |
2188 | -+G_DEFINE_TYPE_WITH_CODE (NautilusSearchEngineRecent, |
2189 | -+ nautilus_search_engine_recent, |
2190 | -+ G_TYPE_OBJECT, |
2191 | -+ G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_SEARCH_PROVIDER, |
2192 | -+ nautilus_search_provider_init)) |
2193 | -+ |
2194 | -+enum |
2195 | -+{ |
2196 | -+ PROP_0, |
2197 | -+ PROP_RUNNING, |
2198 | -+ LAST_PROP |
2199 | -+}; |
2200 | -+ |
2201 | -+ |
2202 | -+NautilusSearchEngineRecent * |
2203 | -+nautilus_search_engine_recent_new (void) |
2204 | -+{ |
2205 | -+ return g_object_new (NAUTILUS_TYPE_SEARCH_ENGINE_RECENT, NULL); |
2206 | -+} |
2207 | -+ |
2208 | -+static void |
2209 | -+nautilus_search_engine_recent_finalize (GObject *object) |
2210 | -+{ |
2211 | -+ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (object); |
2212 | -+ |
2213 | -+ if (self->cancellable) |
2214 | -+ g_cancellable_cancel (self->cancellable); |
2215 | -+ |
2216 | -+ g_clear_object (&self->query); |
2217 | -+ g_clear_object (&self->cancellable); |
2218 | -+ |
2219 | -+ G_OBJECT_CLASS (nautilus_search_engine_recent_parent_class)->finalize (object); |
2220 | -+} |
2221 | -+ |
2222 | -+typedef struct |
2223 | -+{ |
2224 | -+ NautilusSearchEngineRecent *recent; |
2225 | -+ GList *hits; |
2226 | -+} SearchHitsData; |
2227 | -+ |
2228 | -+ |
2229 | -+static gboolean |
2230 | -+search_thread_add_hits_idle (gpointer user_data) |
2231 | -+{ |
2232 | -+ SearchHitsData *search_hits = user_data; |
2233 | -+ NautilusSearchEngineRecent *self = search_hits->recent; |
2234 | -+ NautilusSearchProvider *provider = NAUTILUS_SEARCH_PROVIDER (self); |
2235 | -+ |
2236 | -+ if (!g_cancellable_is_cancelled (self->cancellable)) |
2237 | -+ { |
2238 | -+ nautilus_search_provider_hits_added (provider, search_hits->hits); |
2239 | -+ DEBUG ("Recent engine add hits"); |
2240 | -+ } |
2241 | -+ |
2242 | -+ g_list_free_full (search_hits->hits, g_object_unref); |
2243 | -+ g_object_unref (self->query); |
2244 | -+ g_clear_object (&self->cancellable); |
2245 | -+ g_object_unref (self); |
2246 | -+ g_free (search_hits); |
2247 | -+ |
2248 | -+ nautilus_search_provider_finished (provider, |
2249 | -+ NAUTILUS_SEARCH_PROVIDER_STATUS_NORMAL); |
2250 | -+ g_object_notify (G_OBJECT (provider), "running"); |
2251 | -+ |
2252 | -+ return FALSE; |
2253 | -+} |
2254 | -+ |
2255 | -+static gpointer |
2256 | -+recent_thread_func (gpointer user_data) |
2257 | -+{ |
2258 | -+ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (user_data); |
2259 | -+ SearchHitsData *search_hits; |
2260 | -+ GList *recent_items, *hits, *l; |
2261 | -+ |
2262 | -+ g_return_val_if_fail (self->query, NULL); |
2263 | -+ |
2264 | -+ hits = NULL; |
2265 | -+ recent_items = gtk_recent_manager_get_items (self->recent_manager); |
2266 | -+ |
2267 | -+ for (l = recent_items; l; l = l->next) |
2268 | -+ { |
2269 | -+ GtkRecentInfo *info = l->data; |
2270 | -+ const gchar *uri = gtk_recent_info_get_uri (info); |
2271 | -+ const gchar *name; |
2272 | -+ gdouble rank; |
2273 | -+ |
2274 | -+ if (gtk_recent_info_is_local (info)) |
2275 | -+ { |
2276 | -+ g_autofree gchar *path = g_filename_from_uri (uri, NULL, NULL); |
2277 | -+ |
2278 | -+ if (!path || !g_file_test (path, G_FILE_TEST_EXISTS)) |
2279 | -+ continue; |
2280 | -+ } |
2281 | -+ |
2282 | -+ if (g_cancellable_is_cancelled (self->cancellable)) |
2283 | -+ break; |
2284 | -+ |
2285 | -+ name = gtk_recent_info_get_display_name (info); |
2286 | -+ rank = nautilus_query_matches_string (self->query, name); |
2287 | -+ |
2288 | -+ if (rank <= 0) |
2289 | -+ { |
2290 | -+ name = gtk_recent_info_get_short_name (info); |
2291 | -+ rank = nautilus_query_matches_string (self->query, name); |
2292 | -+ } |
2293 | -+ |
2294 | -+ if (rank > 0) |
2295 | -+ { |
2296 | -+ NautilusSearchHit *hit; |
2297 | -+ time_t modified, visited; |
2298 | -+ g_autoptr (GDateTime) gmodified = NULL; |
2299 | -+ g_autoptr (GDateTime) gvisited = NULL; |
2300 | -+ |
2301 | -+ modified = gtk_recent_info_get_modified (info); |
2302 | -+ visited = gtk_recent_info_get_visited (info); |
2303 | -+ |
2304 | -+ gmodified = g_date_time_new_from_unix_local (modified); |
2305 | -+ gvisited = g_date_time_new_from_unix_local (visited); |
2306 | -+ |
2307 | -+ hit = nautilus_search_hit_new (uri); |
2308 | -+ nautilus_search_hit_set_fts_rank (hit, rank); |
2309 | -+ nautilus_search_hit_set_modification_time (hit, gmodified); |
2310 | -+ nautilus_search_hit_set_access_time (hit, gvisited); |
2311 | -+ |
2312 | -+ hits = g_list_prepend (hits, hit); |
2313 | -+ } |
2314 | -+ } |
2315 | -+ |
2316 | -+ search_hits = g_new0 (SearchHitsData, 1); |
2317 | -+ search_hits->recent = self; |
2318 | -+ search_hits->hits = hits; |
2319 | -+ |
2320 | -+ g_idle_add (search_thread_add_hits_idle, search_hits); |
2321 | -+ |
2322 | -+ g_list_free_full (recent_items, (GDestroyNotify) gtk_recent_info_unref); |
2323 | -+ |
2324 | -+ return NULL; |
2325 | -+} |
2326 | -+ |
2327 | -+static void |
2328 | -+nautilus_search_engine_recent_start (NautilusSearchProvider *provider) |
2329 | -+{ |
2330 | -+ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
2331 | -+ GThread *thread; |
2332 | -+ |
2333 | -+ g_return_if_fail (self->query); |
2334 | -+ g_return_if_fail (self->cancellable == NULL); |
2335 | -+ |
2336 | -+ g_object_ref (self); |
2337 | -+ g_object_ref (self->query); |
2338 | -+ self->cancellable = g_cancellable_new (); |
2339 | -+ |
2340 | -+ thread = g_thread_new ("nautilus-search-recent", recent_thread_func, self); |
2341 | -+ g_object_notify (G_OBJECT (provider), "running"); |
2342 | -+ |
2343 | -+ g_thread_unref (thread); |
2344 | -+} |
2345 | -+ |
2346 | -+static void |
2347 | -+nautilus_search_engine_recent_stop (NautilusSearchProvider *provider) |
2348 | -+{ |
2349 | -+ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
2350 | -+ |
2351 | -+ if (self->cancellable != NULL) |
2352 | -+ { |
2353 | -+ DEBUG ("Recent engine stop"); |
2354 | -+ g_cancellable_cancel (self->cancellable); |
2355 | -+ g_clear_object (&self->cancellable); |
2356 | -+ |
2357 | -+ g_object_notify (G_OBJECT (provider), "running"); |
2358 | -+ } |
2359 | -+} |
2360 | -+ |
2361 | -+static void |
2362 | -+nautilus_search_engine_recent_set_query (NautilusSearchProvider *provider, |
2363 | -+ NautilusQuery *query) |
2364 | -+{ |
2365 | -+ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
2366 | -+ |
2367 | -+ g_clear_object (&self->query); |
2368 | -+ self->query = g_object_ref (query); |
2369 | -+} |
2370 | -+ |
2371 | -+static gboolean |
2372 | -+nautilus_search_engine_recent_is_running (NautilusSearchProvider *provider) |
2373 | -+{ |
2374 | -+ NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (provider); |
2375 | -+ |
2376 | -+ return self->cancellable != NULL && |
2377 | -+ !g_cancellable_is_cancelled (self->cancellable); |
2378 | -+} |
2379 | -+ |
2380 | -+static void |
2381 | -+nautilus_search_engine_recent_get_property (GObject *object, |
2382 | -+ guint prop_id, |
2383 | -+ GValue *value, |
2384 | -+ GParamSpec *pspec) |
2385 | -+{ |
2386 | -+ NautilusSearchProvider *provider = NAUTILUS_SEARCH_PROVIDER (object); |
2387 | -+ |
2388 | -+ switch (prop_id) |
2389 | -+ { |
2390 | -+ case PROP_RUNNING: |
2391 | -+ { |
2392 | -+ gboolean running; |
2393 | -+ running = nautilus_search_engine_recent_is_running (provider); |
2394 | -+ g_value_set_boolean (value, running); |
2395 | -+ } |
2396 | -+ break; |
2397 | -+ |
2398 | -+ default: |
2399 | -+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
2400 | -+ } |
2401 | -+} |
2402 | -+ |
2403 | -+static void |
2404 | -+nautilus_search_provider_init (NautilusSearchProviderInterface *iface) |
2405 | -+{ |
2406 | -+ iface->set_query = nautilus_search_engine_recent_set_query; |
2407 | -+ iface->start = nautilus_search_engine_recent_start; |
2408 | -+ iface->stop = nautilus_search_engine_recent_stop; |
2409 | -+ iface->is_running = nautilus_search_engine_recent_is_running; |
2410 | -+} |
2411 | -+ |
2412 | -+static void |
2413 | -+nautilus_search_engine_recent_class_init (NautilusSearchEngineRecentClass *klass) |
2414 | -+{ |
2415 | -+ GObjectClass *object_class = G_OBJECT_CLASS (klass); |
2416 | -+ |
2417 | -+ object_class->finalize = nautilus_search_engine_recent_finalize; |
2418 | -+ object_class->get_property = nautilus_search_engine_recent_get_property; |
2419 | -+ |
2420 | -+ g_object_class_override_property (object_class, PROP_RUNNING, "running"); |
2421 | -+} |
2422 | -+ |
2423 | -+static void |
2424 | -+nautilus_search_engine_recent_init (NautilusSearchEngineRecent *self) |
2425 | -+{ |
2426 | -+ self->recent_manager = gtk_recent_manager_get_default (); |
2427 | -+} |
2428 | -diff --git a/src/nautilus-search-engine-recent.h b/src/nautilus-search-engine-recent.h |
2429 | -new file mode 100644 |
2430 | -index 000000000..fc225f736 |
2431 | ---- /dev/null |
2432 | -+++ b/src/nautilus-search-engine-recent.h |
2433 | -@@ -0,0 +1,37 @@ |
2434 | -+/* |
2435 | -+ * Copyright (C) 2018 Canonical Ltd |
2436 | -+ * |
2437 | -+ * Nautilus is free software; you can redistribute it and/or |
2438 | -+ * modify it under the terms of the GNU General Public License as |
2439 | -+ * published by the Free Software Foundation; either version 2 of the |
2440 | -+ * License, or (at your option) any later version. |
2441 | -+ * |
2442 | -+ * Nautilus is distributed in the hope that it will be useful, |
2443 | -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2444 | -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2445 | -+ * General Public License for more details. |
2446 | -+ * |
2447 | -+ * You should have received a copy of the GNU General Public |
2448 | -+ * License along with this program; see the file COPYING. If not, |
2449 | -+ * see <http://www.gnu.org/licenses/>. |
2450 | -+ * |
2451 | -+ * Author: Marco Trevisan <marco.trevisan@canonical.com> |
2452 | -+ * |
2453 | -+ */ |
2454 | -+ |
2455 | -+#ifndef __NAUTILUS_SEARCH_ENGINE_RECENT_H__ |
2456 | -+#define __NAUTILUS_SEARCH_ENGINE_RECENT_H__ |
2457 | -+ |
2458 | -+#include <glib-object.h> |
2459 | -+ |
2460 | -+G_BEGIN_DECLS |
2461 | -+ |
2462 | -+#define NAUTILUS_TYPE_SEARCH_ENGINE_RECENT (nautilus_search_engine_recent_get_type ()) |
2463 | -+ |
2464 | -+G_DECLARE_FINAL_TYPE (NautilusSearchEngineRecent, nautilus_search_engine_recent, NAUTILUS, SEARCH_ENGINE_RECENT, GObject); |
2465 | -+ |
2466 | -+NautilusSearchEngineRecent *nautilus_search_engine_recent_new (void); |
2467 | -+ |
2468 | -+G_END_DECLS |
2469 | -+ |
2470 | -+#endif /* __NAUTILUS_SEARCH_ENGINE_RECENT_H__ */ |
2471 | -diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c |
2472 | -index 209bd4f80..aef91b702 100644 |
2473 | ---- a/src/nautilus-search-engine.c |
2474 | -+++ b/src/nautilus-search-engine.c |
2475 | -@@ -24,6 +24,7 @@ |
2476 | - #include <glib/gi18n.h> |
2477 | - #include "nautilus-search-provider.h" |
2478 | - #include "nautilus-search-engine.h" |
2479 | -+#include "nautilus-search-engine-recent.h" |
2480 | - #include "nautilus-search-engine-simple.h" |
2481 | - #include "nautilus-search-engine-model.h" |
2482 | - #define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH |
2483 | -@@ -33,6 +34,7 @@ |
2484 | - typedef struct |
2485 | - { |
2486 | - NautilusSearchEngineTracker *tracker; |
2487 | -+ NautilusSearchEngineRecent *recent; |
2488 | - NautilusSearchEngineSimple *simple; |
2489 | - NautilusSearchEngineModel *model; |
2490 | - |
2491 | -@@ -74,6 +76,7 @@ nautilus_search_engine_set_query (NautilusSearchProvider *provider, |
2492 | - priv = nautilus_search_engine_get_instance_private (engine); |
2493 | - |
2494 | - nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->tracker), query); |
2495 | -+ nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->recent), query); |
2496 | - nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->model), query); |
2497 | - nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (priv->simple), query); |
2498 | - } |
2499 | -@@ -98,6 +101,9 @@ search_engine_start_real (NautilusSearchEngine *engine) |
2500 | - nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->tracker)); |
2501 | - priv->providers_running++; |
2502 | - |
2503 | -+ priv->providers_running++; |
2504 | -+ nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
2505 | -+ |
2506 | - if (nautilus_search_engine_model_get_model (priv->model)) |
2507 | - { |
2508 | - nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->model)); |
2509 | -@@ -159,6 +165,7 @@ nautilus_search_engine_stop (NautilusSearchProvider *provider) |
2510 | - DEBUG ("Search engine stop"); |
2511 | - |
2512 | - nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->tracker)); |
2513 | -+ nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
2514 | - nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->model)); |
2515 | - nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (priv->simple)); |
2516 | - |
2517 | -@@ -334,6 +341,7 @@ nautilus_search_engine_finalize (GObject *object) |
2518 | - g_hash_table_destroy (priv->uris); |
2519 | - |
2520 | - g_clear_object (&priv->tracker); |
2521 | -+ g_clear_object (&priv->recent); |
2522 | - g_clear_object (&priv->model); |
2523 | - g_clear_object (&priv->simple); |
2524 | - |
2525 | -@@ -395,6 +403,9 @@ nautilus_search_engine_init (NautilusSearchEngine *engine) |
2526 | - |
2527 | - priv->simple = nautilus_search_engine_simple_new (); |
2528 | - connect_provider_signals (engine, NAUTILUS_SEARCH_PROVIDER (priv->simple)); |
2529 | -+ |
2530 | -+ priv->recent = nautilus_search_engine_recent_new (); |
2531 | -+ connect_provider_signals (engine, NAUTILUS_SEARCH_PROVIDER (priv->recent)); |
2532 | - } |
2533 | - |
2534 | - NautilusSearchEngine * |
2535 | --- |
2536 | -2.15.1 |
2537 | - |
2538 | |
2539 | === modified file 'debian/patches/series' |
2540 | --- debian/patches/series 2018-03-24 20:06:53 +0000 |
2541 | +++ debian/patches/series 2018-04-12 23:13:34 +0000 |
2542 | @@ -14,5 +14,7 @@ |
2543 | 0001-Respect-gtk-dialogs-use-header-for-all-dialogs.patch |
2544 | #Needs updating |
2545 | #16_unity_new_documents.patch |
2546 | -search-engine-add-a-recent-search-engine-listing-Gtk.patch |
2547 | -directory-update-recent-files-manager-on-rename-or-f.patch |
2548 | +0015-tracker-search-engine-don-t-start-it-if-not-availabl.patch |
2549 | +0016-search-engine-add-a-recent-search-engine-listing-Gtk.patch |
2550 | +0017-recent-add-function-to-update-manager-on-file-rename.patch |
2551 | +0018-search-engine-add-locate-based-search-engine.patch |
Thank you!
Uploading to bionic. Because of the archive freeze, the upload will need to be manually approved by the Ubuntu Release Team.