annotate src/search.c @ 1248:f3cb10d0ad0d

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