annotate src/search.c @ 385:2c06e06f4236

Clean up and simplify.
author zas_
date Wed, 16 Apr 2008 18:57:50 +0000
parents 767b53cd9ab7
children 4b2d7f9af171
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * 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
10 */
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
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "search.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "bar_info.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "cache.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "collect-table.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "dnd.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "dupe.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "image-load.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "info.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "editors.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #include "print.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include "thumb.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 #include "ui_spinner.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 #include "ui_tree_edit.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 #define DEF_SEARCH_WIDTH 700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 #define DEF_SEARCH_HEIGHT 450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 #define SEARCH_BUFFER_MATCH_LOAD 20
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 #define SEARCH_BUFFER_MATCH_HIT 5
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 #define SEARCH_BUFFER_MATCH_MISS 1
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 #define SEARCH_BUFFER_FLUSH_SIZE 99
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 SEARCH_MATCH_NONE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 SEARCH_MATCH_EQUAL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 SEARCH_MATCH_CONTAINS,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 SEARCH_MATCH_UNDER,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 SEARCH_MATCH_OVER,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 SEARCH_MATCH_BETWEEN,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 SEARCH_MATCH_ALL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 SEARCH_MATCH_ANY
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 } MatchType;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 SEARCH_COLUMN_POINTER = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 SEARCH_COLUMN_RANK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 SEARCH_COLUMN_THUMB,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 SEARCH_COLUMN_NAME,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 SEARCH_COLUMN_SIZE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 SEARCH_COLUMN_DATE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 SEARCH_COLUMN_DIMENSIONS,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 SEARCH_COLUMN_PATH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 SEARCH_COLUMN_COUNT /* total columns */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 typedef struct _SearchData SearchData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 struct _SearchData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 GtkWidget *window;
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 GtkWidget *button_thumbs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 GtkWidget *label_status;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 GtkWidget *label_progress;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 GtkWidget *button_start;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 GtkWidget *button_stop;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 GtkWidget *spinner;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 GtkWidget *box_search;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 GtkWidget *menu_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 GtkWidget *path_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 GtkWidget *check_recurse;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 GtkWidget *result_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 GtkWidget *check_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 GtkWidget *menu_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 GtkWidget *entry_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 GtkWidget *check_name_match_case;
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_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 GtkWidget *menu_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 GtkWidget *spin_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 GtkWidget *spin_size_end;
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_date;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 GtkWidget *menu_date;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 GtkWidget *date_sel;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 GtkWidget *date_sel_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_dimensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 GtkWidget *menu_dimensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 GtkWidget *spin_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 GtkWidget *spin_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 GtkWidget *spin_width_end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 GtkWidget *spin_height_end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 GtkWidget *check_similarity;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 GtkWidget *spin_similarity;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 GtkWidget *entry_similarity;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 GtkWidget *check_keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 GtkWidget *menu_keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 GtkWidget *entry_keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 gchar *search_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 gint search_path_recurse;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 gchar *search_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 gint search_name_match_case;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 gint64 search_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 gint64 search_size_end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 gint search_date_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 gint search_date_m;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 gint search_date_d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 gint search_date_end_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 gint search_date_end_m;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 gint search_date_end_d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 gint search_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 gint search_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 gint search_width_end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 gint search_height_end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 gint search_similarity;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 gchar *search_similarity_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 CacheData *search_similarity_cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 GList *search_keyword_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 MatchType search_type;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 MatchType match_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 MatchType match_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 MatchType match_date;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 MatchType match_dimensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 MatchType match_keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 gboolean match_name_enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 gboolean match_size_enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 gboolean match_date_enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 gboolean match_dimensions_enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 gboolean match_similarity_enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 gboolean match_keywords_enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 GList *search_folder_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 GList *search_done_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 GList *search_file_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 GList *search_buffer_list;
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 gint search_count;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 gint search_total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 gint search_buffer_count;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 gint search_idle_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 gint update_idle_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 ImageLoader *img_loader;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 CacheData *img_cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 FileData *click_fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 ThumbLoader *thumb_loader;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 gint thumb_enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 FileData *thumb_fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 };
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 typedef struct _MatchFileData MatchFileData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 struct _MatchFileData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
186 FileData *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 gint width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 gint height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 gint rank;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 typedef struct _MatchList MatchList;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 struct _MatchList
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 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 const MatchType type;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 static const MatchList text_search_menu_path[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 { N_("folder"), SEARCH_MATCH_NONE },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 { N_("comments"), SEARCH_MATCH_ALL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 { N_("results"), SEARCH_MATCH_CONTAINS }
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 static const MatchList text_search_menu_name[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 { N_("contains"), SEARCH_MATCH_CONTAINS },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 { N_("is"), SEARCH_MATCH_EQUAL }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 static const MatchList text_search_menu_size[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 { N_("equal to"), SEARCH_MATCH_EQUAL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 { N_("less than"), SEARCH_MATCH_UNDER },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 { N_("greater than"), SEARCH_MATCH_OVER },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 { N_("between"), SEARCH_MATCH_BETWEEN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 };
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 static const MatchList text_search_menu_date[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 { N_("equal to"), SEARCH_MATCH_EQUAL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 { N_("before"), SEARCH_MATCH_UNDER },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 { N_("after"), SEARCH_MATCH_OVER },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 { N_("between"), SEARCH_MATCH_BETWEEN }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 static const MatchList text_search_menu_keyword[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 { N_("match all"), SEARCH_MATCH_ALL },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 { N_("match any"), SEARCH_MATCH_ANY },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 { N_("exclude"), SEARCH_MATCH_NONE }
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 GList *search_window_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 static gint search_result_selection_count(SearchData *sd, gint64 *bytes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 static gint search_result_count(SearchData *sd, gint64 *bytes);
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 static void search_window_close(SearchData *sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 * utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 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
246 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 struct tm lt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 lt.tm_sec = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 lt.tm_min = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 lt.tm_hour = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 lt.tm_mday = day;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 lt.tm_mon = month - 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 lt.tm_year = year - 1900;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 lt.tm_isdst = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 return mktime(&lt);
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 static void search_status_update(SearchData *sd)
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 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 gint t;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 gint s;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 gint64 t_bytes;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 gint64 s_bytes;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 gchar *tt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 gchar *ts;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 t = search_result_count(sd, &t_bytes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 s = search_result_selection_count(sd, &s_bytes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 if (s > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 tt = text_from_size_abrev(t_bytes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 ts = text_from_size_abrev(s_bytes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 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
278 g_free(tt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 g_free(ts);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 tt = text_from_size_abrev(t_bytes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 buf = g_strdup_printf(_("%s, %d files"), tt, t);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 g_free(tt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 }
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 gtk_label_set_text(GTK_LABEL(sd->label_status), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 static void search_progress_update(SearchData *sd, gint search, gdouble thumbs)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 if (search || thumbs >= 0.0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 const gchar *message;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 if (search && (sd->search_folder_list || sd->search_file_list))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 message = _("Searching...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 else if (thumbs >= 0.0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 message = _("Loading thumbs...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 message = "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 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
308 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(sd->label_progress), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(sd->label_progress),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 (thumbs >= 0.0) ? thumbs : 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 g_free(buf);
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 else
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 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(sd->label_progress), "");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 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
317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 * result list
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 *-------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 static gint search_result_find_row(SearchData *sd, FileData *fd, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
336 MatchFileData *mfd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
339 gtk_tree_model_get(store, iter, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
340 if (mfd->fd == fd) return n;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 valid = gtk_tree_model_iter_next(store, iter);
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 return -1;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 static gint search_result_row_selected(SearchData *sd, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 gint found = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 while (!found && work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 GtkTreePath *tpath = work->data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
361 MatchFileData *mfd_n;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 GtkTreeIter iter;
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 gtk_tree_model_get_iter(store, &iter, tpath);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
365 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd_n, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
366 if (mfd_n->fd == fd) found = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 return found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 static gint search_result_selection_util(SearchData *sd, gint64 *bytes, GList **list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 gint64 total = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 GList *plist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 n++;
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 if (bytes || 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 GtkTreePath *tpath = work->data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
396 MatchFileData *mfd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 gtk_tree_model_get_iter(store, &iter, tpath);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
400 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
401 total += mfd->fd->size;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
402
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
403 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
404 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 g_list_free(slist);
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) *bytes = total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 if (list) *list = g_list_reverse(plist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 return n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 }
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 static GList *search_result_selection_list(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 search_result_selection_util(sd, NULL, &list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 static gint search_result_selection_count(SearchData *sd, gint64 *bytes)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 return search_result_selection_util(sd, bytes, NULL);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 static gint search_result_util(SearchData *sd, gint64 *bytes, GList **list)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 gint64 total = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 GList *plist = NULL;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 if (bytes || list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
447 MatchFileData *mfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
448
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
449 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
450 total += mfd->fd->size;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
451
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
452 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
453 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 }
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 if (bytes) *bytes = total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 if (list) *list = g_list_reverse(plist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 return n;
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
463 static GList *search_result_get_filelist(SearchData *sd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 search_result_util(sd, NULL, &list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 static gint search_result_count(SearchData *sd, gint64 *bytes)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 return search_result_util(sd, bytes, NULL);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 static void search_result_append(SearchData *sd, MatchFileData *mfd)
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 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 gchar *text_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 gchar *text_dim = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
484 fd = mfd->fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 if (!fd) return;
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 text_size = text_from_size(fd->size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 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
490
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 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
492 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 gtk_list_store_set(store, &iter,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
494 SEARCH_COLUMN_POINTER, mfd,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 SEARCH_COLUMN_RANK, mfd->rank,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 SEARCH_COLUMN_THUMB, fd->pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 SEARCH_COLUMN_NAME, fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 SEARCH_COLUMN_SIZE, text_size,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 SEARCH_COLUMN_DATE, text_from_time(fd->date),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 SEARCH_COLUMN_DIMENSIONS, text_dim,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 SEARCH_COLUMN_PATH, fd->path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 -1);
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 g_free(text_size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 g_free(text_dim);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 static GList *search_result_refine_list(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
520 MatchFileData *mfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
521
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
522 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
523 list = g_list_prepend(list, mfd->fd);
9
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 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 }
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 /* clear it here, so that the FileData in list is not freed */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 gtk_list_store_clear(GTK_LIST_STORE(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 return g_list_reverse(list);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 static gboolean search_result_free_node(GtkTreeModel *store, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
537 MatchFileData *mfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
538
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
539 gtk_tree_model_get(store, iter, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
540 file_data_unref(mfd->fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
541 g_free(mfd);
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 return FALSE;
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 static void search_result_clear(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 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
551
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 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
553 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 sd->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 thumb_loader_free(sd->thumb_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 sd->thumb_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 sd->thumb_fd = NULL;
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 search_status_update(sd);
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
564 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
565 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
568 if (!mfd || !iter) return;
9
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 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
573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 gtk_list_store_remove(GTK_LIST_STORE(store), iter);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
575 if (sd->click_fd == mfd->fd) sd->click_fd = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
576 if (sd->thumb_fd == mfd->fd) sd->thumb_fd = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
577 file_data_unref(mfd->fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
578 g_free(mfd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 }
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 static void search_result_remove(SearchData *sd, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
591 MatchFileData *mfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
592
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
593 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
594 if (mfd->fd == fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
596 search_result_remove_item(sd, mfd, &iter);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 static void search_result_remove_selection(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 GList *flist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 while (work)
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 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 GtkTreeIter iter;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
619 MatchFileData *mfd;
9
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 gtk_tree_model_get_iter(store, &iter, tpath);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
622 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
623 flist = g_list_prepend(flist, mfd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 work = flist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 work = work->next;
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 search_result_remove(sd, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 g_list_free(flist);
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 search_status_update(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 static void search_result_edit_selected(SearchData *sd, gint n)
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 list = search_result_selection_list(sd);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
647 start_editor_from_filelist(n, list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
648 filelist_free(list);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 static void search_result_collection_from_selection(SearchData *sd)
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 CollectWindow *w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 list = search_result_selection_list(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 w = collection_window_new(NULL);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
658 collection_table_add_filelist(w->table, list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
659 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 }
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 static gint search_result_update_idle_cb(gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 search_status_update(sd);
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 sd->update_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 static void search_result_update_idle_cancel(SearchData *sd)
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 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
675 sd->update_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 static gboolean search_result_select_cb(GtkTreeSelection *selection, GtkTreeModel *store,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 GtkTreePath *tpath, gboolean selected, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 if (sd->update_idle_id == -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 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
686 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 return TRUE;
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
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 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 * result list thumbs
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 static void search_result_thumb_step(SearchData *sd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 static void search_result_thumb_set(SearchData *sd, FileData *fd, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 GtkTreeIter iter_n;
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 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
706 if (!iter)
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 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
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 if (iter) gtk_list_store_set(store, iter, SEARCH_COLUMN_THUMB, fd->pixbuf, -1);
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 static void search_result_thumb_do(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 FileData *fd;
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 if (!sd->thumb_loader || !sd->thumb_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 fd = sd->thumb_fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 if (fd->pixbuf) g_object_unref(fd->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 fd->pixbuf = thumb_loader_get_pixbuf(sd->thumb_loader, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 search_result_thumb_set(sd, fd, NULL);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 static void search_result_thumb_done_cb(ThumbLoader *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 SearchData *sd = data;
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 search_result_thumb_do(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 search_result_thumb_step(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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 static void search_result_thumb_step(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 GtkTreeIter iter;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
739 MatchFileData *mfd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 gint row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 gint length = 0;
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 if (!sd->thumb_enable) return;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 valid = gtk_tree_model_get_iter_first(store, &iter);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
749 while (!mfd && valid)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 length++;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
754 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, SEARCH_COLUMN_THUMB, &pixbuf, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
755 if (pixbuf || mfd->fd->pixbuf)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
757 if (!pixbuf) gtk_list_store_set(GTK_LIST_STORE(store), &iter, SEARCH_COLUMN_THUMB, mfd->fd->pixbuf, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 row++;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
759 mfd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 if (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 while (gtk_tree_model_iter_next(store, &iter)) length++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
768 if (!mfd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 sd->thumb_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 thumb_loader_free(sd->thumb_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 sd->thumb_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 search_progress_update(sd, TRUE, -1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 search_progress_update(sd, FALSE, (gdouble)row/length);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
780 sd->thumb_fd = mfd->fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 thumb_loader_free(sd->thumb_loader);
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
782 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
783
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 thumb_loader_set_callbacks(sd->thumb_loader,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 search_result_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 search_result_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 sd);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
789 if (!thumb_loader_start(sd->thumb_loader, mfd->fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 search_result_thumb_do(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 search_result_thumb_step(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 }
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 static void search_result_thumb_height(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 GtkCellRenderer *cell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 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
803 if (!column) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
805 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
806
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 list = gtk_tree_view_column_get_cell_renderers(column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 cell = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
812 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
813 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 }
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 static void search_result_thumb_enable(SearchData *sd, gint enable)
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 if (sd->thumb_enable == enable) return;
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 if (sd->thumb_enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 thumb_loader_free(sd->thumb_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 sd->thumb_loader = NULL;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 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
834 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 search_progress_update(sd, TRUE, -1.0);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 sd->thumb_enable = enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 search_result_thumb_height(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 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
843 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 * result list menu
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 */
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 static void sr_menu_view_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
855 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
856 }
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 static void sr_menu_viewnew_cb(GtkWidget *widget, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 GList *list;
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 list = search_result_selection_list(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 view_window_new_from_list(list);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
865 filelist_free(list);
9
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 static void sr_menu_select_all_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 GtkTreeSelection *selection;
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 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 gtk_tree_selection_select_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 static void sr_menu_select_none_cb(GtkWidget *widget, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 GtkTreeSelection *selection;
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 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 gtk_tree_selection_unselect_all(selection);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 static void sr_menu_edit_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 SearchData *sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 sd = submenu_item_get_data(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 n = GPOINTER_TO_INT(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 if (!sd) return;
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 search_result_edit_selected(sd, n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 }
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 static void sr_menu_info_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 info_window_new(NULL, search_result_selection_list(sd));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 static void sr_menu_collection_cb(GtkWidget *widget, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 search_result_collection_from_selection(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 static void sr_menu_print_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 SearchData *sd = data;
250
22ed43d4c849 Drop a bunch of unused variables.
zas_
parents: 196
diff changeset
915
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
916 print_window_new(sd->click_fd, search_result_selection_list(sd),
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
917 search_result_get_filelist(sd), sd->window);
9
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_copy_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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 file_util_copy(NULL, search_result_selection_list(sd), NULL, sd->window);
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_move_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 file_util_move(NULL, search_result_selection_list(sd), NULL, sd->window);
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_rename_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;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 file_util_rename(NULL, search_result_selection_list(sd), sd->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 }
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 static void sr_menu_delete_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 file_util_delete(NULL, search_result_selection_list(sd), sd->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 }
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 static void sr_menu_remove_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 search_result_remove_selection(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 }
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 static void sr_menu_clear_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 search_result_clear(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 }
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 static GtkWidget *search_result_menu(SearchData *sd, gint on_row, gint empty)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 GtkWidget *item;
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 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 menu_item_add_sensitive(menu, _("_View"), on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 G_CALLBACK(sr_menu_view_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 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
971 G_CALLBACK(sr_menu_viewnew_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 menu_item_add_sensitive(menu, _("Select all"), !empty,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 G_CALLBACK(sr_menu_select_all_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 menu_item_add_sensitive(menu, _("Select none"), !empty,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 G_CALLBACK(sr_menu_select_none_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 submenu_add_edit(menu, &item, G_CALLBACK(sr_menu_edit_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 if (!on_row) gtk_widget_set_sensitive(item, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 menu_item_add_stock_sensitive(menu, _("_Properties"), GTK_STOCK_PROPERTIES, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 G_CALLBACK(sr_menu_info_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 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
983 G_CALLBACK(sr_menu_collection_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 menu_item_add_stock_sensitive(menu, _("Print..."), GTK_STOCK_PRINT, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 G_CALLBACK(sr_menu_print_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 G_CALLBACK(sr_menu_copy_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 menu_item_add_sensitive(menu, _("_Move..."), on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 G_CALLBACK(sr_menu_move_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 menu_item_add_sensitive(menu, _("_Rename..."), on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 G_CALLBACK(sr_menu_rename_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 G_CALLBACK(sr_menu_delete_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 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
997 G_CALLBACK(sr_menu_remove_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 menu_item_add_stock_sensitive(menu, _("C_lear"), GTK_STOCK_CLEAR, !empty,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 G_CALLBACK(sr_menu_clear_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 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
1005 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 gint cx, cy, cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 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
1011 if (!tpath) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 tree_view_get_cell_clamped(GTK_TREE_VIEW(sd->result_view), tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 SEARCH_COLUMN_NAME - 1, TRUE, &cx, &cy, &cw, &ch);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 cy += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 popup_menu_position_clamp(menu, &cx, &cy, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 *x = cx;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 *y = cy;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 * result list input
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 static gint search_result_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 GtkTreeIter iter;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1034 MatchFileData *mfd = NULL;
9
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
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 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
1039 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 gtk_tree_model_get_iter(store, &iter, tpath);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1042 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 gtk_tree_path_free(tpath);
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1046 sd->click_fd = mfd ? mfd->fd : NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 if (bevent->button == 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1052 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
1053 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
1054 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1056 if (!mfd) return FALSE;
9
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 if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1060 layout_image_set_fd(NULL, mfd->fd);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 if (bevent->button == 2) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 if (bevent->button == 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1067 if (!search_result_row_selected(sd, mfd->fd))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 }
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 if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 !(bevent->state & GDK_SHIFT_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 !(bevent->state & GDK_CONTROL_MASK ) &&
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1085 search_result_row_selected(sd, mfd->fd))
9
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 /* this selection handled on release_cb */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 gtk_widget_grab_focus(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 static gint search_result_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1102 MatchFileData *mfd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 if (bevent->button != 1 && bevent->button != 2) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 if ((bevent->x != 0 || bevent->y != 0) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 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
1110 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 gtk_tree_model_get_iter(store, &iter, tpath);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1113 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 if (bevent->button == 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1119 if (mfd && sd->click_fd == mfd->fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 GtkTreeSelection *selection;
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 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1124 if (search_result_row_selected(sd, mfd->fd))
9
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 gtk_tree_selection_unselect_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1136 if (mfd && sd->click_fd == mfd->fd &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 !(bevent->state & GDK_SHIFT_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 !(bevent->state & GDK_CONTROL_MASK ) &&
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1139 search_result_row_selected(sd, mfd->fd))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 static gint search_result_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 gint stop_signal = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 GList *slist;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1164 MatchFileData *mfd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 if (slist)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 GList *last;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 last = g_list_last(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 tpath = last->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 /* last is newest selected file */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 gtk_tree_model_get_iter(store, &iter, tpath);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1179 gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 if (event->state & GDK_CONTROL_MASK)
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 gint edit_val = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
1188 stop_signal = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 switch (event->keyval)
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 case '1':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 edit_val = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 case '2':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 edit_val = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 case '3':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 edit_val = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 case '4':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 edit_val = 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 case '5':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 edit_val = 4;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 case '6':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 edit_val = 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 case '7':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 edit_val = 6;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 case '8':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 edit_val = 7;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 case '9':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 edit_val = 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 case '0':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 edit_val = 9;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 case 'C': case 'c':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 file_util_copy(NULL, search_result_selection_list(sd), NULL, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 case 'M': case 'm':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 file_util_move(NULL, search_result_selection_list(sd), NULL, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 case 'R': case 'r':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 file_util_rename(NULL, search_result_selection_list(sd), widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 case 'D': case 'd':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 file_util_delete(NULL, search_result_selection_list(sd), widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 case 'P': case 'p':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 info_window_new(NULL, search_result_selection_list(sd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 case 'A': case 'a':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 gtk_tree_selection_select_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 case GDK_Delete: case GDK_KP_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 search_result_clear(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 default:
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
1250 stop_signal = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 if (edit_val >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 search_result_edit_selected(sd, edit_val);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 {
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
1261 stop_signal = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 case GDK_Return: case GDK_KP_Enter:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1265 if (mfd) layout_image_set_fd(NULL, mfd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 case 'V': case 'v':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 GList *list;
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 list = search_result_selection_list(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 view_window_new_from_list(list);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1273 filelist_free(list);
9
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 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 case GDK_Delete: case GDK_KP_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 search_result_remove_selection(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 case 'C': case 'c':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 search_result_collection_from_selection(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 case GDK_F10:
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 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1287 sd->click_fd = mfd->fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1288 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
1289 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 search_result_menu_pos_cb, sd, 0, GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 default:
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
1294 stop_signal = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 return stop_signal;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 static gint search_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 gint stop_signal = FALSE;
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 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 {
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
1309 stop_signal = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 case 'T': case 't':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sd->button_thumbs),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sd->button_thumbs)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 case 'W': case 'w':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 search_window_close(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 default:
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
1320 stop_signal = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325 return stop_signal;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327
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 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 * dnd
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 *-------------------------------------------------------------------
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 GtkTargetEntry result_drag_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 { "text/uri-list", 0, TARGET_URI_LIST },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 { "text/plain", 0, TARGET_TEXT_PLAIN }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 static gint n_result_drag_types = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 static void search_dnd_data_set(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342 guint time, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 gchar *uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 gint length;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 list = search_result_selection_list(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 if (!list) return;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1355 uri_text = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1356 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360 break;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 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
1364 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 static void search_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
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 SearchData *sd = data;
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 if (sd->click_fd && !search_result_row_selected(sd, sd->click_fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377 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
1378 if (search_result_find_row(sd, sd->click_fd, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 GtkTreePath *tpath;
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 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 if (sd->thumb_enable &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 sd->click_fd && sd->click_fd->pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 dnd_set_drag_icon(widget, context, sd->click_fd->pixbuf, search_result_selection_count(sd, NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397 }
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_init(SearchData *sd)
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 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
1403 result_drag_types, n_result_drag_types,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 g_signal_connect(G_OBJECT(sd->result_view), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406 G_CALLBACK(search_dnd_data_set), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 g_signal_connect(G_OBJECT(sd->result_view), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 G_CALLBACK(search_dnd_begin), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 g_signal_connect(G_OBJECT(sd->result_view), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 G_CALLBACK(search_dnd_end), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418 * search core
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 #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
1423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 static gint search_step_cb(gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 static void search_buffer_flush(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 GList *work;
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 work = g_list_last(sd->search_buffer_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 while (work)
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 MatchFileData *mfd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 search_result_append(sd, mfd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 g_list_free(sd->search_buffer_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 sd->search_buffer_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 sd->search_buffer_count = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 static void search_stop(SearchData *sd)
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 if (sd->search_idle_id != -1)
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 g_source_remove(sd->search_idle_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450 sd->search_idle_id = -1;
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 image_loader_free(sd->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 sd->img_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455 cache_sim_data_free(sd->img_cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 sd->img_cd = NULL;
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 cache_sim_data_free(sd->search_similarity_cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 sd->search_similarity_cd = NULL;
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 search_buffer_flush(sd);
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 filelist_free(sd->search_folder_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 sd->search_folder_list = NULL;
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 g_list_free(sd->search_done_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467 sd->search_done_list = NULL;
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 filelist_free(sd->search_file_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 sd->search_file_list = NULL;
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 gtk_widget_set_sensitive(sd->box_search, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 spinner_set_interval(sd->spinner, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 gtk_widget_set_sensitive(sd->button_start, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475 gtk_widget_set_sensitive(sd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 search_progress_update(sd, TRUE, -1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 search_status_update(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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 static void search_file_load_process(SearchData *sd, CacheData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 GdkPixbuf *pixbuf;
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 pixbuf = image_loader_get_pixbuf(sd->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 if (cd && pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 if (!cd->dimensions)
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_set_dimensions(cd, gdk_pixbuf_get_width(pixbuf),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 gdk_pixbuf_get_height(pixbuf));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 if (sd->match_similarity_enable && !cd->similarity)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 ImageSimilarityData *sim;
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 sim = image_sim_new_from_pixbuf(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 cache_sim_data_set_similarity(cd, sim);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 image_sim_free(sim);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1503 if (options->thumbnails.enable_caching &&
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1504 sd->img_loader && sd->img_loader->fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508 mode_t mode = 0755;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1510 path = sd->img_loader->fd->path;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511 base = cache_get_location(CACHE_TYPE_SIM, path, FALSE, &mode);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512 if (cache_ensure_dir_exists(base, mode))
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 g_free(cd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1515 cd->path = cache_get_location(CACHE_TYPE_SIM, path, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1516 if (cache_sim_data_save(cd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1518 filetime_set(cd->path, filetime(sd->img_loader->fd->path));
9
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1521 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1523 }
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 image_loader_free(sd->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1526 sd->img_loader = NULL;
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 sd->search_idle_id = g_idle_add(search_step_cb, sd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1531 static void search_file_load_done_cb(ImageLoader *il, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1532 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1533 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534 search_file_load_process(sd, sd->img_cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1537 static gint search_file_do_extra(SearchData *sd, FileData *fd, gint *match,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1538 gint *width, gint *height, gint *simval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1539 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1540 gint new_data = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1541 gint tmatch = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1542 gint tested = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1543
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1544 if (!sd->img_cd)
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 gchar *cd_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1547
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1548 new_data = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1550 cd_path = cache_find_location(CACHE_TYPE_SIM, fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1551 if (cd_path && filetime(fd->path) == filetime(cd_path))
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 sd->img_cd = cache_sim_data_load(cd_path);
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 g_free(cd_path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1558 if (!sd->img_cd)
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->img_cd = cache_sim_data_new();
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 if (new_data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1564 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1565 if ((sd->match_dimensions_enable && !sd->img_cd->dimensions) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1566 (sd->match_similarity_enable && !sd->img_cd->similarity))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1568 sd->img_loader = image_loader_new(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1569 image_loader_set_error_func(sd->img_loader, search_file_load_done_cb, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 if (image_loader_start(sd->img_loader, search_file_load_done_cb, sd))
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1573 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1574 else
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 image_loader_free(sd->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577 sd->img_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1578 }
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 }
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 if (tmatch && sd->match_dimensions_enable && sd->img_cd->dimensions)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584 CacheData *cd = sd->img_cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586 tmatch = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587 tested = TRUE;
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 if (sd->match_dimensions == SEARCH_MATCH_EQUAL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1590 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1591 tmatch = (cd->width == sd->search_width && cd->height == sd->search_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1593 else if (sd->match_dimensions == SEARCH_MATCH_UNDER)
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 tmatch = (cd->width < sd->search_width && cd->height < sd->search_height);
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 else if (sd->match_dimensions == SEARCH_MATCH_OVER)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1598 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599 tmatch = (cd->width > sd->search_width && cd->height > sd->search_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601 else if (sd->match_dimensions == SEARCH_MATCH_BETWEEN)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1602 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603 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
1604 MATCH_IS_BETWEEN(cd->height, sd->search_height, sd->search_height_end));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1605 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1608 if (tmatch && sd->match_similarity_enable && sd->img_cd->similarity)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1609 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1610 gdouble value = 0.0;
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 tmatch = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1613 tested = TRUE;
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 /* fixme: implement similarity checking */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1616 if (sd->search_similarity_cd && sd->search_similarity_cd->similarity)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1617 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1618 gdouble result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1619
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1620 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
1621 (gdouble)sd->search_similarity / 100.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1622 result *= 100.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1623 if (result >= (gdouble)sd->search_similarity)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1624 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1625 tmatch = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1626 value = (gint)result;
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 }
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 if (simval) *simval = value;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1633 if (sd->img_cd->dimensions)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1634 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1635 if (width) *width = sd->img_cd->width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1636 if (height) *height = sd->img_cd->height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1637 }
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 cache_sim_data_free(sd->img_cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1640 sd->img_cd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1642 *match = (tmatch && tested);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1643
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1644 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1645 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1646
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1647 static gint search_file_next(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1648 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1649 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1650 gint match = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1651 gint tested = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1652 gint extra_only = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1653 gint width = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1654 gint height = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1655 gint sim = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1656
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1657 if (!sd->search_file_list) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1659 if (sd->img_cd)
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 /* on end of a CacheData load, skip recomparing non-extra match types */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1662 extra_only = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1663 match = FALSE;
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1666 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1667 sd->search_total++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1668 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1669
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1670 fd = sd->search_file_list->data;
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 if (match && sd->match_name_enable && sd->search_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1673 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1674 tested = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1675 match = FALSE;
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 if (sd->match_name == SEARCH_MATCH_EQUAL)
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 if (sd->search_name_match_case)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1680 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1681 match = (strcmp(fd->name, sd->search_name) == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1682 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1683 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1684 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1685 match = (strcasecmp(fd->name, sd->search_name) == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1686 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1687 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1688 else if (sd->match_name == SEARCH_MATCH_CONTAINS)
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_name_match_case)
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 match = (strstr(fd->name, sd->search_name) != NULL);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1695 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1696 /* sd->search_name is converted in search_start() */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1697 gchar *haystack = g_utf8_strdown(fd->name, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1698 match = (strstr(haystack, sd->search_name) != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1699 g_free(haystack);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1700 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1704 if (match && sd->match_size_enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1705 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1706 tested = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1707 match = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1708
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1709 if (sd->match_size == SEARCH_MATCH_EQUAL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1710 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1711 match = (fd->size == sd->search_size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1712 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1713 else if (sd->match_size == SEARCH_MATCH_UNDER)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1714 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1715 match = (fd->size < sd->search_size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1716 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1717 else if (sd->match_size == SEARCH_MATCH_OVER)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1718 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1719 match = (fd->size > sd->search_size);
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_size == SEARCH_MATCH_BETWEEN)
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 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
1724 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1725 }
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 if (match && sd->match_date_enable)
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 tested = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1730 match = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1732 if (sd->match_date == SEARCH_MATCH_EQUAL)
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 struct tm *lt;
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 lt = localtime(&fd->date);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1737 match = (lt &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1738 lt->tm_year == sd->search_date_y - 1900 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1739 lt->tm_mon == sd->search_date_m - 1 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1740 lt->tm_mday == sd->search_date_d);
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 else if (sd->match_date == SEARCH_MATCH_UNDER)
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->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
1745 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1746 else if (sd->match_date == SEARCH_MATCH_OVER)
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->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
1749 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1750 else if (sd->match_date == SEARCH_MATCH_BETWEEN)
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 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
1753 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
1754
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1755 if (b >= a)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1756 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1757 b += 60 * 60 * 24 - 1;
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1760 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1761 a += 60 * 60 * 24 - 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1762 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1763 match = MATCH_IS_BETWEEN(fd->date, a, b);
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 }
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 if (match && sd->match_keywords_enable && sd->search_keyword_list)
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1771 tested = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1772 match = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1773
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
1774 if (comment_read(fd, &list, NULL))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1775 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1776 GList *needle;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1777 GList *haystack;
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 if (sd->match_keywords == SEARCH_MATCH_ALL)
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 gint found = TRUE;
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 needle = sd->search_keyword_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1784 while (needle && found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1785 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1786 found = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1787 haystack = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1788 while (haystack && !found)
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 found = (strcasecmp((gchar *)needle->data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1791 (gchar *)haystack->data) == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1792 haystack = haystack->next;
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 needle = needle->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1797 match = found;
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 else if (sd->match_keywords == SEARCH_MATCH_ANY)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1800 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1801 gint found = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1803 needle = sd->search_keyword_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1804 while (needle && !found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1805 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1806 haystack = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1807 while (haystack && !found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1808 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1809 found = (strcasecmp((gchar *)needle->data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1810 (gchar *)haystack->data) == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1811 haystack = haystack->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1812 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1813 needle = needle->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1814 }
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 match = found;
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 else if (sd->match_keywords == SEARCH_MATCH_NONE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1819 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1820 gint found = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1821
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1822 needle = sd->search_keyword_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1823 while (needle && !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 haystack = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1826 while (haystack && !found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1827 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1828 found = (strcasecmp((gchar *)needle->data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1829 (gchar *)haystack->data) == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1830 haystack = haystack->next;
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 needle = needle->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1835 match = !found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1836 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1837 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1838 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1839 else
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 match = (sd->match_keywords == SEARCH_MATCH_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1842 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1845 if ((match || extra_only) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1846 (sd->match_dimensions_enable || sd->match_similarity_enable))
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 tested = TRUE;
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 if (search_file_do_extra(sd, fd, &match, &width, &height, &sim))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1851 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1852 sd->search_buffer_count += SEARCH_BUFFER_MATCH_LOAD;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1853 return TRUE;
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 }
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 sd->search_file_list = g_list_remove(sd->search_file_list, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1858
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1859 if (tested && match)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1860 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1861 MatchFileData *mfd;
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 mfd = g_new(MatchFileData, 1);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1864 mfd->fd = fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1865
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1866 mfd->width = width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1867 mfd->height = height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1868 mfd->rank = sim;
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 sd->search_buffer_list = g_list_prepend(sd->search_buffer_list, mfd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1871 sd->search_buffer_count += SEARCH_BUFFER_MATCH_HIT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1872 sd->search_count++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1873 search_progress_update(sd, TRUE, -1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1874 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1875 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1876 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1877 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1878 sd->search_buffer_count += SEARCH_BUFFER_MATCH_MISS;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1879 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1880
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1881 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1882 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1883
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1884 static gint search_step_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1885 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1886 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1887 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1888
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1889 if (sd->search_buffer_count > SEARCH_BUFFER_FLUSH_SIZE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1890 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1891 search_buffer_flush(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1892 search_progress_update(sd, TRUE, -1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1893 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1894
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1895 if (sd->search_file_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1896 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1897 if (search_file_next(sd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1898 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1899 sd->search_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1900 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1901 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1902 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1903 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1904
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1905 if (!sd->search_file_list && !sd->search_folder_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1906 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1907 sd->search_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1908
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1909 search_stop(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1910 search_result_thumb_step(sd);
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 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1915 fd = sd->search_folder_list->data;
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 if (g_list_find(sd->search_done_list, fd) == NULL)
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 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1920 GList *dlist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1921 gint success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1922
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1923 sd->search_done_list = g_list_prepend(sd->search_done_list, fd);
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 if (sd->search_type == SEARCH_MATCH_NONE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1926 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1927 success = filelist_read(fd->path, &list, &dlist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1928 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1929 else if (sd->search_type == SEARCH_MATCH_ALL &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1930 sd->search_path &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1931 strlen(fd->path) >= strlen(sd->search_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1932 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1933 const gchar *path;
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 path = fd->path + strlen(sd->search_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1936 if (path != fd->path) success = filelist_read(path, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1937 success |= filelist_read(fd->path, NULL, &dlist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1938 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1939 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1940 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1941
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1942 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1943 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1944 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1945 FileData *fdp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1946 GList *link;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1947 gchar *meta_path;
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 fdp = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1950 link = work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1951 work = work->next;
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 meta_path = cache_find_location(CACHE_TYPE_METADATA, fdp->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1954 if (!meta_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1955 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1956 list = g_list_delete_link(list, link);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1957 file_data_unref(fdp);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1958 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1959 g_free(meta_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1960 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1961 }
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 (success)
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 list = filelist_sort(list, SORT_NAME, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1967 sd->search_file_list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1968
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1969 if (sd->search_path_recurse)
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 dlist = filelist_sort(dlist, SORT_NAME, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1972 sd->search_folder_list = g_list_concat(dlist, sd->search_folder_list);
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 else
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 filelist_free(dlist);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1979 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1980 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1981 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1982 sd->search_folder_list = g_list_remove(sd->search_folder_list, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1983 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
1984 file_data_unref(fd);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1987 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1988 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1989
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1990 static void search_similarity_load_done_cb(ImageLoader *il, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1993 search_file_load_process(sd, sd->search_similarity_cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1994 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1995
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1996 static void search_start(SearchData *sd)
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 search_stop(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1999 search_result_clear(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2001 if (sd->search_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2002 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2003 sd->search_folder_list = g_list_prepend(sd->search_folder_list,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2004 file_data_new_simple(sd->search_path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2005 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2006
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2007 if (!sd->search_name_match_case)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2008 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2009 /* 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
2010 gchar *tmp = g_utf8_strdown(sd->search_name, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2011 g_free(sd->search_name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2012 sd->search_name = tmp;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2015 sd->search_count = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2016 sd->search_total = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2017
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2018 gtk_widget_set_sensitive(sd->box_search, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2019 spinner_set_interval(sd->spinner, SPINNER_SPEED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2020 gtk_widget_set_sensitive(sd->button_start, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2021 gtk_widget_set_sensitive(sd->button_stop, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2022 search_progress_update(sd, TRUE, -1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2023
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2024 if (sd->match_similarity_enable &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2025 !sd->search_similarity_cd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2026 isfile(sd->search_similarity_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2027 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2028 gchar *cd_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 cd_path = cache_find_location(CACHE_TYPE_SIM, sd->search_similarity_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2031 if (cd_path && filetime(sd->search_similarity_path) == filetime(cd_path))
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 sd->search_similarity_cd = cache_sim_data_load(cd_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 g_free(cd_path);
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 if (!sd->search_similarity_cd || !sd->search_similarity_cd->similarity)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2038 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2039 if (!sd->search_similarity_cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2040 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2041 sd->search_similarity_cd = cache_sim_data_new();
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2044 sd->img_loader = image_loader_new(file_data_new_simple(sd->search_similarity_path));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2045 image_loader_set_error_func(sd->img_loader, search_similarity_load_done_cb, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2046 if (image_loader_start(sd->img_loader, search_similarity_load_done_cb, sd))
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 return;
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 image_loader_free(sd->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2051 sd->img_loader = NULL;
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 }
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_idle_id = g_idle_add(search_step_cb, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2057 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2059 static void search_start_cb(GtkWidget *widget, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2062 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2063 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2064
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2065 if (sd->search_folder_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2066 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2067 search_stop(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2068 search_result_thumb_step(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2069 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2070 }
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 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
2073 g_free(sd->search_name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2074 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
2075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2076 g_free(sd->search_similarity_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2077 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
2078 if (sd->match_similarity_enable)
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 (!isfile(sd->search_similarity_path))
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 file_util_warning_dialog(_("File not found"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2083 _("Please enter an existing file for image content."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2084 GTK_STOCK_DIALOG_WARNING, sd->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2085 return;
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 tab_completion_append_to_history(sd->entry_similarity, sd->search_similarity_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2088 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2089
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2090 string_list_free(sd->search_keyword_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2091 sd->search_keyword_list = keyword_list_pull(sd->entry_keywords);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2093 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
2094 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
2095
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2096 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
2097 gtk_tree_view_column_set_visible(column, sd->match_similarity_enable);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2098 if (!sd->match_similarity_enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2099 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2100 GtkTreeSortable *sortable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2101 gint id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2102 GtkSortType order;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2104 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
2105 if (gtk_tree_sortable_get_sort_column_id(sortable, &id, &order) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2106 id == SEARCH_COLUMN_RANK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2108 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
2109 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2112 if (sd->search_type == SEARCH_MATCH_NONE)
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 /* search 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 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
2117 if (isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2118 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2119 g_free(sd->search_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2120 sd->search_path = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2121 path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2123 tab_completion_append_to_history(sd->path_entry, sd->search_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2124
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2125 search_start(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2126 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2127 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2128 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2129 file_util_warning_dialog(_("Folder not found"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2130 _("Please enter an existing folder to search."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2131 GTK_STOCK_DIALOG_WARNING, sd->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2133
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2134 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2135 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2136 else if (sd->search_type == SEARCH_MATCH_ALL)
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 /* search metadata */
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 g_free(sd->search_path);
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
2141 sd->search_path = g_strconcat(homedir(), "/", GQ_CACHE_RC_METADATA, NULL);
9
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 search_start(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2144 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2145 else if (sd->search_type == SEARCH_MATCH_CONTAINS)
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 /* search current result list */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2148 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2149
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2150 list = search_result_refine_list(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2151
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2152 g_free(sd->search_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2153 sd->search_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2154
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2155 search_start(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2156
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2157 sd->search_file_list = g_list_concat(sd->search_file_list, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2158 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2159 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2161 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2162 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2163 * window construct
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2164 *-------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2167 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2168 MENU_CHOICE_COLUMN_NAME = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2169 MENU_CHOICE_COLUMN_VALUE
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2170 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2171
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2172 static void search_thumb_toggle_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2173 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2174 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2176 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
2177 }
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 static gint sort_matchdata_dimensions(MatchFileData *a, MatchFileData *b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2181 gint sa;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2182 gint sb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2184 sa = a->width * a->height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2185 sb = b->width * b->height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2186
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2187 if (sa > sb) return 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2188 if (sa < sb) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2189 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2190 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2191
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2192 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
2193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2194 gint n = GPOINTER_TO_INT(data);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2195 MatchFileData *fda;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2196 MatchFileData *fdb;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2197
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2198 gtk_tree_model_get(model, a, SEARCH_COLUMN_POINTER, &fda, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2199 gtk_tree_model_get(model, b, SEARCH_COLUMN_POINTER, &fdb, -1);
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 (!fda || !fdb) return 0;
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 switch (n)
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 case SEARCH_COLUMN_RANK:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2206 if (((MatchFileData *)fda)->rank > (fdb)->rank) return 1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2207 if (((MatchFileData *)fda)->rank < (fdb)->rank) return -1;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2208 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2209 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2210 case SEARCH_COLUMN_NAME:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2211 return CASE_SORT(fda->fd->name, fdb->fd->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2212 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2213 case SEARCH_COLUMN_SIZE:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2214 if (fda->fd->size > fdb->fd->size) return 1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2215 if (fda->fd->size < fdb->fd->size) return -1;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2216 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2217 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2218 case SEARCH_COLUMN_DATE:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2219 if (fda->fd->date > fdb->fd->date) return 1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2220 if (fda->fd->date < fdb->fd->date) return -1;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2221 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2222 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2223 case SEARCH_COLUMN_DIMENSIONS:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2224 return sort_matchdata_dimensions(fda, fdb);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2225 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2226 case SEARCH_COLUMN_PATH:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2227 return CASE_SORT(fda->fd->path, fdb->fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2228 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2229 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2230 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2231 }
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 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2234 }
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 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
2237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2238 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2239 GtkCellRenderer *renderer;
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 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2242 gtk_tree_view_column_set_title(column, title);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2243 gtk_tree_view_column_set_min_width(column, 4);
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 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
2246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2247 if (!image)
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 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
2250 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2251 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
2252 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2253 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2255 gtk_tree_view_column_set_sort_column_id(column, n);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2258 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2259 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2260 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2261 cell_renderer_height_override(renderer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2262 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2263 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2266 gtk_tree_view_append_column(GTK_TREE_VIEW(sd->result_view), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2267 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2269 static void menu_choice_set_visible(GtkWidget *widget, gint visible)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2270 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2271 if (visible)
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 (!GTK_WIDGET_VISIBLE(widget)) gtk_widget_show(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2274 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2275 else
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 if (GTK_WIDGET_VISIBLE(widget)) gtk_widget_hide(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2278 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2281 static void menu_choice_path_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2282 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2283 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2284 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2285 GtkTreeIter iter;
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 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2288 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2289 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->search_type, -1);
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 menu_choice_set_visible(gtk_widget_get_parent(sd->check_recurse),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2292 (sd->search_type == SEARCH_MATCH_NONE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2293 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2295 static void menu_choice_name_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2297 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2298 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2299 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2301 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2302 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2303 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_name, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2306 static void menu_choice_size_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2308 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2309 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2310 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2312 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2313 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2314 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_size, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2316 menu_choice_set_visible(gtk_widget_get_parent(sd->spin_size_end),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2317 (sd->match_size == SEARCH_MATCH_BETWEEN));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2318 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2320 static void menu_choice_date_cb(GtkWidget *combo, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2323 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2324 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2326 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2327 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2328 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_date, -1);
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 menu_choice_set_visible(gtk_widget_get_parent(sd->date_sel_end),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2331 (sd->match_date == SEARCH_MATCH_BETWEEN));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2332 }
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 static void menu_choice_dimensions_cb(GtkWidget *combo, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2337 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2338 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2339
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2340 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2341 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2342 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_dimensions, -1);
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 menu_choice_set_visible(gtk_widget_get_parent(sd->spin_width_end),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2345 (sd->match_dimensions == SEARCH_MATCH_BETWEEN));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2346 }
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 static void menu_choice_keyword_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2349 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2350 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2351 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2352 GtkTreeIter iter;
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 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2355 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2356 gtk_tree_model_get(store, &iter, MENU_CHOICE_COLUMN_VALUE, &sd->match_keywords, -1);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2359 static void menu_choice_spin_cb(GtkAdjustment *adjustment, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2360 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2361 gint *value = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2363 *value = (gint)gtk_adjustment_get_value(adjustment);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2364 }
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 static GtkWidget *menu_spin(GtkWidget *box, gdouble min, gdouble max, gint value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2367 GCallback func, gpointer data)
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 GtkWidget *spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2370 GtkAdjustment *adj;
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 spin = gtk_spin_button_new_with_range(min, max, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2373 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), (gdouble)value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2374 adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(spin));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2375 if (func) g_signal_connect(G_OBJECT(adj), "value_changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2376 G_CALLBACK(func), data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2377 gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2378 gtk_widget_show(spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2379
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2380 return spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2381 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2383 static void menu_choice_check_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2384 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2385 GtkWidget *widget = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2386 gboolean active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2387 gboolean *value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2389 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2390 gtk_widget_set_sensitive(widget, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2391
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2392 value = g_object_get_data(G_OBJECT(button), "check_var");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2393 if (value) *value = active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2394 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2396 static GtkWidget *menu_choice_menu(const MatchList *items, gint item_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2397 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2398 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2399 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2400 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2401 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2402 gint i;
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 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2405 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2406 g_object_unref(store);
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 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2409 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2410 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2411 "text", MENU_CHOICE_COLUMN_NAME, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2412
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2413 for (i = 0; i < item_count; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2414 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2415 GtkTreeIter iter;
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 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2418 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
2419 MENU_CHOICE_COLUMN_VALUE, items[i].type, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2420 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2422 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
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 if (func) g_signal_connect(G_OBJECT(combo), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2425 G_CALLBACK(func), data);
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 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2428 }
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 static GtkWidget *menu_choice(GtkWidget *box, GtkWidget **check, GtkWidget **menu,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2431 const gchar *text, gboolean *value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2432 const MatchList *items, gint item_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2433 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2434 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2435 GtkWidget *base_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2436 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2437 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2438 GtkWidget *option;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2440 base_box = gtk_hbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2441 gtk_box_pack_start(GTK_BOX(box), base_box, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2442 gtk_widget_show(base_box);
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 button = gtk_check_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2445 if (value) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2446 gtk_box_pack_start(GTK_BOX(base_box), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2447 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2448 if (check) *check = button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2449 if (value) g_object_set_data(G_OBJECT(button), "check_var", value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2451 hbox = gtk_hbox_new(FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2452 gtk_box_pack_start(GTK_BOX(base_box), hbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2453 gtk_widget_show(hbox);
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 g_signal_connect(G_OBJECT(button), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2456 G_CALLBACK(menu_choice_check_cb), hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2457 gtk_widget_set_sensitive(hbox, (value) ? *value : FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2459 pref_label_new(hbox, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2460
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2461 if (!items && !menu) return hbox;
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 option = menu_choice_menu(items, item_count, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2464 gtk_box_pack_start(GTK_BOX(hbox), option, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2465 gtk_widget_show(option);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2466 if (menu) *menu = option;
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 return hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2469 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2471 static void search_window_close(SearchData *sd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2473 gtk_widget_destroy(sd->window);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2476 static gint search_window_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
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 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2480 search_window_close(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2481 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2482 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2484 static void search_window_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2486 SearchData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2488 search_window_list = g_list_remove(search_window_list, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2489
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2490 search_result_update_idle_cancel(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2492 filelist_free(sd->search_buffer_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2493 sd->search_buffer_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2495 search_stop(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2496 search_result_clear(sd);
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 g_free(sd->search_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2499 g_free(sd->search_name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2500 g_free(sd->search_similarity_path);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2501 string_list_free(sd->search_keyword_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2502
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2503 g_free(sd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2506 void search_new(const gchar *path, const gchar *example_file)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2507 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2508 SearchData *sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2509 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2510 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2511 GtkWidget *hbox2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2512 GtkWidget *pad_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2513 GtkWidget *frame;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2514 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2515 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2516 GtkTreeSortable *sortable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2517 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2518 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2519 GdkGeometry geometry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2521 sd = g_new0(SearchData, 1);
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 sd->search_path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2524 sd->search_path_recurse = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2525 sd->search_size = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2526 sd->search_width = 640;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2527 sd->search_height = 480;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2528 sd->search_width_end = 1024;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2529 sd->search_height_end = 768;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2530 sd->search_name = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2531 sd->search_name_match_case = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2533 sd->search_type = SEARCH_MATCH_NONE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2535 sd->match_name = SEARCH_MATCH_CONTAINS;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2536 sd->match_size = SEARCH_MATCH_EQUAL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2537 sd->match_date = SEARCH_MATCH_EQUAL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2538 sd->match_dimensions = SEARCH_MATCH_EQUAL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2539 sd->match_keywords = SEARCH_MATCH_ALL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2540
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2541 sd->match_name_enable = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2542 sd->match_size_enable = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2543 sd->match_date_enable = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2544 sd->match_dimensions_enable = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2545 sd->match_similarity_enable = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2546 sd->match_keywords_enable = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2547
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2548 sd->search_similarity = 95;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2549 sd->search_similarity_path = g_strdup(example_file);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2550 sd->search_similarity_cd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2551
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2552 sd->search_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2553 sd->update_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2554
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 288
diff changeset
2555 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
2556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2557 gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE);
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 geometry.min_width = 32;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2560 geometry.min_height = 32;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2561 geometry.base_width = DEF_SEARCH_WIDTH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2562 geometry.base_height = DEF_SEARCH_HEIGHT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2563 gtk_window_set_geometry_hints(GTK_WINDOW(sd->window), NULL, &geometry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2564 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
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 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
2567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2568 g_signal_connect(G_OBJECT(sd->window), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2569 G_CALLBACK(search_window_delete_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2570 g_signal_connect(G_OBJECT(sd->window), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2571 G_CALLBACK(search_window_destroy_cb), 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 g_signal_connect(G_OBJECT(sd->window), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2574 G_CALLBACK(search_window_keypress_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2575
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2576 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2577 gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2578 gtk_container_add(GTK_CONTAINER(sd->window), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2579 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2580
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2581 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
2582
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2583 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
2584
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2585 pref_label_new(hbox, _("Search:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2586
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2587 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
2588 G_CALLBACK(menu_choice_path_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2589 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
2590 gtk_widget_show(sd->menu_path);
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 hbox2 = pref_box_new(hbox, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2593 combo = tab_completion_new_with_history(&sd->path_entry, sd->search_path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2594 "search_path", -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2595 NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2596 tab_completion_add_select_button(sd->path_entry, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2597 gtk_box_pack_start(GTK_BOX(hbox2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2598 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2599 sd->check_recurse = pref_checkbox_new_int(hbox2, _("Recurse"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2600 sd->search_path_recurse, &sd->search_path_recurse);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2602 hbox = menu_choice(sd->box_search, &sd->check_name, &sd->menu_name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2603 _("File name"), &sd->match_name_enable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2604 text_search_menu_name, sizeof(text_search_menu_name) / sizeof(MatchList),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2605 G_CALLBACK(menu_choice_name_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2606 combo = history_combo_new(&sd->entry_name, "", "search_name", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2607 gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2608 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2609 pref_checkbox_new_int(hbox, _("Match case"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2610 sd->search_name_match_case, &sd->search_name_match_case);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2612 hbox = menu_choice(sd->box_search, &sd->check_size, &sd->menu_size,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2613 _("File size is"), &sd->match_size_enable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2614 text_search_menu_size, sizeof(text_search_menu_size) / sizeof(MatchList),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2615 G_CALLBACK(menu_choice_size_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2616 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
2617 G_CALLBACK(menu_choice_spin_cb), &sd->search_size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2618 hbox2 = gtk_hbox_new(FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2619 gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2620 pref_label_new(hbox2, _("and"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2621 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
2622 G_CALLBACK(menu_choice_spin_cb), &sd->search_size_end);
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 hbox = menu_choice(sd->box_search, &sd->check_date, &sd->menu_date,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2625 _("File date is"), &sd->match_date_enable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2626 text_search_menu_date, sizeof(text_search_menu_date) / sizeof(MatchList),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2627 G_CALLBACK(menu_choice_date_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2628 sd->date_sel = date_selection_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2629 date_selection_time_set(sd->date_sel, time(NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2630 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
2631 gtk_widget_show(sd->date_sel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2632
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2633 hbox2 = gtk_hbox_new(FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2634 gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2635 pref_label_new(hbox2, _("and"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2636 sd->date_sel_end = date_selection_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2637 date_selection_time_set(sd->date_sel_end, time(NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2638 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
2639 gtk_widget_show(sd->date_sel_end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2640
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2641 hbox = menu_choice(sd->box_search, &sd->check_dimensions, &sd->menu_dimensions,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2642 _("Image dimensions are"), &sd->match_dimensions_enable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2643 text_search_menu_size, sizeof(text_search_menu_size) / sizeof(MatchList),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2644 G_CALLBACK(menu_choice_dimensions_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2645 pad_box = pref_box_new(hbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2646 sd->spin_width = menu_spin(pad_box, 0, 1000000, sd->search_width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2647 G_CALLBACK(menu_choice_spin_cb), &sd->search_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2648 pref_label_new(pad_box, "x");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2649 sd->spin_height = menu_spin(pad_box, 0, 1000000, sd->search_height,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2650 G_CALLBACK(menu_choice_spin_cb), &sd->search_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2651 hbox2 = gtk_hbox_new(FALSE, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2652 gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2653 pref_label_new(hbox2, _("and"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2654 pref_spacer(hbox2, PREF_PAD_SPACE - 2*2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2655 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
2656 G_CALLBACK(menu_choice_spin_cb), &sd->search_width_end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2657 pref_label_new(hbox2, "x");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2658 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
2659 G_CALLBACK(menu_choice_spin_cb), &sd->search_height_end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2661 hbox = menu_choice(sd->box_search, &sd->check_similarity, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2662 _("Image content is"), &sd->match_similarity_enable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2663 NULL, 0, NULL, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2664 sd->spin_similarity = menu_spin(hbox, 80, 100, sd->search_similarity,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2665 G_CALLBACK(menu_choice_spin_cb), &sd->search_similarity);
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 /* xgettext:no-c-format */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2668 pref_label_new(hbox, _("% similar to"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2669
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2670 combo = tab_completion_new_with_history(&sd->entry_similarity,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2671 (sd->search_similarity_path) ? sd->search_similarity_path : "",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2672 "search_similarity_path", -1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2673 tab_completion_add_select_button(sd->entry_similarity, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2674 gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2675 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2676
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2677 hbox = menu_choice(sd->box_search, &sd->check_keywords, &sd->menu_keywords,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2678 _("Keywords"), &sd->match_keywords_enable,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2679 text_search_menu_keyword, sizeof(text_search_menu_keyword) / sizeof(MatchList),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2680 G_CALLBACK(menu_choice_keyword_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2681 sd->entry_keywords = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2682 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
2683 gtk_widget_set_sensitive(sd->entry_keywords, sd->match_keywords_enable);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2684 g_signal_connect(G_OBJECT(sd->check_keywords), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2685 G_CALLBACK(menu_choice_check_cb), sd->entry_keywords);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2686 gtk_widget_show(sd->entry_keywords);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2687
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2688 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2689 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
2690 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2691 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2692 gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2693 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2694
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2695 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
2696 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2697 G_TYPE_STRING, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2699 /* set up sorting */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2700 sortable = GTK_TREE_SORTABLE(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2701 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
2702 GINT_TO_POINTER(SEARCH_COLUMN_RANK), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2703 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
2704 GINT_TO_POINTER(SEARCH_COLUMN_NAME), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2705 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
2706 GINT_TO_POINTER(SEARCH_COLUMN_SIZE), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2707 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
2708 GINT_TO_POINTER(SEARCH_COLUMN_DATE), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2709 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
2710 GINT_TO_POINTER(SEARCH_COLUMN_DIMENSIONS), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2711 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
2712 GINT_TO_POINTER(SEARCH_COLUMN_PATH), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2713
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2714 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2715 /* 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
2716 * 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
2717 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2718 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
2719 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2721 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
2722 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2723 gtk_container_add(GTK_CONTAINER(scrolled), sd->result_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2724 gtk_widget_show(sd->result_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2726 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2727 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2728 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
2729
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2730 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
2731 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
2732
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2733 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2734 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
2735 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2737 search_result_add_column(sd, SEARCH_COLUMN_RANK, _("Rank"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2738 search_result_add_column(sd, SEARCH_COLUMN_THUMB, "", TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2739 search_result_add_column(sd, SEARCH_COLUMN_NAME, _("Name"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2740 search_result_add_column(sd, SEARCH_COLUMN_SIZE, _("Size"), FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2741 search_result_add_column(sd, SEARCH_COLUMN_DATE, _("Date"), FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2742 search_result_add_column(sd, SEARCH_COLUMN_DIMENSIONS, _("Dimensions"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2743 search_result_add_column(sd, SEARCH_COLUMN_PATH, _("Path"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2745 search_dnd_init(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2747 g_signal_connect(G_OBJECT(sd->result_view), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2748 G_CALLBACK(search_result_press_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2749 g_signal_connect(G_OBJECT(sd->result_view), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2750 G_CALLBACK(search_result_release_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2751 g_signal_connect(G_OBJECT(sd->result_view), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2752 G_CALLBACK(search_result_keypress_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2753
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2754 hbox = pref_box_new(vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2755
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2756 sd->button_thumbs = pref_checkbox_new(hbox, _("Thumbnails"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2757 G_CALLBACK(search_thumb_toggle_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2758
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2759 frame = gtk_frame_new(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2760 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2761 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
2762 gtk_widget_show(frame);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2763
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2764 sd->label_status = gtk_label_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2765 gtk_widget_set_size_request(sd->label_status, 50, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2766 gtk_container_add(GTK_CONTAINER(frame), sd->label_status);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2767 gtk_widget_show(sd->label_status);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2768
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2769 sd->label_progress = gtk_progress_bar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2770 gtk_widget_set_size_request(sd->label_progress, 50, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2771 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
2772 gtk_widget_show(sd->label_progress);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2774 sd->spinner = spinner_new(NULL, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2775 gtk_box_pack_start(GTK_BOX(hbox), sd->spinner, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2776 gtk_widget_show(sd->spinner);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2778 sd->button_start = pref_button_new(hbox, GTK_STOCK_FIND, NULL, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2779 G_CALLBACK(search_start_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2780 pref_spacer(hbox, PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2781 sd->button_stop = pref_button_new(hbox, GTK_STOCK_STOP, NULL, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2782 G_CALLBACK(search_start_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2783 gtk_widget_set_sensitive(sd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2784
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2785 search_status_update(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2786 search_progress_update(sd, FALSE, -1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2787
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2788 search_window_list = g_list_append(search_window_list, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2789
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2790 gtk_widget_show(sd->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2791 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2792
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2793 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2794 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2795 * maintenance (move, delete, etc.)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2796 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2797 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2798
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2799 static void search_result_change_path(SearchData *sd, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2800 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2801 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2802 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2803 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2804
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2805 store = gtk_tree_view_get_model(GTK_TREE_VIEW(sd->result_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2806 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2807 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2808 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2809 GtkTreeIter current;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2810 MatchFileData *mfd;
9
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 current = iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2813 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2814
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2815 gtk_tree_model_get(store, &current, SEARCH_COLUMN_POINTER, &mfd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2816 if (mfd->fd == fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2817 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2818 if (fd->change && fd->change->dest)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2819 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2820 gtk_list_store_set(GTK_LIST_STORE(store), &current,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2821 SEARCH_COLUMN_NAME, mfd->fd->name,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2822 SEARCH_COLUMN_PATH, mfd->fd->path, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2823 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2824 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2825 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2826 search_result_remove_item(sd, mfd, &current);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2827 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2828 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2829 }
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2832 void search_maint_renamed(FileData *fd)
9
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2835
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2836 work = search_window_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2837 while (work)
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 SearchData *sd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2840 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2841
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2842 search_result_change_path(sd, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2843 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2844 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2845
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2846 void search_maint_removed(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2847 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2848 search_maint_renamed(fd);
9
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