Mercurial > geeqie.yaz
annotate src/search.c @ 107:a01d8c49ca2f
fix comments
author | gqview |
---|---|
date | Fri, 10 Nov 2006 03:30:00 +0000 |
parents | 9d5c75b5ec28 |
children | 71e1ebee420e |
rev | line source |
---|---|
9 | 1 /* |
2 * GQview | |
3 * (C) 2005 John Ellis | |
4 * | |
5 * Author: John Ellis | |
6 * | |
7 * This software is released under the GNU General Public License (GNU GPL). | |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
10 */ | |
11 | |
12 | |
13 #include "gqview.h" | |
14 #include "search.h" | |
15 | |
16 #include "bar_info.h" | |
17 #include "cache.h" | |
18 #include "collect.h" | |
19 #include "collect-table.h" | |
20 #include "dnd.h" | |
21 #include "dupe.h" | |
22 #include "image-load.h" | |
23 #include "info.h" | |
24 #include "editors.h" | |
25 #include "img-view.h" | |
26 #include "filelist.h" | |
27 #include "layout_image.h" | |
28 #include "menu.h" | |
29 #include "print.h" | |
30 #include "thumb.h" | |
31 #include "utilops.h" | |
32 #include "ui_bookmark.h" | |
33 #include "ui_fileops.h" | |
34 #include "ui_menu.h" | |
35 #include "ui_misc.h" | |
36 #include "ui_spinner.h" | |
37 #include "ui_tabcomp.h" | |
38 #include "ui_tree_edit.h" | |
39 | |
40 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
41 | |
42 | |
43 #define DEF_SEARCH_WIDTH 700 | |
44 #define DEF_SEARCH_HEIGHT 450 | |
45 | |
46 #define SEARCH_BUFFER_MATCH_LOAD 20 | |
47 #define SEARCH_BUFFER_MATCH_HIT 5 | |
48 #define SEARCH_BUFFER_MATCH_MISS 1 | |
49 #define SEARCH_BUFFER_FLUSH_SIZE 99 | |
50 | |
51 | |
52 typedef enum { | |
53 SEARCH_MATCH_NONE, | |
54 SEARCH_MATCH_EQUAL, | |
55 SEARCH_MATCH_CONTAINS, | |
56 SEARCH_MATCH_UNDER, | |
57 SEARCH_MATCH_OVER, | |
58 SEARCH_MATCH_BETWEEN, | |
59 SEARCH_MATCH_ALL, | |
60 SEARCH_MATCH_ANY | |
61 } MatchType; | |
62 | |
63 enum { | |
64 SEARCH_COLUMN_POINTER = 0, | |
65 SEARCH_COLUMN_RANK, | |
66 SEARCH_COLUMN_THUMB, | |
67 SEARCH_COLUMN_NAME, | |
68 SEARCH_COLUMN_SIZE, | |
69 SEARCH_COLUMN_DATE, | |
70 SEARCH_COLUMN_DIMENSIONS, | |
71 SEARCH_COLUMN_PATH, | |
72 SEARCH_COLUMN_COUNT /* total columns */ | |
73 }; | |
74 | |
75 typedef struct _SearchData SearchData; | |
76 struct _SearchData | |
77 { | |
78 GtkWidget *window; | |
79 | |
80 GtkWidget *button_thumbs; | |
81 GtkWidget *label_status; | |
82 GtkWidget *label_progress; | |
83 GtkWidget *button_start; | |
84 GtkWidget *button_stop; | |
85 GtkWidget *spinner; | |
86 | |
87 GtkWidget *box_search; | |
88 | |
89 GtkWidget *menu_path; | |
90 GtkWidget *path_entry; | |
91 GtkWidget *check_recurse; | |
92 | |
93 GtkWidget *result_view; | |
94 | |
95 GtkWidget *check_name; | |
96 GtkWidget *menu_name; | |
97 GtkWidget *entry_name; | |
98 GtkWidget *check_name_match_case; | |
99 | |
100 GtkWidget *check_size; | |
101 GtkWidget *menu_size; | |
102 GtkWidget *spin_size; | |
103 GtkWidget *spin_size_end; | |
104 | |
105 GtkWidget *check_date; | |
106 GtkWidget *menu_date; | |
107 GtkWidget *date_sel; | |
108 GtkWidget *date_sel_end; | |
109 | |
110 GtkWidget *check_dimensions; | |
111 GtkWidget *menu_dimensions; | |
112 GtkWidget *spin_width; | |
113 GtkWidget *spin_height; | |
114 GtkWidget *spin_width_end; | |
115 GtkWidget *spin_height_end; | |
116 | |
117 GtkWidget *check_similarity; | |
118 GtkWidget *spin_similarity; | |
119 GtkWidget *entry_similarity; | |
120 | |
121 GtkWidget *check_keywords; | |
122 GtkWidget *menu_keywords; | |
123 GtkWidget *entry_keywords; | |
124 | |
125 gchar *search_path; | |
126 gint search_path_recurse; | |
127 gchar *search_name; | |
128 gint search_name_match_case; | |
129 gint64 search_size; | |
130 gint64 search_size_end; | |
131 gint search_date_y; | |
132 gint search_date_m; | |
133 gint search_date_d; | |
134 gint search_date_end_y; | |
135 gint search_date_end_m; | |
136 gint search_date_end_d; | |
137 gint search_width; | |
138 gint search_height; | |
139 gint search_width_end; | |
140 gint search_height_end; | |
141 gint search_similarity; | |
142 gchar *search_similarity_path; | |
143 CacheData *search_similarity_cd; | |
144 GList *search_keyword_list; | |
145 | |
146 MatchType search_type; | |
147 | |
148 MatchType match_name; | |
149 MatchType match_size; | |
150 MatchType match_date; | |
151 MatchType match_dimensions; | |
152 MatchType match_keywords; | |
153 | |
154 gboolean match_name_enable; | |
155 gboolean match_size_enable; | |
156 gboolean match_date_enable; | |
157 gboolean match_dimensions_enable; | |
158 gboolean match_similarity_enable; | |
159 gboolean match_keywords_enable; | |
160 | |
161 GList *search_folder_list; | |
162 GList *search_done_list; | |
163 GList *search_file_list; | |
164 GList *search_buffer_list; | |
165 | |
166 gint search_count; | |
167 gint search_total; | |
168 gint search_buffer_count; | |
169 | |
170 gint search_idle_id; | |
171 gint update_idle_id; | |
172 | |
173 ImageLoader *img_loader; | |
174 CacheData *img_cd; | |
175 | |
176 FileData *click_fd; | |
177 | |
178 ThumbLoader *thumb_loader; | |
179 gint thumb_enable; | |
180 FileData *thumb_fd; | |
181 }; | |
182 | |
183 typedef struct _MatchFileData MatchFileData; | |
184 struct _MatchFileData | |
185 { | |
186 FileData fd; | |
187 gint width; | |
188 gint height; | |
189 gint rank; | |
190 }; | |
191 | |
192 typedef struct _MatchList MatchList; | |
193 struct _MatchList | |
194 { | |
195 const gchar *text; | |
196 const MatchType type; | |
197 }; | |
198 | |
199 static const MatchList text_search_menu_path[] = { | |
200 { N_("folder"), SEARCH_MATCH_NONE }, | |
201 { N_("comments"), SEARCH_MATCH_ALL }, | |
202 { N_("results"), SEARCH_MATCH_CONTAINS } | |
203 }; | |
204 | |
205 static const MatchList text_search_menu_name[] = { | |
206 { N_("contains"), SEARCH_MATCH_CONTAINS }, | |
207 { N_("is"), SEARCH_MATCH_EQUAL } | |
208 }; | |
209 | |
210 static const MatchList text_search_menu_size[] = { | |
211 { N_("equal to"), SEARCH_MATCH_EQUAL }, | |
212 { N_("less than"), SEARCH_MATCH_UNDER }, | |
213 { N_("greater than"), SEARCH_MATCH_OVER }, | |
214 { N_("between"), SEARCH_MATCH_BETWEEN } | |
215 }; | |
216 | |
217 static const MatchList text_search_menu_date[] = { | |
218 { N_("equal to"), SEARCH_MATCH_EQUAL }, | |
219 { N_("before"), SEARCH_MATCH_UNDER }, | |
220 { N_("after"), SEARCH_MATCH_OVER }, | |
221 { N_("between"), SEARCH_MATCH_BETWEEN } | |
222 }; | |
223 | |
224 static const MatchList text_search_menu_keyword[] = { | |
225 { N_("match all"), SEARCH_MATCH_ALL }, | |
226 { N_("match any"), SEARCH_MATCH_ANY }, | |
227 { N_("exclude"), SEARCH_MATCH_NONE } | |
228 }; | |
229 | |
230 static GList *search_window_list = NULL; | |
231 | |
232 | |
233 static gint search_result_selection_count(SearchData *sd, gint64 *bytes); | |
234 static gint search_result_count(SearchData *sd, gint64 *bytes); | |
235 | |
236 static void search_window_close(SearchData *sd); | |
237 | |
238 | |
239 /* | |
240 *------------------------------------------------------------------- | |
241 * utils | |
242 *------------------------------------------------------------------- | |
243 */ | |
244 | |
245 static time_t convert_dmy_to_time(gint day, gint month, gint year) | |
246 { | |
247 struct tm lt; | |
248 | |
249 lt.tm_sec = 0; | |
250 lt.tm_min = 0; | |
251 lt.tm_hour = 0; | |
252 lt.tm_mday = day; | |
253 lt.tm_mon = month - 1; | |
254 lt.tm_year = year - 1900; | |
255 lt.tm_isdst = 0; | |
256 | |
257 return mktime(<); | |
258 } | |
259 | |
260 static void search_status_update(SearchData *sd) | |
261 { | |
262 gchar *buf; | |
263 gint t; | |
264 gint s; | |
265 gint64 t_bytes; | |
266 gint64 s_bytes; | |
267 gchar *tt; | |
268 gchar *ts; | |
269 | |
270 t = search_result_count(sd, &t_bytes); | |
271 s = search_result_selection_count(sd, &s_bytes); | |
272 | |
273 if (s > 0) | |
274 { | |
275 tt = text_from_size_abrev(t_bytes); | |
276 ts = text_from_size_abrev(s_bytes); | |
277 buf = g_strdup_printf(_("%s, %d files (%s, %d)"), tt, t, ts, s); | |
278 g_free(tt); | |
279 g_free(ts); | |
280 } | |
281 else | |
282 { | |
283 tt = text_from_size_abrev(t_bytes); | |
284 buf = g_strdup_printf(_("%s, %d files"), tt, t); | |
285 g_free(tt); | |
286 } | |
287 | |
288 gtk_label_set_text(GTK_LABEL(sd->label_status), buf); | |
289 g_free(buf); | |
290 } | |
291 | |
292 static void search_progress_update(SearchData *sd, gint search, gdouble thumbs) | |
293 { | |
294 | |
295 if (search || thumbs >= 0.0) | |
296 { | |
297 gchar *buf; | |
298 const gchar *message; | |
299 | |
300 if (search && (sd->search_folder_list || sd->search_file_list)) | |
301 message = _("Searching..."); | |
302 else if (thumbs >= 0.0) | |
303 message = _("Loading thumbs..."); | |
304 else | |
305 message = ""; | |
306 | |
307 buf = g_strdup_printf("%s(%d / %d)", message, sd->search_count, sd->search_total); | |
308 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(sd->label_progress), buf); | |
309 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(sd->label_progress), | |
310 (thumbs >= 0.0) ? thumbs : 0.0); | |
311 g_free(buf); | |
312 } | |
313 else | |
314 { | |
315 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(sd->label_progress), ""); | |
316 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(sd->label_progress), 0.0); | |
317 } | |
318 } | |
319 | |
320 /* | |
321 *------------------------------------------------------------------- | |
322 * result list | |
323 *------------------------------------------------------------------- | |
324 */ | |
325 | |
326 static gint search_result_find_row(SearchData *sd, FileData *fd, GtkTreeIter *iter) | |
327 { | |
328 GtkTreeModel *store; | |
329 gint valid; | |
330 gint n = 0; | |
331 | |
332 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
333 valid = gtk_tree_model_get_iter_first(store, iter); | |
334 while (valid) | |
335 { | |
336 FileData *fd_n; | |
337 n++; | |
338 | |
339 gtk_tree_model_get(store, iter, SEARCH_COLUMN_POINTER, &fd_n, -1); | |
340 if (fd_n == fd) return n; | |
341 valid = gtk_tree_model_iter_next(store, iter); | |
342 } | |
343 | |
344 return -1; | |
345 } | |
346 | |
347 static gint search_result_row_selected(SearchData *sd, FileData *fd) | |
348 { | |
349 GtkTreeModel *store; | |
350 GtkTreeSelection *selection; | |
351 GList *slist; | |
352 GList *work; | |
353 gint found = FALSE; | |
354 | |
355 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view)); | |
356 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
357 work = slist; | |
358 while (!found && work) | |
359 { | |
360 GtkTreePath *tpath = work->data; | |
361 FileData *fd_n; | |
362 GtkTreeIter iter; | |
363 | |
364 gtk_tree_model_get_iter(store, &iter, tpath); | |
365 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd_n, -1); | |
366 if (fd_n == fd) found = TRUE; | |
367 work = work->next; | |
368 } | |
369 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
370 g_list_free(slist); | |
371 | |
372 return found; | |
373 } | |
374 | |
375 static gint search_result_selection_util(SearchData *sd, gint64 *bytes, GList **list) | |
376 { | |
377 GtkTreeModel *store; | |
378 GtkTreeSelection *selection; | |
379 GList *slist; | |
380 GList *work; | |
381 gint n = 0; | |
382 gint64 total = 0; | |
383 GList *plist = NULL; | |
384 | |
385 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
386 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view)); | |
387 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
388 work = slist; | |
389 while (work) | |
390 { | |
391 n++; | |
392 | |
393 if (bytes || list) | |
394 { | |
395 GtkTreePath *tpath = work->data; | |
396 FileData *fd; | |
397 GtkTreeIter iter; | |
398 | |
399 gtk_tree_model_get_iter(store, &iter, tpath); | |
400 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
401 total += fd->size; | |
402 | |
403 if (list) plist = g_list_prepend(plist, g_strdup(fd->path)); | |
404 } | |
405 | |
406 work = work->next; | |
407 } | |
408 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
409 g_list_free(slist); | |
410 | |
411 if (bytes) *bytes = total; | |
412 if (list) *list = g_list_reverse(plist); | |
413 | |
414 return n; | |
415 } | |
416 | |
417 static GList *search_result_selection_list(SearchData *sd) | |
418 { | |
419 GList *list; | |
420 | |
421 search_result_selection_util(sd, NULL, &list); | |
422 return list; | |
423 } | |
424 | |
425 static gint search_result_selection_count(SearchData *sd, gint64 *bytes) | |
426 { | |
427 return search_result_selection_util(sd, bytes, NULL); | |
428 } | |
429 | |
430 static gint search_result_util(SearchData *sd, gint64 *bytes, GList **list) | |
431 { | |
432 GtkTreeModel *store; | |
433 GtkTreeIter iter; | |
434 gint valid; | |
435 gint n = 0; | |
436 gint64 total = 0; | |
437 GList *plist = NULL; | |
438 | |
439 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
440 | |
441 valid = gtk_tree_model_get_iter_first(store, &iter); | |
442 while (valid) | |
443 { | |
444 n++; | |
445 if (bytes || list) | |
446 { | |
447 FileData *fd; | |
448 | |
449 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
450 total += fd->size; | |
451 | |
452 if (list) plist = g_list_prepend(plist, g_strdup(fd->path)); | |
453 } | |
454 valid = gtk_tree_model_iter_next(store, &iter); | |
455 } | |
456 | |
457 if (bytes) *bytes = total; | |
458 if (list) *list = g_list_reverse(plist); | |
459 | |
460 return n; | |
461 } | |
462 | |
463 static GList *search_result_get_path_list(SearchData *sd) | |
464 { | |
465 GList *list = NULL; | |
466 | |
467 search_result_util(sd, NULL, &list); | |
468 return list; | |
469 } | |
470 | |
471 static gint search_result_count(SearchData *sd, gint64 *bytes) | |
472 { | |
473 return search_result_util(sd, bytes, NULL); | |
474 } | |
475 | |
476 static void search_result_append(SearchData *sd, MatchFileData *mfd) | |
477 { | |
478 FileData *fd; | |
479 GtkListStore *store; | |
480 GtkTreeIter iter; | |
481 gchar *text_size; | |
482 gchar *text_dim = NULL; | |
483 | |
484 fd = (FileData *)mfd; | |
485 | |
486 if (!fd) return; | |
487 | |
488 text_size = text_from_size(fd->size); | |
489 if (mfd->width > 0 && mfd->height > 0) text_dim = g_strdup_printf("%d x %d", mfd->width, mfd->height); | |
490 | |
491 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view))); | |
492 gtk_list_store_append(store, &iter); | |
493 gtk_list_store_set(store, &iter, | |
494 SEARCH_COLUMN_POINTER, fd, | |
495 SEARCH_COLUMN_RANK, mfd->rank, | |
496 SEARCH_COLUMN_THUMB, fd->pixbuf, | |
497 SEARCH_COLUMN_NAME, fd->name, | |
498 SEARCH_COLUMN_SIZE, text_size, | |
499 SEARCH_COLUMN_DATE, text_from_time(fd->date), | |
500 SEARCH_COLUMN_DIMENSIONS, text_dim, | |
501 SEARCH_COLUMN_PATH, fd->path, | |
502 -1); | |
503 | |
504 g_free(text_size); | |
505 g_free(text_dim); | |
506 } | |
507 | |
508 static GList *search_result_refine_list(SearchData *sd) | |
509 { | |
510 GList *list = NULL; | |
511 GtkTreeModel *store; | |
512 GtkTreeIter iter; | |
513 gint valid; | |
514 | |
515 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
516 | |
517 valid = gtk_tree_model_get_iter_first(store, &iter); | |
518 while (valid) | |
519 { | |
520 FileData *fd; | |
521 | |
522 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
523 list = g_list_prepend(list, fd); | |
524 | |
525 valid = gtk_tree_model_iter_next(store, &iter); | |
526 } | |
527 | |
528 /* clear it here, so that the FileData in list is not freed */ | |
529 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
530 | |
531 return g_list_reverse(list); | |
532 } | |
533 | |
534 static gboolean search_result_free_node(GtkTreeModel *store, GtkTreePath *tpath, | |
535 GtkTreeIter *iter, gpointer data) | |
536 { | |
537 FileData *fd; | |
538 | |
539 gtk_tree_model_get(store, iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
540 file_data_free(fd); | |
541 | |
542 return FALSE; | |
543 } | |
544 | |
545 static void search_result_clear(SearchData *sd) | |
546 { | |
547 GtkListStore *store; | |
548 | |
549 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view))); | |
550 | |
551 gtk_tree_model_foreach(GTK_TREE_MODEL(store), search_result_free_node, sd); | |
552 gtk_list_store_clear(store); | |
553 | |
554 sd->click_fd = NULL; | |
555 | |
556 thumb_loader_free(sd->thumb_loader); | |
557 sd->thumb_loader = NULL; | |
558 sd->thumb_fd = NULL; | |
559 | |
560 search_status_update(sd); | |
561 } | |
562 | |
563 static void search_result_remove_item(SearchData *sd, FileData *fd, GtkTreeIter *iter) | |
564 { | |
565 GtkTreeModel *store; | |
566 | |
567 if (!fd || !iter) return; | |
568 | |
569 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
570 | |
571 tree_view_move_cursor_away(GTK_TREE_VIEW(sd->result_view), iter, TRUE); | |
572 | |
573 gtk_list_store_remove(GTK_LIST_STORE(store), iter); | |
574 if (sd->click_fd == fd) sd->click_fd = NULL; | |
575 if (sd->thumb_fd == fd) sd->thumb_fd = NULL; | |
576 file_data_free(fd); | |
577 } | |
578 | |
579 static void search_result_remove(SearchData *sd, FileData *fd) | |
580 { | |
581 GtkTreeModel *store; | |
582 GtkTreeIter iter; | |
583 gint valid; | |
584 | |
585 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
586 valid = gtk_tree_model_get_iter_first(store, &iter); | |
587 while (valid) | |
588 { | |
589 FileData *fd_n; | |
590 | |
591 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd_n, -1); | |
592 if (fd_n == fd) | |
593 { | |
594 search_result_remove_item(sd, fd_n, &iter); | |
595 return; | |
596 } | |
597 | |
598 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | |
599 } | |
600 } | |
601 | |
602 static void search_result_remove_selection(SearchData *sd) | |
603 { | |
604 GtkTreeSelection *selection; | |
605 GtkTreeModel *store; | |
606 GList *slist; | |
607 GList *flist = NULL; | |
608 GList *work; | |
609 | |
610 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view)); | |
611 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
612 work = slist; | |
613 while (work) | |
614 { | |
615 GtkTreePath *tpath = work->data; | |
616 GtkTreeIter iter; | |
617 FileData *fd; | |
618 | |
619 gtk_tree_model_get_iter(store, &iter, tpath); | |
620 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
621 flist = g_list_prepend(flist, fd); | |
622 work = work->next; | |
623 } | |
624 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
625 g_list_free(slist); | |
626 | |
627 work = flist; | |
628 while (work) | |
629 { | |
630 FileData *fd = work->data; | |
631 work = work->next; | |
632 | |
633 search_result_remove(sd, fd); | |
634 } | |
635 g_list_free(flist); | |
636 | |
637 search_status_update(sd); | |
638 } | |
639 | |
640 static void search_result_edit_selected(SearchData *sd, gint n) | |
641 { | |
642 GList *list; | |
643 | |
644 list = search_result_selection_list(sd); | |
645 start_editor_from_path_list(n, list); | |
646 path_list_free(list); | |
647 } | |
648 | |
649 static void search_result_collection_from_selection(SearchData *sd) | |
650 { | |
651 CollectWindow *w; | |
652 GList *list; | |
653 | |
654 list = search_result_selection_list(sd); | |
655 w = collection_window_new(NULL); | |
656 collection_table_add_path_list(w->table, list); | |
657 path_list_free(list); | |
658 } | |
659 | |
660 static gint search_result_update_idle_cb(gpointer data) | |
661 { | |
662 SearchData *sd = data; | |
663 | |
664 search_status_update(sd); | |
665 | |
666 sd->update_idle_id = -1; | |
667 return FALSE; | |
668 } | |
669 | |
670 static void search_result_update_idle_cancel(SearchData *sd) | |
671 { | |
672 if (sd->update_idle_id != -1) g_source_remove(sd->update_idle_id); | |
673 sd->update_idle_id = -1; | |
674 } | |
675 | |
676 static gboolean search_result_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, | |
677 GtkTreePath *tpath, gboolean selected, gpointer data) | |
678 { | |
679 SearchData *sd = data; | |
680 | |
681 if (sd->update_idle_id == -1) | |
682 { | |
683 sd->update_idle_id = g_idle_add(search_result_update_idle_cb, sd); | |
684 } | |
685 | |
686 return TRUE; | |
687 } | |
688 | |
689 /* | |
690 *------------------------------------------------------------------- | |
691 * result list thumbs | |
692 *------------------------------------------------------------------- | |
693 */ | |
694 | |
695 static void search_result_thumb_step(SearchData *sd); | |
696 | |
697 | |
698 static void search_result_thumb_set(SearchData *sd, FileData *fd, GtkTreeIter *iter) | |
699 { | |
700 GtkListStore *store; | |
701 GtkTreeIter iter_n; | |
702 | |
703 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view))); | |
704 if (!iter) | |
705 { | |
706 if (search_result_find_row(sd, fd, &iter_n) >= 0) iter = &iter_n; | |
707 } | |
708 | |
709 if (iter) gtk_list_store_set(store, iter, SEARCH_COLUMN_THUMB, fd->pixbuf, -1); | |
710 } | |
711 | |
712 static void search_result_thumb_do(SearchData *sd) | |
713 { | |
714 FileData *fd; | |
715 | |
716 if (!sd->thumb_loader || !sd->thumb_fd) return; | |
717 fd = sd->thumb_fd; | |
718 | |
719 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
720 fd->pixbuf = thumb_loader_get_pixbuf(sd->thumb_loader, TRUE); | |
721 | |
722 search_result_thumb_set(sd, fd, NULL); | |
723 } | |
724 | |
725 static void search_result_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
726 { | |
727 SearchData *sd = data; | |
728 | |
729 search_result_thumb_do(sd); | |
730 search_result_thumb_step(sd); | |
731 } | |
732 | |
733 static void search_result_thumb_step(SearchData *sd) | |
734 { | |
735 GtkTreeModel *store; | |
736 GtkTreeIter iter; | |
737 FileData *fd = NULL; | |
738 gint valid; | |
739 gint row = 0; | |
740 gint length = 0; | |
741 | |
742 if (!sd->thumb_enable) return; | |
743 | |
744 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
745 | |
746 valid = gtk_tree_model_get_iter_first(store, &iter); | |
747 while (!fd && valid) | |
748 { | |
749 GdkPixbuf *pixbuf; | |
750 | |
751 length++; | |
752 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, SEARCH_COLUMN_THUMB, &pixbuf, -1); | |
753 if (pixbuf || fd->pixbuf) | |
754 { | |
755 if (!pixbuf) gtk_list_store_set(GTK_LIST_STORE(store), &iter, SEARCH_COLUMN_THUMB, fd->pixbuf, -1); | |
756 row++; | |
757 fd = NULL; | |
758 } | |
759 valid = gtk_tree_model_iter_next(store, &iter); | |
760 } | |
761 if (valid) | |
762 { | |
763 while (gtk_tree_model_iter_next(store, &iter)) length++; | |
764 } | |
765 | |
766 if (!fd) | |
767 { | |
768 sd->thumb_fd = NULL; | |
769 thumb_loader_free(sd->thumb_loader); | |
770 sd->thumb_loader = NULL; | |
771 | |
772 search_progress_update(sd, TRUE, -1.0); | |
773 return; | |
774 } | |
775 | |
776 search_progress_update(sd, FALSE, (gdouble)row/length); | |
777 | |
778 sd->thumb_fd = fd; | |
779 thumb_loader_free(sd->thumb_loader); | |
780 sd->thumb_loader = thumb_loader_new(thumb_max_width, thumb_max_height); | |
781 | |
782 thumb_loader_set_callbacks(sd->thumb_loader, | |
783 search_result_thumb_done_cb, | |
784 search_result_thumb_done_cb, | |
785 NULL, | |
786 sd); | |
787 if (!thumb_loader_start(sd->thumb_loader, fd->path)) | |
788 { | |
789 search_result_thumb_do(sd); | |
790 search_result_thumb_step(sd); | |
791 } | |
792 } | |
793 | |
794 static void search_result_thumb_height(SearchData *sd) | |
795 { | |
796 GtkTreeViewColumn *column; | |
797 GtkCellRenderer *cell; | |
798 GList *list; | |
799 | |
800 column = gtk_tree_view_get_column(GTK_TREE_VIEW(sd->result_view), SEARCH_COLUMN_THUMB - 1); | |
801 if (!column) return; | |
802 | |
803 gtk_tree_view_column_set_fixed_width(column, (sd->thumb_enable) ? thumb_max_width : 4); | |
804 | |
805 list = gtk_tree_view_column_get_cell_renderers(column); | |
806 if (!list) return; | |
807 cell = list->data; | |
808 g_list_free(list); | |
809 | |
810 g_object_set(G_OBJECT(cell), "height", (sd->thumb_enable) ? thumb_max_height : -1, NULL); | |
811 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(sd->result_view)); | |
812 } | |
813 | |
814 static void search_result_thumb_enable(SearchData *sd, gint enable) | |
815 { | |
816 if (sd->thumb_enable == enable) return; | |
817 | |
818 if (sd->thumb_enable) | |
819 { | |
820 GtkTreeModel *store; | |
821 GtkTreeIter iter; | |
822 gint valid; | |
823 | |
824 thumb_loader_free(sd->thumb_loader); | |
825 sd->thumb_loader = NULL; | |
826 | |
827 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
828 valid = gtk_tree_model_get_iter_first(store, &iter); | |
829 while (valid) | |
830 { | |
831 gtk_list_store_set(GTK_LIST_STORE(store), &iter, SEARCH_COLUMN_THUMB, NULL, -1); | |
832 valid = gtk_tree_model_iter_next(store, &iter); | |
833 } | |
834 search_progress_update(sd, TRUE, -1.0); | |
835 } | |
836 | |
837 sd->thumb_enable = enable; | |
838 | |
839 search_result_thumb_height(sd); | |
840 if (!sd->search_folder_list && !sd->search_file_list) search_result_thumb_step(sd); | |
841 } | |
842 | |
843 /* | |
844 *------------------------------------------------------------------- | |
845 * result list menu | |
846 *------------------------------------------------------------------- | |
847 */ | |
848 | |
849 static void sr_menu_view_cb(GtkWidget *widget, gpointer data) | |
850 { | |
851 SearchData *sd = data; | |
852 | |
853 if (sd->click_fd) layout_image_set_path(NULL, sd->click_fd->path); | |
854 } | |
855 | |
856 static void sr_menu_viewnew_cb(GtkWidget *widget, gpointer data) | |
857 { | |
858 SearchData *sd = data; | |
859 GList *list; | |
860 | |
861 list = search_result_selection_list(sd); | |
862 view_window_new_from_list(list); | |
863 path_list_free(list); | |
864 } | |
865 | |
866 static void sr_menu_select_all_cb(GtkWidget *widget, gpointer data) | |
867 { | |
868 SearchData *sd = data; | |
869 GtkTreeSelection *selection; | |
870 | |
871 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view)); | |
872 gtk_tree_selection_select_all(selection); | |
873 } | |
874 | |
875 static void sr_menu_select_none_cb(GtkWidget *widget, gpointer data) | |
876 { | |
877 SearchData *sd = data; | |
878 GtkTreeSelection *selection; | |
879 | |
880 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view)); | |
881 gtk_tree_selection_unselect_all(selection); | |
882 } | |
883 | |
884 static void sr_menu_edit_cb(GtkWidget *widget, gpointer data) | |
885 { | |
886 SearchData *sd; | |
887 gint n; | |
888 | |
889 sd = submenu_item_get_data(widget); | |
890 n = GPOINTER_TO_INT(data); | |
891 if (!sd) return; | |
892 | |
893 search_result_edit_selected(sd, n); | |
894 } | |
895 | |
896 static void sr_menu_info_cb(GtkWidget *widget, gpointer data) | |
897 { | |
898 SearchData *sd = data; | |
899 | |
900 info_window_new(NULL, search_result_selection_list(sd)); | |
901 } | |
902 | |
903 static void sr_menu_collection_cb(GtkWidget *widget, gpointer data) | |
904 { | |
905 SearchData *sd = data; | |
906 | |
907 search_result_collection_from_selection(sd); | |
908 } | |
909 | |
910 static void sr_menu_print_cb(GtkWidget *widget, gpointer data) | |
911 { | |
912 SearchData *sd = data; | |
913 const gchar *path; | |
914 | |
915 path = (sd->click_fd) ? sd->click_fd->path : NULL; | |
916 | |
917 print_window_new(path, search_result_selection_list(sd), | |
918 search_result_get_path_list(sd), sd->window); | |
919 } | |
920 | |
921 static void sr_menu_copy_cb(GtkWidget *widget, gpointer data) | |
922 { | |
923 SearchData *sd = data; | |
924 | |
925 file_util_copy(NULL, search_result_selection_list(sd), NULL, sd->window); | |
926 } | |
927 | |
928 static void sr_menu_move_cb(GtkWidget *widget, gpointer data) | |
929 { | |
930 SearchData *sd = data; | |
931 | |
932 file_util_move(NULL, search_result_selection_list(sd), NULL, sd->window); | |
933 } | |
934 | |
935 static void sr_menu_rename_cb(GtkWidget *widget, gpointer data) | |
936 { | |
937 SearchData *sd = data; | |
938 | |
939 file_util_rename(NULL, search_result_selection_list(sd), sd->window); | |
940 } | |
941 | |
942 static void sr_menu_delete_cb(GtkWidget *widget, gpointer data) | |
943 { | |
944 SearchData *sd = data; | |
945 | |
946 file_util_delete(NULL, search_result_selection_list(sd), sd->window); | |
947 } | |
948 | |
949 static void sr_menu_remove_cb(GtkWidget *widget, gpointer data) | |
950 { | |
951 SearchData *sd = data; | |
952 | |
953 search_result_remove_selection(sd); | |
954 } | |
955 | |
956 static void sr_menu_clear_cb(GtkWidget *widget, gpointer data) | |
957 { | |
958 SearchData *sd = data; | |
959 | |
960 search_result_clear(sd); | |
961 } | |
962 | |
963 static GtkWidget *search_result_menu(SearchData *sd, gint on_row, gint empty) | |
964 { | |
965 GtkWidget *menu; | |
966 GtkWidget *item; | |
967 | |
968 menu = popup_menu_short_lived(); | |
969 menu_item_add_sensitive(menu, _("_View"), on_row, | |
970 G_CALLBACK(sr_menu_view_cb), sd); | |
971 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, on_row, | |
972 G_CALLBACK(sr_menu_viewnew_cb), sd); | |
973 menu_item_add_divider(menu); | |
974 menu_item_add_sensitive(menu, _("Select all"), !empty, | |
975 G_CALLBACK(sr_menu_select_all_cb), sd); | |
976 menu_item_add_sensitive(menu, _("Select none"), !empty, | |
977 G_CALLBACK(sr_menu_select_none_cb), sd); | |
978 menu_item_add_divider(menu); | |
979 submenu_add_edit(menu, &item, G_CALLBACK(sr_menu_edit_cb), sd); | |
980 if (!on_row) gtk_widget_set_sensitive(item, FALSE); | |
981 menu_item_add_stock_sensitive(menu, _("_Properties"), GTK_STOCK_PROPERTIES, on_row, | |
982 G_CALLBACK(sr_menu_info_cb), sd); | |
983 menu_item_add_stock_sensitive(menu, _("Add to new collection"), GTK_STOCK_INDEX, on_row, | |
984 G_CALLBACK(sr_menu_collection_cb), sd); | |
985 menu_item_add_stock_sensitive(menu, _("Print..."), GTK_STOCK_PRINT, on_row, | |
986 G_CALLBACK(sr_menu_print_cb), sd); | |
987 menu_item_add_divider(menu); | |
988 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, on_row, | |
989 G_CALLBACK(sr_menu_copy_cb), sd); | |
990 menu_item_add_sensitive(menu, _("_Move..."), on_row, | |
991 G_CALLBACK(sr_menu_move_cb), sd); | |
992 menu_item_add_sensitive(menu, _("_Rename..."), on_row, | |
993 G_CALLBACK(sr_menu_rename_cb), sd); | |
994 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, on_row, | |
995 G_CALLBACK(sr_menu_delete_cb), sd); | |
996 menu_item_add_divider(menu); | |
997 menu_item_add_stock_sensitive(menu, _("Rem_ove"), GTK_STOCK_REMOVE, on_row, | |
998 G_CALLBACK(sr_menu_remove_cb), sd); | |
999 menu_item_add_stock_sensitive(menu, _("C_lear"), GTK_STOCK_CLEAR, !empty, | |
1000 G_CALLBACK(sr_menu_clear_cb), sd); | |
1001 | |
1002 return menu; | |
1003 } | |
1004 | |
1005 static void search_result_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
1006 { | |
1007 SearchData *sd = data; | |
1008 GtkTreePath *tpath; | |
1009 gint cx, cy, cw, ch; | |
1010 | |
1011 gtk_tree_view_get_cursor(GTK_TREE_VIEW(sd->result_view), &tpath, NULL); | |
1012 if (!tpath) return; | |
1013 | |
1014 tree_view_get_cell_clamped(GTK_TREE_VIEW(sd->result_view), tpath, | |
1015 SEARCH_COLUMN_NAME - 1, TRUE, &cx, &cy, &cw, &ch); | |
1016 gtk_tree_path_free(tpath); | |
1017 cy += ch; | |
1018 popup_menu_position_clamp(menu, &cx, &cy, 0); | |
1019 *x = cx; | |
1020 *y = cy; | |
1021 } | |
1022 | |
1023 /* | |
1024 *------------------------------------------------------------------- | |
1025 * result list input | |
1026 *------------------------------------------------------------------- | |
1027 */ | |
1028 | |
1029 static gint search_result_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
1030 { | |
1031 SearchData *sd = data; | |
1032 GtkTreeModel *store; | |
1033 GtkTreePath *tpath; | |
1034 GtkTreeIter iter; | |
1035 FileData *fd = NULL; | |
1036 | |
1037 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
1038 | |
1039 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
1040 &tpath, NULL, NULL, NULL)) | |
1041 { | |
1042 gtk_tree_model_get_iter(store, &iter, tpath); | |
1043 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
1044 gtk_tree_path_free(tpath); | |
1045 } | |
1046 | |
1047 sd->click_fd = fd; | |
1048 | |
1049 if (bevent->button == 3) | |
1050 { | |
1051 GtkWidget *menu; | |
1052 | |
1053 menu = search_result_menu(sd, (fd != NULL), (search_result_count(sd, NULL) == 0)); | |
1054 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, bevent->button, bevent->time); | |
1055 } | |
1056 | |
1057 if (!fd) return FALSE; | |
1058 | |
1059 if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS) | |
1060 { | |
1061 layout_image_set_path(NULL, fd->path); | |
1062 } | |
1063 | |
1064 if (bevent->button == 2) return TRUE; | |
1065 | |
1066 if (bevent->button == 3) | |
1067 { | |
1068 if (!search_result_row_selected(sd, fd)) | |
1069 { | |
1070 GtkTreeSelection *selection; | |
1071 | |
1072 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
1073 gtk_tree_selection_unselect_all(selection); | |
1074 gtk_tree_selection_select_iter(selection, &iter); | |
1075 | |
1076 tpath = gtk_tree_model_get_path(store, &iter); | |
1077 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
1078 gtk_tree_path_free(tpath); | |
1079 } | |
1080 return TRUE; | |
1081 } | |
1082 | |
1083 if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS && | |
1084 !(bevent->state & GDK_SHIFT_MASK ) && | |
1085 !(bevent->state & GDK_CONTROL_MASK ) && | |
1086 search_result_row_selected(sd, fd)) | |
1087 { | |
1088 /* this selection handled on release_cb */ | |
1089 gtk_widget_grab_focus(widget); | |
1090 return TRUE; | |
1091 } | |
1092 | |
1093 return FALSE; | |
1094 } | |
1095 | |
1096 static gint search_result_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
1097 { | |
1098 SearchData *sd = data; | |
1099 GtkTreeModel *store; | |
1100 GtkTreePath *tpath; | |
1101 GtkTreeIter iter; | |
1102 | |
1103 FileData *fd = NULL; | |
1104 | |
1105 if (bevent->button != 1 && bevent->button != 2) return TRUE; | |
1106 | |
1107 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
1108 | |
1109 if ((bevent->x != 0 || bevent->y != 0) && | |
1110 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
1111 &tpath, NULL, NULL, NULL)) | |
1112 { | |
1113 gtk_tree_model_get_iter(store, &iter, tpath); | |
1114 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
1115 gtk_tree_path_free(tpath); | |
1116 } | |
1117 | |
1118 if (bevent->button == 2) | |
1119 { | |
1120 if (fd && sd->click_fd == fd) | |
1121 { | |
1122 GtkTreeSelection *selection; | |
1123 | |
1124 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
1125 if (search_result_row_selected(sd, fd)) | |
1126 { | |
1127 gtk_tree_selection_unselect_iter(selection, &iter); | |
1128 } | |
1129 else | |
1130 { | |
1131 gtk_tree_selection_select_iter(selection, &iter); | |
1132 } | |
1133 } | |
1134 return TRUE; | |
1135 } | |
1136 | |
1137 if (fd && sd->click_fd == fd && | |
1138 !(bevent->state & GDK_SHIFT_MASK ) && | |
1139 !(bevent->state & GDK_CONTROL_MASK ) && | |
1140 search_result_row_selected(sd, fd)) | |
1141 { | |
1142 GtkTreeSelection *selection; | |
1143 | |
1144 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
1145 gtk_tree_selection_unselect_all(selection); | |
1146 gtk_tree_selection_select_iter(selection, &iter); | |
1147 | |
1148 tpath = gtk_tree_model_get_path(store, &iter); | |
1149 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
1150 gtk_tree_path_free(tpath); | |
1151 | |
1152 return TRUE; | |
1153 } | |
1154 | |
1155 return FALSE; | |
1156 } | |
1157 | |
1158 static gint search_result_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
1159 { | |
1160 SearchData *sd = data; | |
1161 gint stop_signal = FALSE; | |
1162 GtkTreeModel *store; | |
1163 GtkTreeSelection *selection; | |
1164 GList *slist; | |
1165 FileData *fd = NULL; | |
1166 | |
1167 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view)); | |
1168 slist = gtk_tree_selection_get_selected_rows(selection, &store); | |
1169 if (slist) | |
1170 { | |
1171 GtkTreePath *tpath; | |
1172 GtkTreeIter iter; | |
1173 GList *last; | |
1174 | |
1175 last = g_list_last(slist); | |
1176 tpath = last->data; | |
1177 | |
1178 /* last is newest selected file */ | |
1179 gtk_tree_model_get_iter(store, &iter, tpath); | |
1180 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &fd, -1); | |
1181 } | |
1182 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1183 g_list_free(slist); | |
1184 | |
1185 if (event->state & GDK_CONTROL_MASK) | |
1186 { | |
1187 gint edit_val = -1; | |
1188 | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1189 stop_signal = TRUE; |
9 | 1190 switch (event->keyval) |
1191 { | |
1192 case '1': | |
1193 edit_val = 0; | |
1194 break; | |
1195 case '2': | |
1196 edit_val = 1; | |
1197 break; | |
1198 case '3': | |
1199 edit_val = 2; | |
1200 break; | |
1201 case '4': | |
1202 edit_val = 3; | |
1203 break; | |
1204 case '5': | |
1205 edit_val = 4; | |
1206 break; | |
1207 case '6': | |
1208 edit_val = 5; | |
1209 break; | |
1210 case '7': | |
1211 edit_val = 6; | |
1212 break; | |
1213 case '8': | |
1214 edit_val = 7; | |
1215 break; | |
1216 case '9': | |
1217 edit_val = 8; | |
1218 break; | |
1219 case '0': | |
1220 edit_val = 9; | |
1221 break; | |
1222 case 'C': case 'c': | |
1223 file_util_copy(NULL, search_result_selection_list(sd), NULL, widget); | |
1224 break; | |
1225 case 'M': case 'm': | |
1226 file_util_move(NULL, search_result_selection_list(sd), NULL, widget); | |
1227 break; | |
1228 case 'R': case 'r': | |
1229 file_util_rename(NULL, search_result_selection_list(sd), widget); | |
1230 break; | |
1231 case 'D': case 'd': | |
1232 file_util_delete(NULL, search_result_selection_list(sd), widget); | |
1233 break; | |
1234 case 'P': case 'p': | |
1235 info_window_new(NULL, search_result_selection_list(sd)); | |
1236 break; | |
1237 case 'A': case 'a': | |
1238 if (event->state & GDK_SHIFT_MASK) | |
1239 { | |
1240 gtk_tree_selection_unselect_all(selection); | |
1241 } | |
1242 else | |
1243 { | |
1244 gtk_tree_selection_select_all(selection); | |
1245 } | |
1246 break; | |
1247 case GDK_Delete: case GDK_KP_Delete: | |
1248 search_result_clear(sd); | |
1249 break; | |
1250 default: | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1251 stop_signal = FALSE; |
9 | 1252 break; |
1253 } | |
1254 | |
1255 if (edit_val >= 0) | |
1256 { | |
1257 search_result_edit_selected(sd, edit_val); | |
1258 } | |
1259 } | |
1260 else | |
1261 { | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1262 stop_signal = TRUE; |
9 | 1263 switch (event->keyval) |
1264 { | |
1265 case GDK_Return: case GDK_KP_Enter: | |
1266 if (fd) layout_image_set_path(NULL, fd->path); | |
1267 break; | |
1268 case 'V': case 'v': | |
1269 { | |
1270 GList *list; | |
1271 | |
1272 list = search_result_selection_list(sd); | |
1273 view_window_new_from_list(list); | |
1274 path_list_free(list); | |
1275 } | |
1276 break; | |
1277 case GDK_Delete: case GDK_KP_Delete: | |
1278 search_result_remove_selection(sd); | |
1279 break; | |
1280 case 'C': case 'c': | |
1281 search_result_collection_from_selection(sd); | |
1282 break; | |
1283 case GDK_Menu: | |
1284 case GDK_F10: | |
1285 { | |
1286 GtkWidget *menu; | |
1287 | |
1288 sd->click_fd = fd; | |
1289 menu = search_result_menu(sd, (fd != NULL), (search_result_count(sd, NULL) > 0)); | |
1290 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, | |
1291 search_result_menu_pos_cb, sd, 0, GDK_CURRENT_TIME); | |
1292 } | |
1293 break; | |
1294 default: | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1295 stop_signal = FALSE; |
9 | 1296 break; |
1297 } | |
1298 } | |
1299 | |
1300 return stop_signal; | |
1301 } | |
1302 | |
1303 static gint search_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
1304 { | |
1305 SearchData *sd = data; | |
1306 gint stop_signal = FALSE; | |
1307 | |
1308 if (event->state & GDK_CONTROL_MASK) | |
1309 { | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1310 stop_signal = TRUE; |
9 | 1311 switch (event->keyval) |
1312 { | |
1313 case 'T': case 't': | |
1314 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sd->button_thumbs), | |
1315 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sd->button_thumbs))); | |
1316 break; | |
1317 case 'W': case 'w': | |
1318 search_window_close(sd); | |
1319 break; | |
1320 default: | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1321 stop_signal = FALSE; |
9 | 1322 break; |
1323 } | |
1324 } | |
1325 | |
1326 return stop_signal; | |
1327 } | |
1328 | |
1329 /* | |
1330 *------------------------------------------------------------------- | |
1331 * dnd | |
1332 *------------------------------------------------------------------- | |
1333 */ | |
1334 | |
1335 static GtkTargetEntry result_drag_types[] = { | |
1336 { "text/uri-list", 0, TARGET_URI_LIST }, | |
1337 { "text/plain", 0, TARGET_TEXT_PLAIN } | |
1338 }; | |
1339 static gint n_result_drag_types = 2; | |
1340 | |
1341 static void search_dnd_data_set(GtkWidget *widget, GdkDragContext *context, | |
1342 GtkSelectionData *selection_data, guint info, | |
1343 guint time, gpointer data) | |
1344 { | |
1345 SearchData *sd = data; | |
1346 gchar *uri_text; | |
1347 gint length; | |
1348 GList *list; | |
1349 | |
1350 switch (info) | |
1351 { | |
1352 case TARGET_URI_LIST: | |
1353 case TARGET_TEXT_PLAIN: | |
1354 list = search_result_selection_list(sd); | |
1355 if (!list) return; | |
1356 uri_text = uri_text_from_list(list, &length, (info == TARGET_TEXT_PLAIN)); | |
1357 path_list_free(list); | |
1358 break; | |
1359 default: | |
1360 uri_text = NULL; | |
1361 break; | |
1362 } | |
1363 | |
1364 if (uri_text) gtk_selection_data_set(selection_data, selection_data->target, | |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1365 8, (guchar *)uri_text, length); |
9 | 1366 g_free(uri_text); |
1367 } | |
1368 | |
1369 static void search_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
1370 { | |
1371 SearchData *sd = data; | |
1372 | |
1373 if (sd->click_fd && !search_result_row_selected(sd, sd->click_fd)) | |
1374 { | |
1375 GtkListStore *store; | |
1376 GtkTreeIter iter; | |
1377 | |
1378 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); | |
1379 if (search_result_find_row(sd, sd->click_fd, &iter) >= 0) | |
1380 { | |
1381 GtkTreeSelection *selection; | |
1382 GtkTreePath *tpath; | |
1383 | |
1384 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
1385 gtk_tree_selection_unselect_all(selection); | |
1386 gtk_tree_selection_select_iter(selection, &iter); | |
1387 | |
1388 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); | |
1389 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
1390 gtk_tree_path_free(tpath); | |
1391 } | |
1392 } | |
1393 | |
1394 if (sd->thumb_enable && | |
1395 sd->click_fd && sd->click_fd->pixbuf) | |
1396 { | |
1397 dnd_set_drag_icon(widget, context, sd->click_fd->pixbuf, search_result_selection_count(sd, NULL)); | |
1398 } | |
1399 } | |
1400 | |
1401 static void search_dnd_init(SearchData *sd) | |
1402 { | |
1403 gtk_drag_source_set(sd->result_view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
1404 result_drag_types, n_result_drag_types, | |
1405 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
1406 g_signal_connect(G_OBJECT(sd->result_view), "drag_data_get", | |
1407 G_CALLBACK(search_dnd_data_set), sd); | |
1408 g_signal_connect(G_OBJECT(sd->result_view), "drag_begin", | |
1409 G_CALLBACK(search_dnd_begin), sd); | |
1410 #if 0 | |
1411 g_signal_connect(G_OBJECT(sd->result_view), "drag_end", | |
1412 G_CALLBACK(search_dnd_end), sd); | |
1413 #endif | |
1414 | |
1415 } | |
1416 | |
1417 /* | |
1418 *------------------------------------------------------------------- | |
1419 * search core | |
1420 *------------------------------------------------------------------- | |
1421 */ | |
1422 | |
1423 #define MATCH_IS_BETWEEN(val, a, b) (b > a ? (val >= a && val <= b) : (val >= b && val <= a)) | |
1424 | |
1425 static gint search_step_cb(gpointer data); | |
1426 | |
1427 | |
1428 static void search_buffer_flush(SearchData *sd) | |
1429 { | |
1430 GList *work; | |
1431 | |
1432 work = g_list_last(sd->search_buffer_list); | |
1433 while (work) | |
1434 { | |
1435 MatchFileData *mfd = work->data; | |
1436 work = work->prev; | |
1437 | |
1438 search_result_append(sd, mfd); | |
1439 } | |
1440 | |
1441 g_list_free(sd->search_buffer_list); | |
1442 sd->search_buffer_list = NULL; | |
1443 sd->search_buffer_count = 0; | |
1444 } | |
1445 | |
1446 static void search_stop(SearchData *sd) | |
1447 { | |
1448 if (sd->search_idle_id != -1) | |
1449 { | |
1450 g_source_remove(sd->search_idle_id); | |
1451 sd->search_idle_id = -1; | |
1452 } | |
1453 | |
1454 image_loader_free(sd->img_loader); | |
1455 sd->img_loader = NULL; | |
1456 cache_sim_data_free(sd->img_cd); | |
1457 sd->img_cd = NULL; | |
1458 | |
1459 cache_sim_data_free(sd->search_similarity_cd); | |
1460 sd->search_similarity_cd = NULL; | |
1461 | |
1462 search_buffer_flush(sd); | |
1463 | |
1464 filelist_free(sd->search_folder_list); | |
1465 sd->search_folder_list = NULL; | |
1466 | |
1467 g_list_free(sd->search_done_list); | |
1468 sd->search_done_list = NULL; | |
1469 | |
1470 filelist_free(sd->search_file_list); | |
1471 sd->search_file_list = NULL; | |
1472 | |
1473 gtk_widget_set_sensitive(sd->box_search, TRUE); | |
1474 spinner_set_interval(sd->spinner, -1); | |
1475 gtk_widget_set_sensitive(sd->button_start, TRUE); | |
1476 gtk_widget_set_sensitive(sd->button_stop, FALSE); | |
1477 search_progress_update(sd, TRUE, -1.0); | |
1478 search_status_update(sd); | |
1479 } | |
1480 | |
1481 static void search_file_load_process(SearchData *sd, CacheData *cd) | |
1482 { | |
1483 GdkPixbuf *pixbuf; | |
1484 | |
1485 pixbuf = image_loader_get_pixbuf(sd->img_loader); | |
1486 | |
1487 if (cd && pixbuf) | |
1488 { | |
1489 if (!cd->dimensions) | |
1490 { | |
1491 cache_sim_data_set_dimensions(cd, gdk_pixbuf_get_width(pixbuf), | |
1492 gdk_pixbuf_get_height(pixbuf)); | |
1493 } | |
1494 | |
1495 if (sd->match_similarity_enable && !cd->similarity) | |
1496 { | |
1497 ImageSimilarityData *sim; | |
1498 | |
1499 sim = image_sim_new_from_pixbuf(pixbuf); | |
1500 cache_sim_data_set_similarity(cd, sim); | |
1501 image_sim_free(sim); | |
1502 } | |
1503 | |
1504 if (enable_thumb_caching && | |
1505 sd->img_loader && sd->img_loader->path) | |
1506 { | |
1507 gchar *base; | |
1508 const gchar *path; | |
1509 mode_t mode = 0755; | |
1510 | |
1511 path = sd->img_loader->path; | |
1512 base = cache_get_location(CACHE_TYPE_SIM, path, FALSE, &mode); | |
1513 if (cache_ensure_dir_exists(base, mode)) | |
1514 { | |
1515 g_free(cd->path); | |
1516 cd->path = cache_get_location(CACHE_TYPE_SIM, path, TRUE, NULL); | |
1517 if (cache_sim_data_save(cd)) | |
1518 { | |
1519 filetime_set(cd->path, filetime(sd->img_loader->path)); | |
1520 } | |
1521 } | |
1522 g_free(base); | |
1523 } | |
1524 } | |
1525 | |
1526 image_loader_free(sd->img_loader); | |
1527 sd->img_loader = NULL; | |
1528 | |
1529 sd->search_idle_id = g_idle_add(search_step_cb, sd); | |
1530 } | |
1531 | |
1532 static void search_file_load_done_cb(ImageLoader *il, gpointer data) | |
1533 { | |
1534 SearchData *sd = data; | |
1535 search_file_load_process(sd, sd->img_cd); | |
1536 } | |
1537 | |
1538 static gint search_file_do_extra(SearchData *sd, FileData *fd, gint *match, | |
1539 gint *width, gint *height, gint *simval) | |
1540 { | |
1541 gint new_data = FALSE; | |
1542 gint tmatch = TRUE; | |
1543 gint tested = FALSE; | |
1544 | |
1545 if (!sd->img_cd) | |
1546 { | |
1547 gchar *cd_path; | |
1548 | |
1549 new_data = TRUE; | |
1550 | |
1551 cd_path = cache_find_location(CACHE_TYPE_SIM, fd->path); | |
1552 if (cd_path && filetime(fd->path) == filetime(cd_path)) | |
1553 { | |
1554 sd->img_cd = cache_sim_data_load(cd_path); | |
1555 } | |
1556 g_free(cd_path); | |
1557 } | |
1558 | |
1559 if (!sd->img_cd) | |
1560 { | |
1561 sd->img_cd = cache_sim_data_new(); | |
1562 } | |
1563 | |
1564 if (new_data) | |
1565 { | |
1566 if ((sd->match_dimensions_enable && !sd->img_cd->dimensions) || | |
1567 (sd->match_similarity_enable && !sd->img_cd->similarity)) | |
1568 { | |
1569 sd->img_loader = image_loader_new(fd->path); | |
1570 image_loader_set_error_func(sd->img_loader, search_file_load_done_cb, sd); | |
1571 if (image_loader_start(sd->img_loader, search_file_load_done_cb, sd)) | |
1572 { | |
1573 return TRUE; | |
1574 } | |
1575 else | |
1576 { | |
1577 image_loader_free(sd->img_loader); | |
1578 sd->img_loader = NULL; | |
1579 } | |
1580 } | |
1581 } | |
1582 | |
1583 if (tmatch && sd->match_dimensions_enable && sd->img_cd->dimensions) | |
1584 { | |
1585 CacheData *cd = sd->img_cd; | |
1586 | |
1587 tmatch = FALSE; | |
1588 tested = TRUE; | |
1589 | |
1590 if (sd->match_dimensions == SEARCH_MATCH_EQUAL) | |
1591 { | |
1592 tmatch = (cd->width == sd->search_width && cd->height == sd->search_height); | |
1593 } | |
1594 else if (sd->match_dimensions == SEARCH_MATCH_UNDER) | |
1595 { | |
1596 tmatch = (cd->width < sd->search_width && cd->height < sd->search_height); | |
1597 } | |
1598 else if (sd->match_dimensions == SEARCH_MATCH_OVER) | |
1599 { | |
1600 tmatch = (cd->width > sd->search_width && cd->height > sd->search_height); | |
1601 } | |
1602 else if (sd->match_dimensions == SEARCH_MATCH_BETWEEN) | |
1603 { | |
1604 tmatch = (MATCH_IS_BETWEEN(cd->width, sd->search_width, sd->search_width_end) && | |
1605 MATCH_IS_BETWEEN(cd->height, sd->search_height, sd->search_height_end)); | |
1606 } | |
1607 } | |
1608 | |
1609 if (tmatch && sd->match_similarity_enable && sd->img_cd->similarity) | |
1610 { | |
1611 gdouble value = 0.0; | |
1612 | |
1613 tmatch = FALSE; | |
1614 tested = TRUE; | |
1615 | |
1616 /* fixme: implement similarity checking */ | |
1617 if (sd->search_similarity_cd && sd->search_similarity_cd->similarity) | |
1618 { | |
1619 gdouble result; | |
1620 | |
1621 result = image_sim_compare_fast(sd->search_similarity_cd->sim, sd->img_cd->sim, | |
1622 (gdouble)sd->search_similarity / 100.0); | |
1623 result *= 100.0; | |
1624 if (result >= (gdouble)sd->search_similarity) | |
1625 { | |
1626 tmatch = TRUE; | |
1627 value = (gint)result; | |
1628 } | |
1629 } | |
1630 | |
1631 if (simval) *simval = value; | |
1632 } | |
1633 | |
1634 if (sd->img_cd->dimensions) | |
1635 { | |
1636 if (width) *width = sd->img_cd->width; | |
1637 if (height) *height = sd->img_cd->height; | |
1638 } | |
1639 | |
1640 cache_sim_data_free(sd->img_cd); | |
1641 sd->img_cd = NULL; | |
1642 | |
1643 *match = (tmatch && tested); | |
1644 | |
1645 return FALSE; | |
1646 } | |
1647 | |
1648 static gint search_file_next(SearchData *sd) | |
1649 { | |
1650 FileData *fd; | |
1651 gint match = TRUE; | |
1652 gint tested = FALSE; | |
1653 gint extra_only = FALSE; | |
1654 gint width = 0; | |
1655 gint height = 0; | |
1656 gint sim = 0; | |
1657 | |
1658 if (!sd->search_file_list) return FALSE; | |
1659 | |
1660 if (sd->img_cd) | |
1661 { | |
1662 /* on end of a CacheData load, skip recomparing non-extra match types */ | |
1663 extra_only = TRUE; | |
1664 match = FALSE; | |
1665 } | |
1666 else | |
1667 { | |
1668 sd->search_total++; | |
1669 } | |
1670 | |
1671 fd = sd->search_file_list->data; | |
1672 | |
1673 if (match && sd->match_name_enable && sd->search_name) | |
1674 { | |
1675 tested = TRUE; | |
1676 match = FALSE; | |
1677 | |
1678 if (sd->match_name == SEARCH_MATCH_EQUAL) | |
1679 { | |
1680 if (sd->search_name_match_case) | |
1681 { | |
1682 match = (strcmp(fd->name, sd->search_name) == 0); | |
1683 } | |
1684 else | |
1685 { | |
1686 match = (strcasecmp(fd->name, sd->search_name) == 0); | |
1687 } | |
1688 } | |
1689 else if (sd->match_name == SEARCH_MATCH_CONTAINS) | |
1690 { | |
1691 if (sd->search_name_match_case) | |
1692 { | |
1693 match = (strstr(fd->name, sd->search_name) != NULL); | |
1694 } | |
1695 else | |
1696 { | |
1697 /* sd->search_name is converted in search_start() */ | |
1698 gchar *haystack = g_utf8_strdown(fd->name, -1); | |
1699 match = (strstr(haystack, sd->search_name) != NULL); | |
1700 g_free(haystack); | |
1701 } | |
1702 } | |
1703 } | |
1704 | |
1705 if (match && sd->match_size_enable) | |
1706 { | |
1707 tested = TRUE; | |
1708 match = FALSE; | |
1709 | |
1710 if (sd->match_size == SEARCH_MATCH_EQUAL) | |
1711 { | |
1712 match = (fd->size == sd->search_size); | |
1713 } | |
1714 else if (sd->match_size == SEARCH_MATCH_UNDER) | |
1715 { | |
1716 match = (fd->size < sd->search_size); | |
1717 } | |
1718 else if (sd->match_size == SEARCH_MATCH_OVER) | |
1719 { | |
1720 match = (fd->size > sd->search_size); | |
1721 } | |
1722 else if (sd->match_size == SEARCH_MATCH_BETWEEN) | |
1723 { | |
1724 match = MATCH_IS_BETWEEN(fd->size, sd->search_size, sd->search_size_end); | |
1725 } | |
1726 } | |
1727 | |
1728 if (match && sd->match_date_enable) | |
1729 { | |
1730 tested = TRUE; | |
1731 match = FALSE; | |
1732 | |
1733 if (sd->match_date == SEARCH_MATCH_EQUAL) | |
1734 { | |
1735 struct tm *lt; | |
1736 | |
1737 lt = localtime(&fd->date); | |
1738 match = (lt && | |
1739 lt->tm_year == sd->search_date_y - 1900 && | |
1740 lt->tm_mon == sd->search_date_m - 1 && | |
1741 lt->tm_mday == sd->search_date_d); | |
1742 } | |
1743 else if (sd->match_date == SEARCH_MATCH_UNDER) | |
1744 { | |
1745 match = (fd->date < convert_dmy_to_time(sd->search_date_d, sd->search_date_m, sd->search_date_y)); | |
1746 } | |
1747 else if (sd->match_date == SEARCH_MATCH_OVER) | |
1748 { | |
1749 match = (fd->date > convert_dmy_to_time(sd->search_date_d, sd->search_date_m, sd->search_date_y) + 60 * 60 * 24 - 1); | |
1750 } | |
1751 else if (sd->match_date == SEARCH_MATCH_BETWEEN) | |
1752 { | |
1753 time_t a = convert_dmy_to_time(sd->search_date_d, sd->search_date_m, sd->search_date_y); | |
1754 time_t b = convert_dmy_to_time(sd->search_date_end_d, sd->search_date_end_m, sd->search_date_end_y); | |
1755 | |
1756 if (b >= a) | |
1757 { | |
1758 b += 60 * 60 * 24 - 1; | |
1759 } | |
1760 else | |
1761 { | |
1762 a += 60 * 60 * 24 - 1; | |
1763 } | |
1764 match = MATCH_IS_BETWEEN(fd->date, a, b); | |
1765 } | |
1766 } | |
1767 | |
1768 if (match && sd->match_keywords_enable && sd->search_keyword_list) | |
1769 { | |
1770 GList *list; | |
1771 | |
1772 tested = TRUE; | |
1773 match = FALSE; | |
1774 | |
1775 if (comment_cache_read(fd->path, &list, NULL)) | |
1776 { | |
1777 GList *needle; | |
1778 GList *haystack; | |
1779 | |
1780 if (sd->match_keywords == SEARCH_MATCH_ALL) | |
1781 { | |
1782 gint found = TRUE; | |
1783 | |
1784 needle = sd->search_keyword_list; | |
1785 while (needle && found) | |
1786 { | |
1787 found = FALSE; | |
1788 haystack = list; | |
1789 while (haystack && !found) | |
1790 { | |
1791 found = (strcasecmp((gchar *)needle->data, | |
1792 (gchar *)haystack->data) == 0); | |
1793 haystack = haystack->next; | |
1794 } | |
1795 needle = needle->next; | |
1796 } | |
1797 | |
1798 match = found; | |
1799 } | |
1800 else if (sd->match_keywords == SEARCH_MATCH_ANY) | |
1801 { | |
1802 gint found = FALSE; | |
1803 | |
1804 needle = sd->search_keyword_list; | |
1805 while (needle && !found) | |
1806 { | |
1807 haystack = list; | |
1808 while (haystack && !found) | |
1809 { | |
1810 found = (strcasecmp((gchar *)needle->data, | |
1811 (gchar *)haystack->data) == 0); | |
1812 haystack = haystack->next; | |
1813 } | |
1814 needle = needle->next; | |
1815 } | |
1816 | |
1817 match = found; | |
1818 } | |
1819 else if (sd->match_keywords == SEARCH_MATCH_NONE) | |
1820 { | |
1821 gint found = FALSE; | |
1822 | |
1823 needle = sd->search_keyword_list; | |
1824 while (needle && !found) | |
1825 { | |
1826 haystack = list; | |
1827 while (haystack && !found) | |
1828 { | |
1829 found = (strcasecmp((gchar *)needle->data, | |
1830 (gchar *)haystack->data) == 0); | |
1831 haystack = haystack->next; | |
1832 } | |
1833 needle = needle->next; | |
1834 } | |
1835 | |
1836 match = !found; | |
1837 } | |
1838 path_list_free(list); | |
1839 } | |
1840 else | |
1841 { | |
1842 match = (sd->match_keywords == SEARCH_MATCH_NONE); | |
1843 } | |
1844 } | |
1845 | |
1846 if ((match || extra_only) && | |
1847 (sd->match_dimensions_enable || sd->match_similarity_enable)) | |
1848 { | |
1849 tested = TRUE; | |
1850 | |
1851 if (search_file_do_extra(sd, fd, &match, &width, &height, &sim)) | |
1852 { | |
1853 sd->search_buffer_count += SEARCH_BUFFER_MATCH_LOAD; | |
1854 return TRUE; | |
1855 } | |
1856 } | |
1857 | |
1858 sd->search_file_list = g_list_remove(sd->search_file_list, fd); | |
1859 | |
1860 if (tested && match) | |
1861 { | |
1862 MatchFileData *mfd; | |
1863 | |
1864 mfd = g_new(MatchFileData, 1); | |
1865 memcpy(mfd, fd, sizeof(FileData)); | |
1866 g_free(fd); | |
1867 | |
1868 mfd->width = width; | |
1869 mfd->height = height; | |
1870 mfd->rank = sim; | |
1871 | |
1872 sd->search_buffer_list = g_list_prepend(sd->search_buffer_list, mfd); | |
1873 sd->search_buffer_count += SEARCH_BUFFER_MATCH_HIT; | |
1874 sd->search_count++; | |
1875 search_progress_update(sd, TRUE, -1.0); | |
1876 } | |
1877 else | |
1878 { | |
1879 file_data_free(fd); | |
1880 sd->search_buffer_count += SEARCH_BUFFER_MATCH_MISS; | |
1881 } | |
1882 | |
1883 return FALSE; | |
1884 } | |
1885 | |
1886 static gint search_step_cb(gpointer data) | |
1887 { | |
1888 SearchData *sd = data; | |
1889 FileData *fd; | |
1890 | |
1891 if (sd->search_buffer_count > SEARCH_BUFFER_FLUSH_SIZE) | |
1892 { | |
1893 search_buffer_flush(sd); | |
1894 search_progress_update(sd, TRUE, -1.0); | |
1895 } | |
1896 | |
1897 if (sd->search_file_list) | |
1898 { | |
1899 if (search_file_next(sd)) | |
1900 { | |
1901 sd->search_idle_id = -1; | |
1902 return FALSE; | |
1903 } | |
1904 return TRUE; | |
1905 } | |
1906 | |
1907 if (!sd->search_file_list && !sd->search_folder_list) | |
1908 { | |
1909 sd->search_idle_id = -1; | |
1910 | |
1911 search_stop(sd); | |
1912 search_result_thumb_step(sd); | |
1913 | |
1914 return FALSE; | |
1915 } | |
1916 | |
1917 fd = sd->search_folder_list->data; | |
1918 | |
1919 if (g_list_find(sd->search_done_list, fd) == NULL) | |
1920 { | |
1921 GList *list = NULL; | |
1922 GList *dlist = NULL; | |
1923 gint success = FALSE; | |
1924 | |
1925 sd->search_done_list = g_list_prepend(sd->search_done_list, fd); | |
1926 | |
1927 if (sd->search_type == SEARCH_MATCH_NONE) | |
1928 { | |
1929 success = filelist_read(fd->path, &list, &dlist); | |
1930 } | |
1931 else if (sd->search_type == SEARCH_MATCH_ALL && | |
1932 sd->search_path && | |
1933 strlen(fd->path) >= strlen(sd->search_path)) | |
1934 { | |
1935 const gchar *path; | |
1936 | |
1937 path = fd->path + strlen(sd->search_path); | |
1938 if (path != fd->path) success = filelist_read(path, &list, NULL); | |
1939 success |= filelist_read(fd->path, NULL, &dlist); | |
1940 if (success) | |
1941 { | |
1942 GList *work; | |
1943 | |
1944 work = list; | |
1945 while (work) | |
1946 { | |
1947 FileData *fdp; | |
1948 GList *link; | |
1949 gchar *meta_path; | |
1950 | |
1951 fdp = work->data; | |
1952 link = work; | |
1953 work = work->next; | |
1954 | |
1955 meta_path = cache_find_location(CACHE_TYPE_METADATA, fdp->path); | |
1956 if (!meta_path) | |
1957 { | |
1958 list = g_list_delete_link(list, link); | |
1959 file_data_free(fdp); | |
1960 } | |
1961 g_free(meta_path); | |
1962 } | |
1963 } | |
1964 } | |
1965 | |
1966 if (success) | |
1967 { | |
1968 list = filelist_sort(list, SORT_NAME, TRUE); | |
1969 sd->search_file_list = list; | |
1970 | |
1971 if (sd->search_path_recurse) | |
1972 { | |
1973 dlist = filelist_sort(dlist, SORT_NAME, TRUE); | |
1974 sd->search_folder_list = g_list_concat(dlist, sd->search_folder_list); | |
1975 } | |
1976 else | |
1977 { | |
1978 filelist_free(dlist); | |
1979 } | |
1980 } | |
1981 } | |
1982 else | |
1983 { | |
1984 sd->search_folder_list = g_list_remove(sd->search_folder_list, fd); | |
1985 sd->search_done_list = g_list_remove(sd->search_done_list, fd); | |
1986 file_data_free(fd); | |
1987 } | |
1988 | |
1989 return TRUE; | |
1990 } | |
1991 | |
1992 static void search_similarity_load_done_cb(ImageLoader *il, gpointer data) | |
1993 { | |
1994 SearchData *sd = data; | |
1995 search_file_load_process(sd, sd->search_similarity_cd); | |
1996 } | |
1997 | |
1998 static void search_start(SearchData *sd) | |
1999 { | |
2000 search_stop(sd); | |
2001 search_result_clear(sd); | |
2002 | |
2003 if (sd->search_path) | |
2004 { | |
2005 sd->search_folder_list = g_list_prepend(sd->search_folder_list, | |
2006 file_data_new_simple(sd->search_path)); | |
2007 } | |
2008 | |
2009 if (!sd->search_name_match_case) | |
2010 { | |
2011 /* convert to lowercase here, so that this is only done once per search */ | |
2012 gchar *tmp = g_utf8_strdown(sd->search_name, -1); | |
2013 g_free(sd->search_name); | |
2014 sd->search_name = tmp; | |
2015 } | |
2016 | |
2017 sd->search_count = 0; | |
2018 sd->search_total = 0; | |
2019 | |
2020 gtk_widget_set_sensitive(sd->box_search, FALSE); | |
2021 spinner_set_interval(sd->spinner, SPINNER_SPEED); | |
2022 gtk_widget_set_sensitive(sd->button_start, FALSE); | |
2023 gtk_widget_set_sensitive(sd->button_stop, TRUE); | |
2024 search_progress_update(sd, TRUE, -1.0); | |
2025 | |
2026 if (sd->match_similarity_enable && | |
2027 !sd->search_similarity_cd && | |
2028 isfile(sd->search_similarity_path)) | |
2029 { | |
2030 gchar *cd_path; | |
2031 | |
2032 cd_path = cache_find_location(CACHE_TYPE_SIM, sd->search_similarity_path); | |
2033 if (cd_path && filetime(sd->search_similarity_path) == filetime(cd_path)) | |
2034 { | |
2035 sd->search_similarity_cd = cache_sim_data_load(cd_path); | |
2036 } | |
2037 g_free(cd_path); | |
2038 | |
2039 if (!sd->search_similarity_cd || !sd->search_similarity_cd->similarity) | |
2040 { | |
2041 if (!sd->search_similarity_cd) | |
2042 { | |
2043 sd->search_similarity_cd = cache_sim_data_new(); | |
2044 } | |
2045 | |
2046 sd->img_loader = image_loader_new(sd->search_similarity_path); | |
2047 image_loader_set_error_func(sd->img_loader, search_similarity_load_done_cb, sd); | |
2048 if (image_loader_start(sd->img_loader, search_similarity_load_done_cb, sd)) | |
2049 { | |
2050 return; | |
2051 } | |
2052 image_loader_free(sd->img_loader); | |
2053 sd->img_loader = NULL; | |
2054 } | |
2055 | |
2056 } | |
2057 | |
2058 sd->search_idle_id = g_idle_add(search_step_cb, sd); | |
2059 } | |
2060 | |
2061 static void search_start_cb(GtkWidget *widget, gpointer data) | |
2062 { | |
2063 SearchData *sd = data; | |
2064 GtkTreeViewColumn *column; | |
2065 gchar *path; | |
2066 | |
2067 if (sd->search_folder_list) | |
2068 { | |
2069 search_stop(sd); | |
2070 search_result_thumb_step(sd); | |
2071 return; | |
2072 } | |
2073 | |
2074 if (sd->match_name_enable) history_combo_append_history(sd->entry_name, NULL); | |
2075 g_free(sd->search_name); | |
2076 sd->search_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(sd->entry_name))); | |
2077 | |
2078 g_free(sd->search_similarity_path); | |
2079 sd->search_similarity_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(sd->entry_similarity))); | |
2080 if (sd->match_similarity_enable) | |
2081 { | |
2082 if (!isfile(sd->search_similarity_path)) | |
2083 { | |
2084 file_util_warning_dialog(_("File not found"), | |
2085 _("Please enter an existing file for image content."), | |
2086 GTK_STOCK_DIALOG_WARNING, sd->window); | |
2087 return; | |
2088 } | |
2089 tab_completion_append_to_history(sd->entry_similarity, sd->search_similarity_path); | |
2090 } | |
2091 | |
2092 path_list_free(sd->search_keyword_list); | |
2093 sd->search_keyword_list = keyword_list_pull(sd->entry_keywords); | |
2094 | |
2095 date_selection_get(sd->date_sel, &sd->search_date_d, &sd->search_date_m, &sd->search_date_y); | |
2096 date_selection_get(sd->date_sel_end, &sd->search_date_end_d, &sd->search_date_end_m, &sd->search_date_end_y); | |
2097 | |
2098 column = gtk_tree_view_get_column(GTK_TREE_VIEW(sd->result_view), SEARCH_COLUMN_RANK - 1); | |
2099 gtk_tree_view_column_set_visible(column, sd->match_similarity_enable); | |
2100 if (!sd->match_similarity_enable) | |
2101 { | |
2102 GtkTreeSortable *sortable; | |
2103 gint id; | |
2104 GtkSortType order; | |
2105 | |
2106 sortable = GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view))); | |
2107 if (gtk_tree_sortable_get_sort_column_id(sortable, &id, &order) && | |
2108 id == SEARCH_COLUMN_RANK) | |
2109 { | |
2110 gtk_tree_sortable_set_sort_column_id(sortable, SEARCH_COLUMN_PATH, GTK_SORT_ASCENDING); | |
2111 } | |
2112 } | |
2113 | |
2114 if (sd->search_type == SEARCH_MATCH_NONE) | |
2115 { | |
2116 /* search path */ | |
2117 | |
2118 path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(sd->path_entry))); | |
2119 if (isdir(path)) | |
2120 { | |
2121 g_free(sd->search_path); | |
2122 sd->search_path = path; | |
2123 path = NULL; | |
2124 | |
2125 tab_completion_append_to_history(sd->path_entry, sd->search_path); | |
2126 | |
2127 search_start(sd); | |
2128 } | |
2129 else | |
2130 { | |
2131 file_util_warning_dialog(_("Folder not found"), | |
2132 _("Please enter an existing folder to search."), | |
2133 GTK_STOCK_DIALOG_WARNING, sd->window); | |
2134 } | |
2135 | |
2136 g_free(path); | |
2137 } | |
2138 else if (sd->search_type == SEARCH_MATCH_ALL) | |
2139 { | |
2140 /* search metadata */ | |
2141 | |
2142 g_free(sd->search_path); | |
2143 sd->search_path = g_strconcat(homedir(), "/", GQVIEW_CACHE_RC_METADATA, NULL); | |
2144 | |
2145 search_start(sd); | |
2146 } | |
2147 else if (sd->search_type == SEARCH_MATCH_CONTAINS) | |
2148 { | |
2149 /* search current result list */ | |
2150 GList *list; | |
2151 | |
2152 list = search_result_refine_list(sd); | |
2153 | |
2154 g_free(sd->search_path); | |
2155 sd->search_path = NULL; | |
2156 | |
2157 search_start(sd); | |
2158 | |
2159 sd->search_file_list = g_list_concat(sd->search_file_list, list); | |
2160 } | |
2161 } | |
2162 | |
2163 /* | |
2164 *------------------------------------------------------------------- | |
2165 * window construct | |
2166 *------------------------------------------------------------------- | |
2167 */ | |
2168 | |
2169 enum { | |
2170 MENU_CHOICE_COLUMN_NAME = 0, | |
2171 MENU_CHOICE_COLUMN_VALUE | |
2172 }; | |
2173 | |
2174 static void search_thumb_toggle_cb(GtkWidget *button, gpointer data) | |
2175 { | |
2176 SearchData *sd = data; | |
2177 | |
2178 search_result_thumb_enable(sd, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))); | |
2179 } | |
2180 | |
2181 static gint sort_matchdata_dimensions(MatchFileData *a, MatchFileData *b) | |
2182 { | |
2183 gint sa; | |
2184 gint sb; | |
2185 | |
2186 sa = a->width * a->height; | |
2187 sb = b->width * b->height; | |
2188 | |
2189 if (sa > sb) return 1; | |
2190 if (sa < sb) return -1; | |
2191 return 0; | |
2192 } | |
2193 | |
2194 static gint search_result_sort_cb(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data) | |
2195 { | |
2196 gint n = GPOINTER_TO_INT(data); | |
2197 FileData *fda; | |
2198 FileData *fdb; | |
2199 | |
2200 gtk_tree_model_get(model, a, SEARCH_COLUMN_POINTER, &fda, -1); | |
2201 gtk_tree_model_get(model, b, SEARCH_COLUMN_POINTER, &fdb, -1); | |
2202 | |
2203 if (!fda || !fdb) return 0; | |
2204 | |
2205 switch (n) | |
2206 { | |
2207 case SEARCH_COLUMN_RANK: | |
2208 if (((MatchFileData *)fda)->rank > ((MatchFileData *)fdb)->rank) return 1; | |
2209 if (((MatchFileData *)fda)->rank < ((MatchFileData *)fdb)->rank) return -1; | |
2210 return 0; | |
2211 break; | |
2212 case SEARCH_COLUMN_NAME: | |
2213 return CASE_SORT(fda->name, fdb->name); | |
2214 break; | |
2215 case SEARCH_COLUMN_SIZE: | |
2216 if (fda->size > fdb->size) return 1; | |
2217 if (fda->size < fdb->size) return -1; | |
2218 return 0; | |
2219 break; | |
2220 case SEARCH_COLUMN_DATE: | |
2221 if (fda->date > fdb->date) return 1; | |
2222 if (fda->date < fdb->date) return -1; | |
2223 return 0; | |
2224 break; | |
2225 case SEARCH_COLUMN_DIMENSIONS: | |
2226 return sort_matchdata_dimensions((MatchFileData *)fda, (MatchFileData *)fdb); | |
2227 break; | |
2228 case SEARCH_COLUMN_PATH: | |
2229 return CASE_SORT(fda->path, fdb->path); | |
2230 break; | |
2231 default: | |
2232 break; | |
2233 } | |
2234 | |
2235 return 0; | |
2236 } | |
2237 | |
2238 static void search_result_add_column(SearchData * sd, gint n, const gchar *title, gint image, gint right_justify) | |
2239 { | |
2240 GtkTreeViewColumn *column; | |
2241 GtkCellRenderer *renderer; | |
2242 | |
2243 column = gtk_tree_view_column_new(); | |
2244 gtk_tree_view_column_set_title(column, title); | |
2245 gtk_tree_view_column_set_min_width(column, 4); | |
2246 | |
2247 if (n != SEARCH_COLUMN_THUMB) gtk_tree_view_column_set_resizable(column, TRUE); | |
2248 | |
2249 if (!image) | |
2250 { | |
2251 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
2252 renderer = gtk_cell_renderer_text_new(); | |
2253 if (right_justify) g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); | |
2254 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
2255 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
2256 | |
2257 gtk_tree_view_column_set_sort_column_id(column, n); | |
2258 } | |
2259 else | |
2260 { | |
2261 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
2262 renderer = gtk_cell_renderer_pixbuf_new(); | |
2263 cell_renderer_height_override(renderer); | |
2264 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
2265 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n); | |
2266 } | |
2267 | |
2268 gtk_tree_view_append_column(GTK_TREE_VIEW(sd->result_view), column); | |
2269 } | |
2270 | |
2271 static void menu_choice_set_visible(GtkWidget *widget, gint visible) | |
2272 { | |
2273 if (visible) | |
2274 { | |
2275 if (!GTK_WIDGET_VISIBLE(widget)) gtk_widget_show(widget); | |
2276 } | |
2277 else | |
2278 { | |
2279 if (GTK_WIDGET_VISIBLE(widget)) gtk_widget_hide(widget); | |
2280 } | |
2281 } | |
2282 | |
2283 static void menu_choice_path_cb(GtkWidget *combo, gpointer data) | |
2284 { | |
2285 SearchData *sd = data; | |
2286 GtkTreeModel *store; | |
2287 GtkTreeIter iter; | |
2288 | |
2289 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | |
2290 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; | |
2291 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->search_type, -1); | |
2292 | |
2293 menu_choice_set_visible(gtk_widget_get_parent(sd->check_recurse), | |
2294 (sd->search_type == SEARCH_MATCH_NONE)); | |
2295 } | |
2296 | |
2297 static void menu_choice_name_cb(GtkWidget *combo, gpointer data) | |
2298 { | |
2299 SearchData *sd = data; | |
2300 GtkTreeModel *store; | |
2301 GtkTreeIter iter; | |
2302 | |
2303 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | |
2304 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; | |
2305 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_name, -1); | |
2306 } | |
2307 | |
2308 static void menu_choice_size_cb(GtkWidget *combo, gpointer data) | |
2309 { | |
2310 SearchData *sd = data; | |
2311 GtkTreeModel *store; | |
2312 GtkTreeIter iter; | |
2313 | |
2314 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | |
2315 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; | |
2316 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_size, -1); | |
2317 | |
2318 menu_choice_set_visible(gtk_widget_get_parent(sd->spin_size_end), | |
2319 (sd->match_size == SEARCH_MATCH_BETWEEN)); | |
2320 } | |
2321 | |
2322 static void menu_choice_date_cb(GtkWidget *combo, gpointer data) | |
2323 { | |
2324 SearchData *sd = data; | |
2325 GtkTreeModel *store; | |
2326 GtkTreeIter iter; | |
2327 | |
2328 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | |
2329 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; | |
2330 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_date, -1); | |
2331 | |
2332 menu_choice_set_visible(gtk_widget_get_parent(sd->date_sel_end), | |
2333 (sd->match_date == SEARCH_MATCH_BETWEEN)); | |
2334 } | |
2335 | |
2336 static void menu_choice_dimensions_cb(GtkWidget *combo, gpointer data) | |
2337 { | |
2338 SearchData *sd = data; | |
2339 GtkTreeModel *store; | |
2340 GtkTreeIter iter; | |
2341 | |
2342 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | |
2343 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; | |
2344 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_dimensions, -1); | |
2345 | |
2346 menu_choice_set_visible(gtk_widget_get_parent(sd->spin_width_end), | |
2347 (sd->match_dimensions == SEARCH_MATCH_BETWEEN)); | |
2348 } | |
2349 | |
2350 static void menu_choice_keyword_cb(GtkWidget *combo, gpointer data) | |
2351 { | |
2352 SearchData *sd = data; | |
2353 GtkTreeModel *store; | |
2354 GtkTreeIter iter; | |
2355 | |
2356 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | |
2357 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; | |
2358 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_keywords, -1); | |
2359 } | |
2360 | |
2361 static void menu_choice_spin_cb(GtkAdjustment *adjustment, gpointer data) | |
2362 { | |
2363 gint *value = data; | |
2364 | |
2365 *value = (gint)gtk_adjustment_get_value(adjustment); | |
2366 } | |
2367 | |
2368 static GtkWidget *menu_spin(GtkWidget *box, gdouble min, gdouble max, gint value, | |
2369 GCallback func, gpointer data) | |
2370 { | |
2371 GtkWidget *spin; | |
2372 GtkAdjustment *adj; | |
2373 | |
2374 spin = gtk_spin_button_new_with_range(min, max, 1); | |
2375 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), (gdouble)value); | |
2376 adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(spin)); | |
2377 if (func) g_signal_connect(G_OBJECT(adj), "value_changed", | |
2378 G_CALLBACK(func), data); | |
2379 gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0); | |
2380 gtk_widget_show(spin); | |
2381 | |
2382 return spin; | |
2383 } | |
2384 | |
2385 static void menu_choice_check_cb(GtkWidget *button, gpointer data) | |
2386 { | |
2387 GtkWidget *widget = data; | |
2388 gboolean active; | |
2389 gboolean *value; | |
2390 | |
2391 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); | |
2392 gtk_widget_set_sensitive(widget, active); | |
2393 | |
2394 value = g_object_get_data(G_OBJECT(button), "check_var"); | |
2395 if (value) *value = active; | |
2396 } | |
2397 | |
2398 static GtkWidget *menu_choice_menu(const MatchList *items, gint item_count, | |
2399 GCallback func, gpointer data) | |
2400 { | |
2401 GtkWidget *combo; | |
2402 GtkCellRenderer *renderer; | |
2403 GtkListStore *store; | |
2404 gint i; | |
2405 | |
2406 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); | |
2407 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); | |
2408 g_object_unref(store); | |
2409 | |
2410 renderer = gtk_cell_renderer_text_new(); | |
2411 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); | |
2412 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, | |
2413 "text", MENU_CHOICE_COLUMN_NAME, NULL); | |
2414 | |
2415 for (i = 0; i < item_count; i++) | |
2416 { | |
2417 GtkTreeIter iter; | |
2418 | |
2419 gtk_list_store_append(store, &iter); | |
2420 gtk_list_store_set(store, &iter, MENU_CHOICE_COLUMN_NAME, _(items[i].text), | |
2421 MENU_CHOICE_COLUMN_VALUE, items[i].type, -1); | |
2422 } | |
2423 | |
2424 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | |
2425 | |
2426 if (func) g_signal_connect(G_OBJECT(combo), "changed", | |
2427 G_CALLBACK(func), data); | |
2428 | |
2429 return combo; | |
2430 } | |
2431 | |
2432 static GtkWidget *menu_choice(GtkWidget *box, GtkWidget **check, GtkWidget **menu, | |
2433 const gchar *text, gboolean *value, | |
2434 const MatchList *items, gint item_count, | |
2435 GCallback func, gpointer data) | |
2436 { | |
2437 GtkWidget *base_box; | |
2438 GtkWidget *hbox; | |
2439 GtkWidget *button; | |
2440 GtkWidget *option; | |
2441 | |
2442 base_box = gtk_hbox_new(FALSE, PREF_PAD_GAP); | |
2443 gtk_box_pack_start(GTK_BOX(box), base_box, FALSE, FALSE, 0); | |
2444 gtk_widget_show(base_box); | |
2445 | |
2446 button = gtk_check_button_new(); | |
2447 if (value) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *value); | |
2448 gtk_box_pack_start(GTK_BOX(base_box), button, FALSE, FALSE, 0); | |
2449 gtk_widget_show(button); | |
2450 if (check) *check = button; | |
2451 if (value) g_object_set_data(G_OBJECT(button), "check_var", value); | |
2452 | |
2453 hbox = gtk_hbox_new(FALSE, PREF_PAD_SPACE); | |
2454 gtk_box_pack_start(GTK_BOX(base_box), hbox, TRUE, TRUE, 0); | |
2455 gtk_widget_show(hbox); | |
2456 | |
2457 g_signal_connect(G_OBJECT(button), "toggled", | |
2458 G_CALLBACK(menu_choice_check_cb), hbox); | |
2459 gtk_widget_set_sensitive(hbox, (value) ? *value : FALSE); | |
2460 | |
2461 pref_label_new(hbox, text); | |
2462 | |
2463 if (!items && !menu) return hbox; | |
2464 | |
2465 option = menu_choice_menu(items, item_count, func, data); | |
2466 gtk_box_pack_start(GTK_BOX(hbox), option, FALSE, FALSE, 0); | |
2467 gtk_widget_show(option); | |
2468 if (menu) *menu = option; | |
2469 | |
2470 return hbox; | |
2471 } | |
2472 | |
2473 static void search_window_close(SearchData *sd) | |
2474 { | |
2475 gtk_widget_destroy(sd->window); | |
2476 } | |
2477 | |
2478 static gint search_window_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
2479 { | |
2480 SearchData *sd = data; | |
2481 | |
2482 search_window_close(sd); | |
2483 return TRUE; | |
2484 } | |
2485 | |
2486 static void search_window_destroy_cb(GtkWidget *widget, gpointer data) | |
2487 { | |
2488 SearchData *sd = data; | |
2489 | |
2490 search_window_list = g_list_remove(search_window_list, sd); | |
2491 | |
2492 search_result_update_idle_cancel(sd); | |
2493 | |
2494 filelist_free(sd->search_buffer_list); | |
2495 sd->search_buffer_list = NULL; | |
2496 | |
2497 search_stop(sd); | |
2498 search_result_clear(sd); | |
2499 | |
2500 g_free(sd->search_path); | |
2501 g_free(sd->search_name); | |
2502 g_free(sd->search_similarity_path); | |
2503 path_list_free(sd->search_keyword_list); | |
2504 | |
2505 g_free(sd); | |
2506 } | |
2507 | |
2508 void search_new(const gchar *path, const gchar *example_file) | |
2509 { | |
2510 SearchData *sd; | |
2511 GtkWidget *vbox; | |
2512 GtkWidget *hbox; | |
2513 GtkWidget *hbox2; | |
2514 GtkWidget *pad_box; | |
2515 GtkWidget *frame; | |
2516 GtkWidget *scrolled; | |
2517 GtkListStore *store; | |
2518 GtkTreeSortable *sortable; | |
2519 GtkTreeSelection *selection; | |
2520 GtkWidget *combo; | |
2521 GdkGeometry geometry; | |
2522 | |
2523 sd = g_new0(SearchData, 1); | |
2524 | |
2525 sd->search_path = g_strdup(path); | |
2526 sd->search_path_recurse = TRUE; | |
2527 sd->search_size = 0; | |
2528 sd->search_width = 640; | |
2529 sd->search_height = 480; | |
2530 sd->search_width_end = 1024; | |
2531 sd->search_height_end = 768; | |
2532 sd->search_name = NULL; | |
2533 sd->search_name_match_case = FALSE; | |
2534 | |
2535 sd->search_type = SEARCH_MATCH_NONE; | |
2536 | |
2537 sd->match_name = SEARCH_MATCH_CONTAINS; | |
2538 sd->match_size = SEARCH_MATCH_EQUAL; | |
2539 sd->match_date = SEARCH_MATCH_EQUAL; | |
2540 sd->match_dimensions = SEARCH_MATCH_EQUAL; | |
2541 sd->match_keywords = SEARCH_MATCH_ALL; | |
2542 | |
2543 sd->match_name_enable = TRUE; | |
2544 sd->match_size_enable = FALSE; | |
2545 sd->match_date_enable = FALSE; | |
2546 sd->match_dimensions_enable = FALSE; | |
2547 sd->match_similarity_enable = FALSE; | |
2548 sd->match_keywords_enable = FALSE; | |
2549 | |
2550 sd->search_similarity = 95; | |
2551 sd->search_similarity_path = g_strdup(example_file); | |
2552 sd->search_similarity_cd = NULL; | |
2553 | |
2554 sd->search_idle_id = -1; | |
2555 sd->update_idle_id = -1; | |
2556 | |
2557 sd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
2558 window_set_icon(sd->window, NULL, NULL); | |
2559 | |
2560 gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE); | |
2561 gtk_window_set_title(GTK_WINDOW(sd->window), _("Image search - GQview")); | |
2562 gtk_window_set_wmclass(GTK_WINDOW(sd->window), "search", "GQview"); | |
2563 | |
2564 geometry.min_width = 32; | |
2565 geometry.min_height = 32; | |
2566 geometry.base_width = DEF_SEARCH_WIDTH; | |
2567 geometry.base_height = DEF_SEARCH_HEIGHT; | |
2568 gtk_window_set_geometry_hints(GTK_WINDOW(sd->window), NULL, &geometry, | |
2569 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE); | |
2570 | |
2571 gtk_window_set_default_size(GTK_WINDOW(sd->window), DEF_SEARCH_WIDTH, DEF_SEARCH_HEIGHT); | |
2572 | |
2573 g_signal_connect(G_OBJECT(sd->window), "delete_event", | |
2574 G_CALLBACK(search_window_delete_cb), sd); | |
2575 g_signal_connect(G_OBJECT(sd->window), "destroy", | |
2576 G_CALLBACK(search_window_destroy_cb), sd); | |
2577 | |
2578 g_signal_connect(G_OBJECT(sd->window), "key_press_event", | |
2579 G_CALLBACK(search_window_keypress_cb), sd); | |
2580 | |
2581 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
2582 gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_GAP); | |
2583 gtk_container_add(GTK_CONTAINER(sd->window), vbox); | |
2584 gtk_widget_show(vbox); | |
2585 | |
2586 sd->box_search = pref_box_new(vbox, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); | |
2587 | |
2588 hbox = pref_box_new(sd->box_search, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); | |
2589 | |
2590 pref_label_new(hbox, _("Search:")); | |
2591 | |
2592 sd->menu_path = menu_choice_menu(text_search_menu_path, sizeof(text_search_menu_path) / sizeof(MatchList), | |
2593 G_CALLBACK(menu_choice_path_cb), sd); | |
2594 gtk_box_pack_start(GTK_BOX(hbox), sd->menu_path, FALSE, FALSE, 0); | |
2595 gtk_widget_show(sd->menu_path); | |
2596 | |
2597 hbox2 = pref_box_new(hbox, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); | |
2598 combo = tab_completion_new_with_history(&sd->path_entry, sd->search_path, | |
2599 "search_path", -1, | |
2600 NULL, NULL); | |
2601 tab_completion_add_select_button(sd->path_entry, NULL, TRUE); | |
2602 gtk_box_pack_start(GTK_BOX(hbox2), combo, TRUE, TRUE, 0); | |
2603 gtk_widget_show(combo); | |
2604 sd->check_recurse = pref_checkbox_new_int(hbox2, _("Recurse"), | |
2605 sd->search_path_recurse, &sd->search_path_recurse); | |
2606 | |
2607 hbox = menu_choice(sd->box_search, &sd->check_name, &sd->menu_name, | |
2608 _("File name"), &sd->match_name_enable, | |
2609 text_search_menu_name, sizeof(text_search_menu_name) / sizeof(MatchList), | |
2610 G_CALLBACK(menu_choice_name_cb), sd); | |
2611 combo = history_combo_new(&sd->entry_name, "", "search_name", -1); | |
2612 gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0); | |
2613 gtk_widget_show(combo); | |
2614 pref_checkbox_new_int(hbox, _("Match case"), | |
2615 sd->search_name_match_case, &sd->search_name_match_case); | |
2616 | |
2617 hbox = menu_choice(sd->box_search, &sd->check_size, &sd->menu_size, | |
2618 _("File size is"), &sd->match_size_enable, | |
2619 text_search_menu_size, sizeof(text_search_menu_size) / sizeof(MatchList), | |
2620 G_CALLBACK(menu_choice_size_cb), sd); | |
2621 sd->spin_size = menu_spin(hbox, 0, 1024*1024*1024, sd->search_size, | |
2622 G_CALLBACK(menu_choice_spin_cb), &sd->search_size); | |
2623 hbox2 = gtk_hbox_new(FALSE, PREF_PAD_SPACE); | |
2624 gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0); | |
2625 pref_label_new(hbox2, _("and")); | |
2626 sd->spin_size_end = menu_spin(hbox2, 0, 1024*1024*1024, sd->search_size_end, | |
2627 G_CALLBACK(menu_choice_spin_cb), &sd->search_size_end); | |
2628 | |
2629 hbox = menu_choice(sd->box_search, &sd->check_date, &sd->menu_date, | |
2630 _("File date is"), &sd->match_date_enable, | |
2631 text_search_menu_date, sizeof(text_search_menu_date) / sizeof(MatchList), | |
2632 G_CALLBACK(menu_choice_date_cb), sd); | |
2633 sd->date_sel = date_selection_new(); | |
2634 date_selection_time_set(sd->date_sel, time(NULL)); | |
2635 gtk_box_pack_start(GTK_BOX(hbox), sd->date_sel, FALSE, FALSE, 0); | |
2636 gtk_widget_show(sd->date_sel); | |
2637 | |
2638 hbox2 = gtk_hbox_new(FALSE, PREF_PAD_SPACE); | |
2639 gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0); | |
2640 pref_label_new(hbox2, _("and")); | |
2641 sd->date_sel_end = date_selection_new(); | |
2642 date_selection_time_set(sd->date_sel_end, time(NULL)); | |
2643 gtk_box_pack_start(GTK_BOX(hbox2), sd->date_sel_end, FALSE, FALSE, 0); | |
2644 gtk_widget_show(sd->date_sel_end); | |
2645 | |
2646 hbox = menu_choice(sd->box_search, &sd->check_dimensions, &sd->menu_dimensions, | |
2647 _("Image dimensions are"), &sd->match_dimensions_enable, | |
2648 text_search_menu_size, sizeof(text_search_menu_size) / sizeof(MatchList), | |
2649 G_CALLBACK(menu_choice_dimensions_cb), sd); | |
2650 pad_box = pref_box_new(hbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 2); | |
2651 sd->spin_width = menu_spin(pad_box, 0, 1000000, sd->search_width, | |
2652 G_CALLBACK(menu_choice_spin_cb), &sd->search_width); | |
2653 pref_label_new(pad_box, "x"); | |
2654 sd->spin_height = menu_spin(pad_box, 0, 1000000, sd->search_height, | |
2655 G_CALLBACK(menu_choice_spin_cb), &sd->search_height); | |
2656 hbox2 = gtk_hbox_new(FALSE, 2); | |
2657 gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0); | |
2658 pref_label_new(hbox2, _("and")); | |
2659 pref_spacer(hbox2, PREF_PAD_SPACE - 2*2); | |
2660 sd->spin_width_end = menu_spin(hbox2, 0, 1000000, sd->search_width_end, | |
2661 G_CALLBACK(menu_choice_spin_cb), &sd->search_width_end); | |
2662 pref_label_new(hbox2, "x"); | |
2663 sd->spin_height_end = menu_spin(hbox2, 0, 1000000, sd->search_height_end, | |
2664 G_CALLBACK(menu_choice_spin_cb), &sd->search_height_end); | |
2665 | |
2666 hbox = menu_choice(sd->box_search, &sd->check_similarity, NULL, | |
2667 _("Image content is"), &sd->match_similarity_enable, | |
2668 NULL, 0, NULL, sd); | |
2669 sd->spin_similarity = menu_spin(hbox, 80, 100, sd->search_similarity, | |
2670 G_CALLBACK(menu_choice_spin_cb), &sd->search_similarity); | |
2671 | |
2672 /* xgettext:no-c-format */ | |
2673 pref_label_new(hbox, _("% similar to")); | |
2674 | |
2675 combo = tab_completion_new_with_history(&sd->entry_similarity, | |
2676 (sd->search_similarity_path) ? sd->search_similarity_path : "", | |
2677 "search_similarity_path", -1, NULL, NULL); | |
2678 tab_completion_add_select_button(sd->entry_similarity, NULL, FALSE); | |
2679 gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0); | |
2680 gtk_widget_show(combo); | |
2681 | |
2682 hbox = menu_choice(sd->box_search, &sd->check_keywords, &sd->menu_keywords, | |
2683 _("Keywords"), &sd->match_keywords_enable, | |
2684 text_search_menu_keyword, sizeof(text_search_menu_keyword) / sizeof(MatchList), | |
2685 G_CALLBACK(menu_choice_keyword_cb), sd); | |
2686 sd->entry_keywords = gtk_entry_new(); | |
2687 gtk_box_pack_start(GTK_BOX(hbox), sd->entry_keywords, TRUE, TRUE, 0); | |
2688 gtk_widget_set_sensitive(sd->entry_keywords, sd->match_keywords_enable); | |
2689 g_signal_connect(G_OBJECT(sd->check_keywords), "toggled", | |
2690 G_CALLBACK(menu_choice_check_cb), sd->entry_keywords); | |
2691 gtk_widget_show(sd->entry_keywords); | |
2692 | |
2693 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
2694 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
2695 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
2696 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
2697 gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0); | |
2698 gtk_widget_show(scrolled); | |
2699 | |
2700 store = gtk_list_store_new(8, G_TYPE_POINTER, G_TYPE_INT, GDK_TYPE_PIXBUF, | |
2701 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, | |
2702 G_TYPE_STRING, G_TYPE_STRING); | |
2703 | |
2704 /* set up sorting */ | |
2705 sortable = GTK_TREE_SORTABLE(store); | |
2706 gtk_tree_sortable_set_sort_func(sortable, SEARCH_COLUMN_RANK, search_result_sort_cb, | |
2707 GINT_TO_POINTER(SEARCH_COLUMN_RANK), NULL); | |
2708 gtk_tree_sortable_set_sort_func(sortable, SEARCH_COLUMN_NAME, search_result_sort_cb, | |
2709 GINT_TO_POINTER(SEARCH_COLUMN_NAME), NULL); | |
2710 gtk_tree_sortable_set_sort_func(sortable, SEARCH_COLUMN_SIZE, search_result_sort_cb, | |
2711 GINT_TO_POINTER(SEARCH_COLUMN_SIZE), NULL); | |
2712 gtk_tree_sortable_set_sort_func(sortable, SEARCH_COLUMN_DATE, search_result_sort_cb, | |
2713 GINT_TO_POINTER(SEARCH_COLUMN_DATE), NULL); | |
2714 gtk_tree_sortable_set_sort_func(sortable, SEARCH_COLUMN_DIMENSIONS, search_result_sort_cb, | |
2715 GINT_TO_POINTER(SEARCH_COLUMN_DIMENSIONS), NULL); | |
2716 gtk_tree_sortable_set_sort_func(sortable, SEARCH_COLUMN_PATH, search_result_sort_cb, | |
2717 GINT_TO_POINTER(SEARCH_COLUMN_PATH), NULL); | |
2718 | |
2719 #if 0 | |
2720 /* by default, search results are unsorted until user selects a sort column - for speed, | |
2721 * using sort slows search speed by an order of magnitude with 1000's of results :-/ | |
2722 */ | |
2723 gtk_tree_sortable_set_sort_column_id(sortable, SEARCH_COLUMN_PATH, GTK_SORT_ASCENDING); | |
2724 #endif | |
2725 | |
2726 sd->result_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
2727 g_object_unref(store); | |
2728 gtk_container_add(GTK_CONTAINER(scrolled), sd->result_view); | |
2729 gtk_widget_show(sd->result_view); | |
2730 | |
2731 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view)); | |
2732 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE); | |
2733 gtk_tree_selection_set_select_function(selection, search_result_select_cb, sd, NULL); | |
2734 | |
2735 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(sd->result_view), TRUE); | |
2736 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(sd->result_view), FALSE); | |
2737 | |
2738 #if 0 | |
2739 gtk_tree_view_set_search_column(GTK_TREE_VIEW(sd->result_view), SEARCH_COLUMN_NAME); | |
2740 #endif | |
2741 | |
2742 search_result_add_column(sd, SEARCH_COLUMN_RANK, _("Rank"), FALSE, FALSE); | |
2743 search_result_add_column(sd, SEARCH_COLUMN_THUMB, "", TRUE, FALSE); | |
2744 search_result_add_column(sd, SEARCH_COLUMN_NAME, _("Name"), FALSE, FALSE); | |
2745 search_result_add_column(sd, SEARCH_COLUMN_SIZE, _("Size"), FALSE, TRUE); | |
2746 search_result_add_column(sd, SEARCH_COLUMN_DATE, _("Date"), FALSE, TRUE); | |
2747 search_result_add_column(sd, SEARCH_COLUMN_DIMENSIONS, _("Dimensions"), FALSE, FALSE); | |
2748 search_result_add_column(sd, SEARCH_COLUMN_PATH, _("Path"), FALSE, FALSE); | |
2749 | |
2750 search_dnd_init(sd); | |
2751 | |
2752 g_signal_connect(G_OBJECT(sd->result_view), "button_press_event", | |
2753 G_CALLBACK(search_result_press_cb), sd); | |
2754 g_signal_connect(G_OBJECT(sd->result_view), "button_release_event", | |
2755 G_CALLBACK(search_result_release_cb), sd); | |
2756 g_signal_connect(G_OBJECT(sd->result_view), "key_press_event", | |
2757 G_CALLBACK(search_result_keypress_cb), sd); | |
2758 | |
2759 hbox = pref_box_new(vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0); | |
2760 | |
2761 sd->button_thumbs = pref_checkbox_new(hbox, _("Thumbnails"), FALSE, | |
2762 G_CALLBACK(search_thumb_toggle_cb), sd); | |
2763 | |
2764 frame = gtk_frame_new(NULL); | |
2765 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
2766 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, PREF_PAD_SPACE); | |
2767 gtk_widget_show(frame); | |
2768 | |
2769 sd->label_status = gtk_label_new(""); | |
2770 gtk_widget_set_size_request(sd->label_status, 50, -1); | |
2771 gtk_container_add(GTK_CONTAINER(frame), sd->label_status); | |
2772 gtk_widget_show(sd->label_status); | |
2773 | |
2774 sd->label_progress = gtk_progress_bar_new(); | |
2775 gtk_widget_set_size_request(sd->label_progress, 50, -1); | |
2776 gtk_box_pack_start(GTK_BOX(hbox), sd->label_progress, TRUE, TRUE, 0); | |
2777 gtk_widget_show(sd->label_progress); | |
2778 | |
2779 sd->spinner = spinner_new(NULL, -1); | |
2780 gtk_box_pack_start(GTK_BOX(hbox), sd->spinner, FALSE, FALSE, 0); | |
2781 gtk_widget_show(sd->spinner); | |
2782 | |
2783 sd->button_start = pref_button_new(hbox, GTK_STOCK_FIND, NULL, FALSE, | |
2784 G_CALLBACK(search_start_cb), sd); | |
2785 pref_spacer(hbox, PREF_PAD_BUTTON_GAP); | |
2786 sd->button_stop = pref_button_new(hbox, GTK_STOCK_STOP, NULL, FALSE, | |
2787 G_CALLBACK(search_start_cb), sd); | |
2788 gtk_widget_set_sensitive(sd->button_stop, FALSE); | |
2789 | |
2790 search_status_update(sd); | |
2791 search_progress_update(sd, FALSE, -1.0); | |
2792 | |
2793 search_window_list = g_list_append(search_window_list, sd); | |
2794 | |
2795 gtk_widget_show(sd->window); | |
2796 } | |
2797 | |
2798 /* | |
2799 *------------------------------------------------------------------- | |
2800 * maintenance (move, delete, etc.) | |
2801 *------------------------------------------------------------------- | |
2802 */ | |
2803 | |
2804 static void search_result_change_path(SearchData *sd, const gchar *path, const gchar *newpath) | |
2805 { | |
2806 GtkTreeModel *store; | |
2807 GtkTreeIter iter; | |
2808 gint valid; | |
2809 | |
2810 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view)); | |
2811 valid = gtk_tree_model_get_iter_first(store, &iter); | |
2812 while (valid) | |
2813 { | |
2814 GtkTreeIter current; | |
2815 FileData *fd; | |
2816 | |
2817 current = iter; | |
2818 valid = gtk_tree_model_iter_next(store, &iter); | |
2819 | |
2820 gtk_tree_model_get(store, ¤t, SEARCH_COLUMN_POINTER, &fd, -1); | |
2821 if (strcmp(fd->path, path) == 0) | |
2822 { | |
2823 if (newpath) | |
2824 { | |
2825 g_free(fd->path); | |
2826 fd->path = g_strdup(newpath); | |
2827 fd->name = filename_from_path(fd->path); | |
2828 | |
2829 gtk_list_store_set(GTK_LIST_STORE(store), ¤t, | |
2830 SEARCH_COLUMN_NAME, fd->name, | |
2831 SEARCH_COLUMN_PATH, fd->path, -1); | |
2832 } | |
2833 else | |
2834 { | |
2835 search_result_remove_item(sd, fd, ¤t); | |
2836 } | |
2837 } | |
2838 } | |
2839 } | |
2840 | |
2841 void search_maint_renamed(const gchar *source, const gchar *dest) | |
2842 { | |
2843 GList *work; | |
2844 | |
2845 work = search_window_list; | |
2846 while (work) | |
2847 { | |
2848 SearchData *sd = work->data; | |
2849 work = work->next; | |
2850 | |
2851 search_result_change_path(sd, source, dest); | |
2852 } | |
2853 } | |
2854 | |
2855 void search_maint_removed(const gchar *path) | |
2856 { | |
2857 search_maint_renamed(path, NULL); | |
2858 } | |
2859 |