Mercurial > geeqie.yaz
annotate src/filelist.c @ 175:682705e0c0e0
do not show frame for full-window images
author | nadvornik |
---|---|
date | Mon, 11 Feb 2008 15:23:43 +0000 |
parents | d18b94f1ca80 |
children | 0584cb78aa14 |
rev | line source |
---|---|
1 | 1 /* |
9 | 2 * GQview |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
12 | |
9 | 13 #include "gqview.h" |
14 #include "filelist.h" | |
1 | 15 |
9 | 16 #include "cache.h" |
17 #include "rcfile.h" | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
18 #include "thumb_standard.h" |
9 | 19 #include "ui_fileops.h" |
1 | 20 |
21 | |
22 /* | |
23 *----------------------------------------------------------------------------- | |
24 * file filtering | |
25 *----------------------------------------------------------------------------- | |
26 */ | |
27 | |
9 | 28 static GList *filter_list = NULL; |
29 static GList *extension_list = NULL; | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
30 static GList *sidecar_ext_list = NULL; |
9 | 31 |
32 gint ishidden(const gchar *name) | |
1 | 33 { |
34 if (name[0] != '.') return FALSE; | |
35 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE; | |
36 return TRUE; | |
37 } | |
38 | |
9 | 39 static FilterEntry *filter_entry_new(const gchar *key, const gchar *description, |
40 const gchar *extensions, gint enabled) | |
41 { | |
42 FilterEntry *fe; | |
43 | |
44 fe = g_new0(FilterEntry, 1); | |
45 fe->key = g_strdup(key); | |
46 fe->description = g_strdup(description); | |
47 fe->extensions = g_strdup(extensions); | |
48 fe->enabled = enabled; | |
49 | |
50 return fe; | |
51 } | |
52 | |
53 static void filter_entry_free(FilterEntry *fe) | |
54 { | |
55 if (!fe) return; | |
56 | |
57 g_free(fe->key); | |
58 g_free(fe->description); | |
59 g_free(fe->extensions); | |
60 g_free(fe); | |
61 } | |
62 | |
63 GList *filter_get_list(void) | |
64 { | |
65 return filter_list; | |
66 } | |
67 | |
68 void filter_remove_entry(FilterEntry *fe) | |
69 { | |
70 if (!g_list_find(filter_list, fe)) return; | |
71 | |
72 filter_list = g_list_remove(filter_list, fe); | |
73 filter_entry_free(fe); | |
74 } | |
75 | |
76 static gint filter_key_exists(const gchar *key) | |
77 { | |
78 GList *work; | |
79 | |
80 if (!key) return FALSE; | |
81 | |
82 work = filter_list; | |
83 while (work) | |
84 { | |
85 FilterEntry *fe = work->data; | |
86 work = work->next; | |
87 | |
88 if (strcmp(fe->key, key) == 0) return TRUE; | |
89 } | |
90 | |
91 return FALSE; | |
92 } | |
93 | |
94 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, gint enabled) | |
95 { | |
96 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, enabled)); | |
97 } | |
98 | |
99 void filter_add_unique(const gchar *description, const gchar *extensions, gint enabled) | |
100 { | |
101 gchar *key; | |
102 gint n; | |
103 | |
104 key = g_strdup("user0"); | |
105 n = 1; | |
106 while (filter_key_exists(key)) | |
107 { | |
108 g_free(key); | |
109 if (n > 999) return; | |
110 key = g_strdup_printf("user%d", n); | |
111 n++; | |
112 } | |
113 | |
114 filter_add(key, description, extensions, enabled); | |
115 g_free(key); | |
116 } | |
117 | |
118 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, gint enabled) | |
119 { | |
120 GList *work; | |
121 | |
122 if (!key) return; | |
123 | |
124 work = filter_list; | |
125 while (work) | |
126 { | |
127 FilterEntry *fe = work->data; | |
128 work = work->next; | |
129 if (fe->key && strcmp(fe->key, key) == 0) return; | |
130 } | |
131 | |
132 filter_add(key, description, extensions, enabled); | |
133 } | |
134 | |
135 void filter_reset(void) | |
1 | 136 { |
137 GList *work; | |
9 | 138 |
139 work = filter_list; | |
140 while (work) | |
141 { | |
142 FilterEntry *fe = work->data; | |
143 work = work->next; | |
144 filter_entry_free(fe); | |
145 } | |
146 | |
147 g_list_free(filter_list); | |
148 filter_list = NULL; | |
149 } | |
150 | |
151 void filter_add_defaults(void) | |
152 { | |
153 GSList *list, *work; | |
154 | |
155 list = gdk_pixbuf_get_formats(); | |
156 work = list; | |
157 while (work) | |
158 { | |
159 GdkPixbufFormat *format; | |
160 gchar *name; | |
161 gchar *desc; | |
162 gchar **extensions; | |
163 GString *filter = NULL; | |
164 gint i; | |
165 | |
166 format = work->data; | |
167 work = work->next; | |
168 | |
169 name = gdk_pixbuf_format_get_name(format); | |
170 desc = gdk_pixbuf_format_get_description(format); | |
171 extensions = gdk_pixbuf_format_get_extensions(format); | |
172 | |
173 i = 0; | |
174 while (extensions[i]) | |
175 { | |
176 if (!filter) | |
177 { | |
178 filter = g_string_new("."); | |
179 filter = g_string_append(filter, extensions[i]); | |
180 } | |
181 else | |
182 { | |
183 filter = g_string_append(filter, ";."); | |
184 filter = g_string_append(filter, extensions[i]); | |
185 } | |
186 i++; | |
187 } | |
188 | |
189 if (debug) printf("loader reported [%s] [%s] [%s]\n", name, desc, filter->str); | |
190 | |
191 filter_add_if_missing(name, desc, filter->str, TRUE); | |
192 | |
193 g_free(name); | |
194 g_free(desc); | |
195 g_strfreev(extensions); | |
196 g_string_free(filter, TRUE); | |
197 } | |
198 g_slist_free(list); | |
1 | 199 |
9 | 200 /* add defaults even if gdk-pixbuf does not have them, but disabled */ |
201 filter_add_if_missing("jpeg", "JPEG group", ".jpg;.jpeg;.jpe", FALSE); | |
202 filter_add_if_missing("png", "Portable Network Graphic", ".png", FALSE); | |
203 filter_add_if_missing("tiff", "Tiff", ".tif;.tiff", FALSE); | |
204 filter_add_if_missing("pnm", "Packed Pixel formats", ".pbm;.pgm;.pnm;.ppm", FALSE); | |
205 filter_add_if_missing("gif", "Graphics Interchange Format", ".gif", FALSE); | |
206 filter_add_if_missing("xbm", "X bitmap", ".xbm", FALSE); | |
207 filter_add_if_missing("xpm", "X pixmap", ".xpm", FALSE); | |
208 filter_add_if_missing("bmp", "Bitmap", ".bmp", FALSE); | |
209 filter_add_if_missing("ico", "Icon file", ".ico;.cur", FALSE); | |
210 filter_add_if_missing("ras", "Raster", ".ras", FALSE); | |
211 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FALSE); | |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
212 |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
213 /* These are the raw camera formats with embedded jpeg/exif. |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
214 * (see format_raw.c) |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
215 */ |
53
00843150f7c8
Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents:
52
diff
changeset
|
216 filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", TRUE); |
45
7cfa60beda76
Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents:
43
diff
changeset
|
217 filter_add_if_missing("raf", "Fujifilm raw format", ".raf", TRUE); |
53
00843150f7c8
Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents:
52
diff
changeset
|
218 filter_add_if_missing("nef", "Nikon raw format", ".nef", TRUE); |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
219 filter_add_if_missing("orf", "Olympus raw format", ".orf", TRUE); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
79
diff
changeset
|
220 filter_add_if_missing("pef", "Pentax raw format", ".pef", TRUE); |
9 | 221 } |
222 | |
147
b2266996fa83
added possibility to specify prefered file type for external commands
nadvornik
parents:
146
diff
changeset
|
223 GList *filter_to_list(const gchar *extensions) |
9 | 224 { |
225 GList *list = NULL; | |
226 const gchar *p; | |
227 | |
228 if (!extensions) return NULL; | |
229 | |
230 p = extensions; | |
231 while (*p != '\0') | |
232 { | |
233 const gchar *b; | |
234 gint l = 0; | |
235 | |
236 b = p; | |
237 while (*p != '\0' && *p != ';') | |
238 { | |
239 p++; | |
240 l++; | |
241 } | |
242 list = g_list_append(list, g_strndup(b, l)); | |
243 if (*p == ';') p++; | |
244 } | |
245 | |
246 return list; | |
247 } | |
248 | |
249 void filter_rebuild(void) | |
250 { | |
251 GList *work; | |
252 | |
253 path_list_free(extension_list); | |
254 extension_list = NULL; | |
255 | |
256 work = filter_list; | |
257 while (work) | |
258 { | |
259 FilterEntry *fe; | |
260 | |
261 fe = work->data; | |
262 work = work->next; | |
263 | |
264 if (fe->enabled) | |
265 { | |
266 GList *ext; | |
267 | |
268 ext = filter_to_list(fe->extensions); | |
269 if (ext) extension_list = g_list_concat(extension_list, ext); | |
270 } | |
271 } | |
272 } | |
273 | |
274 gint filter_name_exists(const gchar *name) | |
275 { | |
276 GList *work; | |
277 if (!extension_list || file_filter_disable) return TRUE; | |
278 | |
279 work = extension_list; | |
1 | 280 while (work) |
281 { | |
282 gchar *filter = work->data; | |
283 gint lf = strlen(filter); | |
284 gint ln = strlen(name); | |
285 if (ln >= lf) | |
286 { | |
287 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE; | |
288 } | |
289 work = work->next; | |
290 } | |
291 | |
292 return FALSE; | |
293 } | |
294 | |
9 | 295 void filter_write_list(FILE *f) |
1 | 296 { |
9 | 297 GList *work; |
298 | |
299 work = filter_list; | |
300 while (work) | |
301 { | |
302 FilterEntry *fe = work->data; | |
303 work = work->next; | |
304 | |
305 fprintf(f, "filter_ext: \"%s%s\" \"%s\" \"%s\"\n", (fe->enabled) ? "" : "#", | |
306 fe->key, fe->extensions, | |
307 (fe->description) ? fe->description : ""); | |
308 } | |
1 | 309 } |
310 | |
9 | 311 void filter_parse(const gchar *text) |
1 | 312 { |
9 | 313 const gchar *p; |
314 gchar *key; | |
315 gchar *ext; | |
316 gchar *desc; | |
317 gint enabled = TRUE; | |
318 | |
319 if (!text || text[0] != '"') return; | |
320 | |
321 key = quoted_value(text); | |
322 if (!key) return; | |
323 | |
324 p = text; | |
325 p++; | |
326 while (*p != '"' && *p != '\0') p++; | |
327 if (*p != '"') | |
328 { | |
329 g_free(key); | |
330 return; | |
331 } | |
332 p++; | |
333 while (*p != '"' && *p != '\0') p++; | |
334 if (*p != '"') | |
1 | 335 { |
9 | 336 g_free(key); |
337 return; | |
338 } | |
339 | |
340 ext = quoted_value(p); | |
341 | |
342 p++; | |
343 while (*p != '"' && *p != '\0') p++; | |
344 if (*p == '"') p++; | |
345 while (*p != '"' && *p != '\0') p++; | |
346 | |
347 if (*p == '"') | |
348 { | |
349 desc = quoted_value(p); | |
350 } | |
351 else | |
352 { | |
353 desc = NULL; | |
354 } | |
355 | |
356 if (key && key[0] == '#') | |
357 { | |
358 gchar *tmp; | |
359 tmp = g_strdup(key + 1); | |
360 g_free(key); | |
361 key = tmp; | |
362 | |
363 enabled = FALSE; | |
1 | 364 } |
365 | |
9 | 366 if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, enabled); |
367 | |
368 g_free(key); | |
369 g_free(ext); | |
370 g_free(desc); | |
371 } | |
1 | 372 |
9 | 373 GList *path_list_filter(GList *list, gint is_dir_list) |
374 { | |
375 GList *work; | |
376 | |
377 if (!is_dir_list && file_filter_disable && show_dot_files) return list; | |
378 | |
379 work = list; | |
380 while (work) | |
1 | 381 { |
9 | 382 gchar *name = work->data; |
383 const gchar *base; | |
384 | |
385 base = filename_from_path(name); | |
386 | |
387 if ((!show_dot_files && ishidden(base)) || | |
388 (!is_dir_list && !filter_name_exists(base)) || | |
389 (is_dir_list && base[0] == '.' && (strcmp(base, GQVIEW_CACHE_LOCAL_THUMB) == 0 || | |
390 strcmp(base, GQVIEW_CACHE_LOCAL_METADATA) == 0)) ) | |
391 { | |
392 GList *link = work; | |
393 work = work->next; | |
394 list = g_list_remove_link(list, link); | |
395 g_free(name); | |
396 g_list_free(link); | |
397 } | |
398 else | |
1 | 399 { |
9 | 400 work = work->next; |
1 | 401 } |
402 } | |
9 | 403 |
404 return list; | |
405 } | |
406 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
407 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
408 /* |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
409 *----------------------------------------------------------------------------- |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
410 * sidecar extension list |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
411 *----------------------------------------------------------------------------- |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
412 */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
413 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
414 static GList *sidecar_ext_get_list(void) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
415 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
416 return sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
417 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
418 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
419 void sidecar_ext_parse(const gchar *text, gint quoted) |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
420 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
421 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
422 gchar *value; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
423 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
424 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
425 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
426 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
427 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
428 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
429 g_free(ext); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
430 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
431 g_list_free(sidecar_ext_list); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
432 sidecar_ext_list = NULL; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
433 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
434 if (quoted) |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
435 value = quoted_value(text); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
436 else |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
437 value = g_strdup(text); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
438 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
439 if (value == NULL) return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
440 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
441 sidecar_ext_list = filter_to_list(value); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
442 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
443 g_free(value); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
444 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
445 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
446 void sidecar_ext_write(FILE *f) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
447 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
448 GList *work; |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
449 fprintf(f, "\nsidecar_ext: \"%s\"\n", sidecar_ext_to_string()); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
450 } |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
451 |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
452 char *sidecar_ext_to_string() |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
453 { |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
454 GList *work; |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
455 GString *str = g_string_new(""); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
456 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
457 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
458 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
459 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
460 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
461 work = work->next; |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
462 g_string_append(str, ext); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
463 if (work) g_string_append(str, ";"); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
464 } |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
465 return g_string_free(str, FALSE); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
466 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
467 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
468 void sidecar_ext_add_defaults() |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
469 { |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
470 sidecar_ext_parse(".jpg;.cr2;.nef;.crw", FALSE); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
471 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
472 |
9 | 473 /* |
474 *----------------------------------------------------------------------------- | |
475 * path list recursive | |
476 *----------------------------------------------------------------------------- | |
477 */ | |
478 | |
479 static gint path_list_sort_cb(gconstpointer a, gconstpointer b) | |
480 { | |
481 return CASE_SORT((gchar *)a, (gchar *)b); | |
482 } | |
483 | |
484 GList *path_list_sort(GList *list) | |
485 { | |
486 return g_list_sort(list, path_list_sort_cb); | |
487 } | |
488 | |
489 static void path_list_recursive_append(GList **list, GList *dirs) | |
490 { | |
491 GList *work; | |
492 | |
493 work = dirs; | |
494 while (work) | |
495 { | |
496 const gchar *path = work->data; | |
497 GList *f = NULL; | |
498 GList *d = NULL; | |
499 | |
500 if (path_list(path, &f, &d)) | |
501 { | |
502 f = path_list_filter(f, FALSE); | |
503 f = path_list_sort(f); | |
504 *list = g_list_concat(*list, f); | |
505 | |
506 d = path_list_filter(d, TRUE); | |
507 d = path_list_sort(d); | |
508 path_list_recursive_append(list, d); | |
52
a210a19f26da
Sun Jun 5 03:05:39 2005 John Ellis <johne@verizon.net>
gqview
parents:
45
diff
changeset
|
509 path_list_free(d); |
9 | 510 } |
511 | |
512 work = work->next; | |
513 } | |
514 } | |
515 | |
516 GList *path_list_recursive(const gchar *path) | |
517 { | |
518 GList *list = NULL; | |
519 GList *d = NULL; | |
520 | |
521 if (!path_list(path, &list, &d)) return NULL; | |
522 list = path_list_filter(list, FALSE); | |
523 list = path_list_sort(list); | |
524 | |
525 d = path_list_filter(d, TRUE); | |
526 d = path_list_sort(d); | |
527 path_list_recursive_append(&list, d); | |
528 path_list_free(d); | |
529 | |
530 return list; | |
1 | 531 } |
532 | |
533 /* | |
534 *----------------------------------------------------------------------------- | |
9 | 535 * text conversion utils |
1 | 536 *----------------------------------------------------------------------------- |
537 */ | |
538 | |
9 | 539 gchar *text_from_size(gint64 size) |
1 | 540 { |
9 | 541 gchar *a, *b; |
542 gchar *s, *d; | |
543 gint l, n, i; | |
544 | |
545 /* what I would like to use is printf("%'d", size) | |
546 * BUT: not supported on every libc :( | |
547 */ | |
548 if (size > G_MAXUINT) | |
549 { | |
550 /* the %lld conversion is not valid in all libcs, so use a simple work-around */ | |
551 a = g_strdup_printf("%d%09d", (guint)(size / 1000000000), (guint)(size % 1000000000)); | |
552 } | |
553 else | |
554 { | |
555 a = g_strdup_printf("%d", (guint)size); | |
556 } | |
557 l = strlen(a); | |
558 n = (l - 1)/ 3; | |
559 if (n < 1) return a; | |
560 | |
561 b = g_new(gchar, l + n + 1); | |
562 | |
563 s = a; | |
564 d = b; | |
565 i = l - n * 3; | |
566 while (*s != '\0') | |
567 { | |
568 if (i < 1) | |
569 { | |
570 i = 3; | |
571 *d = ','; | |
572 d++; | |
573 } | |
574 | |
575 *d = *s; | |
576 s++; | |
577 d++; | |
578 i--; | |
579 } | |
580 *d = '\0'; | |
581 | |
582 g_free(a); | |
583 return b; | |
584 } | |
585 | |
586 gchar *text_from_size_abrev(gint64 size) | |
587 { | |
588 if (size < (gint64)1024) | |
589 { | |
590 return g_strdup_printf(_("%d bytes"), (gint)size); | |
591 } | |
592 if (size < (gint64)1048576) | |
593 { | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
594 return g_strdup_printf(_("%.1f K"), (double)size / 1024.0); |
9 | 595 } |
596 if (size < (gint64)1073741824) | |
597 { | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
598 return g_strdup_printf(_("%.1f MB"), (double)size / 1048576.0); |
9 | 599 } |
600 | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
601 /* to avoid overflowing the double, do division in two steps */ |
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
602 size /= 1048576; |
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
603 return g_strdup_printf(_("%.1f GB"), (double)size / 1024.0); |
9 | 604 } |
605 | |
606 /* note: returned string is valid until next call to text_from_time() */ | |
607 const gchar *text_from_time(time_t t) | |
608 { | |
609 static gchar *ret = NULL; | |
610 gchar buf[128]; | |
611 gint buflen; | |
612 struct tm *btime; | |
613 GError *error = NULL; | |
614 | |
615 btime = localtime(&t); | |
616 | |
617 /* the %x warning about 2 digit years is not an error */ | |
618 buflen = strftime(buf, sizeof(buf), "%x %H:%M", btime); | |
619 if (buflen < 1) return ""; | |
620 | |
621 g_free(ret); | |
622 ret = g_locale_to_utf8(buf, buflen, NULL, NULL, &error); | |
623 if (error) | |
624 { | |
625 printf("Error converting locale strftime to UTF-8: %s\n", error->message); | |
626 g_error_free(error); | |
627 return ""; | |
628 } | |
629 | |
630 return ret; | |
1 | 631 } |
632 | |
9 | 633 /* |
634 *----------------------------------------------------------------------------- | |
635 * file info struct | |
636 *----------------------------------------------------------------------------- | |
637 */ | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
638 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
639 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source); |
167 | 640 static void file_data_check_sidecars(FileData *fd); |
641 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
642 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
643 |
138 | 644 static void file_data_set_path(FileData *fd, const gchar *path) |
645 { | |
9 | 646 |
138 | 647 if (strcmp(path, "/") == 0) |
648 { | |
649 fd->path = g_strdup(path); | |
650 fd->name = fd->path; | |
651 fd->extension = fd->name + 1; | |
652 return; | |
653 } | |
654 | |
655 fd->path = g_strdup(path); | |
656 fd->name = filename_from_path(fd->path); | |
657 | |
658 if (strcmp(fd->name, "..") == 0) | |
659 { | |
660 gchar *dir = remove_level_from_path(path); | |
661 g_free(fd->path); | |
662 fd->path = remove_level_from_path(dir); | |
663 g_free(dir); | |
664 fd->name = ".."; | |
665 fd->extension = fd->name + 2; | |
666 return; | |
667 } | |
668 else if (strcmp(fd->name, ".") == 0) | |
669 { | |
670 g_free(fd->path); | |
671 fd->path = remove_level_from_path(path); | |
672 fd->name = "."; | |
673 fd->extension = fd->name + 1; | |
674 return; | |
675 } | |
676 | |
677 fd->extension = extension_from_path(fd->path); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
678 if (fd->extension == NULL) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
679 fd->extension = fd->name + strlen(fd->name); |
138 | 680 } |
681 | |
167 | 682 static void file_data_check_changed_files(FileData *fd, struct stat *st) |
164 | 683 { |
167 | 684 GList *work; |
164 | 685 if (fd->size != st->st_size || |
686 fd->date != st->st_mtime) | |
687 { | |
688 fd->size = st->st_size; | |
689 fd->date = st->st_mtime; | |
690 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
691 fd->pixbuf = NULL; | |
692 } | |
167 | 693 |
694 work = fd->sidecar_files; | |
695 while (work) | |
696 { | |
697 FileData *sfd = work->data; | |
698 struct stat st; | |
699 | |
700 if (!stat_utf8(sfd->path, &st)) | |
701 { | |
702 file_data_disconnect_sidecar_file(fd, sfd); | |
703 } | |
704 | |
705 file_data_check_changed_files(sfd, &st); | |
706 work = work->next; | |
707 } | |
164 | 708 } |
709 | |
138 | 710 static GHashTable *file_data_pool = NULL; |
711 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
712 static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars) |
9 | 713 { |
714 FileData *fd; | |
715 | |
172 | 716 if (debug) printf("file_data_new: '%s' %d\n", path_utf8, check_sidecars); |
138 | 717 |
718 if (!file_data_pool) | |
719 file_data_pool = g_hash_table_new (g_str_hash, g_str_equal); | |
720 | |
721 fd = g_hash_table_lookup(file_data_pool, path_utf8); | |
722 if (fd) | |
723 { | |
167 | 724 file_data_check_changed_files(fd, st); |
172 | 725 if (debug) printf("file_data_pool hit: '%s'\n", fd->path); |
138 | 726 return file_data_ref(fd); |
727 } | |
728 | |
9 | 729 fd = g_new0(FileData, 1); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
730 |
138 | 731 file_data_set_path(fd, path_utf8); |
732 | |
733 fd->original_path = g_strdup(path_utf8); | |
9 | 734 fd->size = st->st_size; |
735 fd->date = st->st_mtime; | |
736 fd->pixbuf = NULL; | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
737 fd->sidecar_files = NULL; |
138 | 738 fd->ref = 1; |
739 fd->magick = 0x12345678; | |
740 | |
741 g_hash_table_insert(file_data_pool, fd->original_path, fd); | |
742 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
743 if (check_sidecars && sidecar_file_priority(fd->extension)) |
146 | 744 file_data_check_sidecars(fd); |
9 | 745 return fd; |
746 } | |
747 | |
146 | 748 static void file_data_check_sidecars(FileData *fd) |
749 { | |
750 int i = 0; | |
751 int base_len = fd->extension - fd->path; | |
752 GString *fname = g_string_new_len(fd->path, base_len); | |
753 FileData *parent_fd = NULL; | |
754 GList *work = sidecar_ext_get_list(); | |
755 while (work) | |
756 { | |
757 /* check for possible sidecar files; | |
758 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent, | |
759 they have fd->ref set to 0 and file_data unref must chack and free them all together | |
760 (using fd->ref would cause loops and leaks) | |
761 */ | |
762 | |
763 FileData *new_fd; | |
764 | |
765 gchar *ext = work->data; | |
766 work = work->next; | |
767 | |
768 if (strcmp(ext, fd->extension) == 0) | |
769 { | |
770 new_fd = fd; /* processing the original file */ | |
771 } | |
772 else | |
773 { | |
774 struct stat nst; | |
775 g_string_truncate(fname, base_len); | |
776 g_string_append(fname, ext); | |
777 | |
778 if (!stat_utf8(fname->str, &nst)) | |
779 continue; | |
780 | |
781 new_fd = file_data_new(fname->str, &nst, FALSE); | |
782 new_fd->ref--; /* do not use ref here */ | |
783 } | |
784 | |
785 if (!parent_fd) | |
786 parent_fd = new_fd; /* parent is the one with the highest prio, found first */ | |
787 else | |
788 file_data_merge_sidecar_files(parent_fd, new_fd); | |
789 } | |
790 g_string_free(fname, TRUE); | |
791 } | |
792 | |
793 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
794 static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean check_sidecars) |
138 | 795 { |
796 gchar *path_utf8 = path_to_utf8(path); | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
797 FileData *ret = file_data_new(path_utf8, st, check_sidecars); |
138 | 798 g_free(path_utf8); |
799 return ret; | |
800 } | |
801 | |
802 FileData *file_data_new_simple(const gchar *path_utf8) | |
9 | 803 { |
804 struct stat st; | |
805 | |
138 | 806 if (!stat_utf8(path_utf8, &st)) |
9 | 807 { |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
808 st.st_size = 0; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
809 st.st_mtime = 0; |
9 | 810 } |
811 | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
812 return file_data_new(path_utf8, &st, TRUE); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
813 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
814 |
141 | 815 FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd) |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
816 { |
141 | 817 sfd->parent = target; |
146 | 818 if(!g_list_find(target->sidecar_files, sfd)) |
819 target->sidecar_files = g_list_prepend(target->sidecar_files, sfd); | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
820 return target; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
821 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
822 |
167 | 823 |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
824 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source) |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
825 { |
141 | 826 GList *work; |
827 file_data_add_sidecar_file(target, source); | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
828 |
141 | 829 work = source->sidecar_files; |
830 while (work) | |
831 { | |
832 FileData *sfd = work->data; | |
146 | 833 file_data_add_sidecar_file(target, sfd); |
141 | 834 work = work->next; |
835 } | |
836 | |
146 | 837 g_list_free(source->sidecar_files); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
838 source->sidecar_files = NULL; |
167 | 839 |
840 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE); | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
841 return target; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
842 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
843 |
167 | 844 |
845 | |
138 | 846 FileData *file_data_ref(FileData *fd) |
847 { | |
848 if (fd == NULL) return NULL; | |
849 | |
850 // return g_memdup(fd, sizeof(FileData)); | |
851 g_assert(fd->magick == 0x12345678); | |
852 fd->ref++; | |
853 return fd; | |
854 } | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
855 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
856 static void file_data_free(FileData *fd) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
857 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
858 g_assert(fd->magick == 0x12345678); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
859 g_assert(fd->ref == 0); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
860 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
861 g_hash_table_remove(file_data_pool, fd->original_path); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
862 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
863 g_free(fd->path); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
864 g_free(fd->original_path); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
865 if (fd->pixbuf) g_object_unref(fd->pixbuf); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
866 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
867 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
868 g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
869 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
870 file_data_change_info_free(NULL, fd); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
871 g_free(fd); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
872 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
873 |
138 | 874 void file_data_unref(FileData *fd) |
875 { | |
876 if (fd == NULL) return; | |
877 g_assert(fd->magick == 0x12345678); | |
172 | 878 if (debug) printf("file_data_unref: '%s'\n", fd->path); |
138 | 879 fd->ref--; |
880 if (fd->ref == 0) | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
881 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
882 FileData *parent = fd->parent ? fd->parent : fd; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
883 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
884 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
885 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
886 if (parent->ref > 0) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
887 return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
888 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
889 work = parent->sidecar_files; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
890 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
891 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
892 FileData *sfd = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
893 if (sfd->ref > 0) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
894 return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
895 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
896 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
897 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
898 /* none of parent/children is referenced, we can free everything */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
899 |
172 | 900 if (debug) printf("file_data_unref: deleting '%s', parent '%s'\n", fd->path, parent->path); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
901 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
902 work = parent->sidecar_files; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
903 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
904 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
905 FileData *sfd = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
906 file_data_free(sfd); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
907 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
908 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
909 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
910 g_list_free(parent->sidecar_files); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
911 parent->sidecar_files = NULL; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
912 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
913 file_data_free(parent); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
914 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
915 } |
138 | 916 } |
917 | |
167 | 918 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd) |
919 { | |
920 sfd->parent = target; | |
921 g_assert(g_list_find(target->sidecar_files, sfd)); | |
922 | |
923 target->sidecar_files = g_list_remove(target->sidecar_files, sfd); | |
924 sfd->parent = NULL; | |
925 | |
926 if (sfd->ref == 0) { | |
927 file_data_free(sfd); | |
928 return NULL; | |
929 } | |
930 | |
931 return sfd; | |
932 } | |
933 | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
934 /* compare name without extension */ |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
935 gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2) |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
936 { |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
937 size_t len1 = fd1->extension - fd1->name; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
938 size_t len2 = fd2->extension - fd2->name; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
939 |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
940 if (len1 < len2) return -1; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
941 if (len1 > len2) return 1; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
942 |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
943 return strncmp(fd1->name, fd2->name, len1); |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
944 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
945 |
138 | 946 FileData *file_data_do_change(FileData *fd) |
947 { | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
948 //FIXME sidecars |
138 | 949 g_assert(fd->change); |
950 g_free(fd->path); | |
951 g_hash_table_remove(file_data_pool, fd->original_path); | |
952 g_free(fd->original_path); | |
953 file_data_set_path(fd, fd->change->dest); | |
954 fd->original_path = g_strdup(fd->change->dest); | |
955 g_hash_table_insert(file_data_pool, fd->original_path, fd); | |
956 | |
957 } | |
958 | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
959 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest) |
138 | 960 { |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
961 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
962 FileDataChangeInfo *fdci; |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
963 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
964 if (fd->change) return FALSE; |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
965 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
966 fdci = g_new0(FileDataChangeInfo, 1); |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
967 |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
968 fdci->type = type; |
138 | 969 |
970 if (src) | |
971 fdci->source = g_strdup(src); | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
972 else |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
973 fdci->source = g_strdup(fd->path); |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
974 |
138 | 975 if (dest) |
976 fdci->dest = g_strdup(dest); | |
977 | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
978 fd->change = fdci; |
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
141
diff
changeset
|
979 return TRUE; |
138 | 980 } |
981 | |
982 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd) | |
983 { | |
984 if (!fdci && fd) | |
985 fdci = fd->change; | |
986 | |
987 if (!fdci) | |
988 return; | |
989 | |
990 g_free(fdci->source); | |
991 g_free(fdci->dest); | |
992 | |
993 g_free(fdci); | |
994 | |
995 if (fd) | |
996 fd->change = NULL; | |
997 } | |
139 | 998 |
999 | |
1000 | |
138 | 1001 |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1002 /* |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1003 *----------------------------------------------------------------------------- |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1004 * sidecar file info struct |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1005 *----------------------------------------------------------------------------- |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1006 */ |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1007 |
9 | 1008 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1009 |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1010 gint sidecar_file_priority(const gchar *path) |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1011 { |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1012 const char *extension = extension_from_path(path); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1013 int i = 1; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1014 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1015 if (extension == NULL) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1016 return 0; |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1017 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1018 work = sidecar_ext_get_list(); |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1019 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1020 while (work) { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1021 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1022 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1023 if (strcmp(extension, ext) == 0) return i; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1024 i++; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1025 } |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1026 return 0; |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1027 } |
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1028 |
139 | 1029 gchar *sidecar_file_data_list_to_string(FileData *fd) |
1030 { | |
1031 GList *work; | |
1032 GString *result = g_string_new(""); | |
1033 | |
1034 work = fd->sidecar_files; | |
1035 while (work) | |
1036 { | |
141 | 1037 FileData *sfd = work->data; |
139 | 1038 result = g_string_append(result, "+ "); |
1039 result = g_string_append(result, sfd->extension); | |
1040 work = work->next; | |
1041 if (work) result = g_string_append_c(result, ' '); | |
1042 } | |
1043 | |
1044 return g_string_free(result, FALSE); | |
1045 } | |
1046 | |
9 | 1047 /* |
1048 *----------------------------------------------------------------------------- | |
1049 * load file list | |
1050 *----------------------------------------------------------------------------- | |
1051 */ | |
1052 | |
1053 static SortType filelist_sort_method = SORT_NONE; | |
1054 static gint filelist_sort_ascend = TRUE; | |
1055 | |
138 | 1056 |
1057 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb) | |
9 | 1058 { |
1059 if (!filelist_sort_ascend) | |
1060 { | |
138 | 1061 FileData *tmp = fa; |
1062 fa = fb; | |
1063 fb = tmp; | |
9 | 1064 } |
1065 | |
1066 switch (filelist_sort_method) | |
1067 { | |
1068 case SORT_SIZE: | |
1069 if (fa->size < fb->size) return -1; | |
1070 if (fa->size > fb->size) return 1; | |
167 | 1071 return CASE_SORT(fa->name, fb->name); /* fall back to name */ |
9 | 1072 break; |
1073 case SORT_TIME: | |
1074 if (fa->date < fb->date) return -1; | |
1075 if (fa->date > fb->date) return 1; | |
167 | 1076 return CASE_SORT(fa->name, fb->name); /* fall back to name */ |
9 | 1077 break; |
1078 #ifdef HAVE_STRVERSCMP | |
1079 case SORT_NUMBER: | |
1080 return strverscmp(fa->name, fb->name); | |
1081 break; | |
1082 #endif | |
1083 case SORT_NAME: | |
1084 default: | |
1085 return CASE_SORT(fa->name, fb->name); | |
1086 break; | |
1087 } | |
1088 } | |
1089 | |
167 | 1090 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gint ascend) |
1091 { | |
1092 filelist_sort_method = method; | |
1093 filelist_sort_ascend = ascend; | |
1094 return filelist_sort_compare_filedata(fa, fb); | |
1095 } | |
1096 | |
138 | 1097 static gint filelist_sort_file_cb(void *a, void *b) |
1098 { | |
1099 return filelist_sort_compare_filedata(a, b); | |
1100 } | |
1101 | |
1102 GList *filelist_sort_full(GList *list, SortType method, gint ascend, GCompareFunc cb) | |
9 | 1103 { |
1104 filelist_sort_method = method; | |
1105 filelist_sort_ascend = ascend; | |
138 | 1106 return g_list_sort(list, cb); |
1107 } | |
1108 | |
1109 GList *filelist_insert_sort_full(GList *list, void *data, SortType method, gint ascend, GCompareFunc cb) | |
1110 { | |
1111 filelist_sort_method = method; | |
1112 filelist_sort_ascend = ascend; | |
1113 return g_list_insert_sorted(list, data, cb); | |
1114 } | |
1115 | |
1116 GList *filelist_sort(GList *list, SortType method, gint ascend) | |
1117 { | |
1118 return filelist_sort_full(list, method, ascend, (GCompareFunc) filelist_sort_file_cb); | |
9 | 1119 } |
1120 | |
1121 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend) | |
1122 { | |
138 | 1123 return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb); |
9 | 1124 } |
1125 | |
137
be3328a58875
started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents:
101
diff
changeset
|
1126 |
148 | 1127 static GList *filelist_filter_out_sidecars(GList *flist) |
1128 { | |
1129 GList *work = flist; | |
1130 GList *flist_filtered = NULL; | |
1131 | |
1132 while (work) | |
1133 { | |
1134 FileData *fd = work->data; | |
1135 work = work->next; | |
1136 if (fd->parent) /* remove fd's that are children */ | |
1137 file_data_unref(fd); | |
1138 else | |
1139 flist_filtered = g_list_prepend(flist_filtered, fd); | |
1140 } | |
1141 g_list_free(flist); | |
1142 return flist_filtered; | |
1143 } | |
1144 | |
138 | 1145 static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks) |
1 | 1146 { |
1147 DIR *dp; | |
1148 struct dirent *dir; | |
1149 struct stat ent_sbuf; | |
9 | 1150 gchar *pathl; |
1151 GList *dlist; | |
1152 GList *flist; | |
1 | 1153 |
9 | 1154 dlist = NULL; |
1155 flist = NULL; | |
1156 | |
1157 pathl = path_from_utf8(path); | |
1158 if (!pathl || (dp = opendir(pathl)) == NULL) | |
1 | 1159 { |
9 | 1160 g_free(pathl); |
1161 if (files) *files = NULL; | |
1162 if (dirs) *dirs = NULL; | |
1163 return FALSE; | |
1 | 1164 } |
1165 | |
9 | 1166 /* root dir fix */ |
1167 if (pathl[0] == '/' && pathl[1] == '\0') | |
1168 { | |
1169 g_free(pathl); | |
1170 pathl = g_strdup(""); | |
1171 } | |
1 | 1172 |
1173 while ((dir = readdir(dp)) != NULL) | |
1174 { | |
9 | 1175 gchar *name = dir->d_name; |
1176 if (show_dot_files || !ishidden(name)) | |
1 | 1177 { |
9 | 1178 gchar *filepath = g_strconcat(pathl, "/", name, NULL); |
138 | 1179 if ((follow_symlinks ? |
1180 stat(filepath, &ent_sbuf) : | |
1181 lstat(filepath, &ent_sbuf)) >= 0) | |
1 | 1182 { |
9 | 1183 if (S_ISDIR(ent_sbuf.st_mode)) |
1 | 1184 { |
9 | 1185 /* we ignore the .thumbnails dir for cleanliness */ |
1186 if ((dirs) && | |
1187 !(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) && | |
1188 strcmp(name, GQVIEW_CACHE_LOCAL_THUMB) != 0 && | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
1189 strcmp(name, GQVIEW_CACHE_LOCAL_METADATA) != 0 && |
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
1190 strcmp(name, THUMB_FOLDER_LOCAL) != 0) |
9 | 1191 { |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
1192 dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, FALSE)); |
9 | 1193 } |
1 | 1194 } |
1195 else | |
1196 { | |
9 | 1197 if ((files) && filter_name_exists(name)) |
1198 { | |
148 | 1199 flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE)); |
9 | 1200 } |
1 | 1201 } |
1202 } | |
9 | 1203 g_free(filepath); |
1 | 1204 } |
1205 } | |
1206 | |
1207 closedir(dp); | |
1208 | |
9 | 1209 g_free(pathl); |
1 | 1210 |
148 | 1211 flist = filelist_filter_out_sidecars(flist); |
1212 | |
9 | 1213 if (dirs) *dirs = dlist; |
1214 if (files) *files = flist; | |
1 | 1215 |
9 | 1216 return TRUE; |
1 | 1217 } |
1218 | |
138 | 1219 gint filelist_read(const gchar *path, GList **files, GList **dirs) |
1220 { | |
1221 return filelist_read_real(path, files, dirs, TRUE); | |
1222 } | |
1223 | |
1224 gint filelist_read_lstat(const gchar *path, GList **files, GList **dirs) | |
1225 { | |
1226 return filelist_read_real(path, files, dirs, FALSE); | |
1227 } | |
1228 | |
9 | 1229 void filelist_free(GList *list) |
1 | 1230 { |
9 | 1231 GList *work; |
3 | 1232 |
9 | 1233 work = list; |
1234 while (work) | |
1 | 1235 { |
138 | 1236 file_data_unref((FileData *)work->data); |
1 | 1237 work = work->next; |
1238 } | |
1239 | |
9 | 1240 g_list_free(list); |
3 | 1241 } |
1242 | |
1 | 1243 |
138 | 1244 GList *filelist_copy(GList *list) |
1245 { | |
1246 GList *new_list = NULL; | |
1247 GList *work; | |
1248 | |
1249 work = list; | |
1250 while (work) | |
1251 { | |
1252 FileData *fd; | |
1253 | |
1254 fd = work->data; | |
1255 work = work->next; | |
1256 | |
1257 new_list = g_list_prepend(new_list, file_data_ref(fd)); | |
1258 } | |
1259 | |
1260 return g_list_reverse(new_list); | |
1261 } | |
1262 | |
1263 GList *filelist_from_path_list(GList *list) | |
1264 { | |
1265 GList *new_list = NULL; | |
1266 GList *work; | |
1267 | |
1268 work = list; | |
1269 while (work) | |
1270 { | |
1271 gchar *path; | |
1272 | |
1273 path = work->data; | |
1274 work = work->next; | |
1275 | |
1276 new_list = g_list_prepend(new_list, file_data_new_simple(path)); | |
1277 } | |
1278 | |
1279 return g_list_reverse(new_list); | |
1280 } | |
1281 | |
1282 GList *filelist_to_path_list(GList *list) | |
1283 { | |
1284 GList *new_list = NULL; | |
1285 GList *work; | |
1286 | |
1287 work = list; | |
1288 while (work) | |
1289 { | |
1290 FileData *fd; | |
1291 | |
1292 fd = work->data; | |
1293 work = work->next; | |
1294 | |
1295 new_list = g_list_prepend(new_list, g_strdup(fd->path)); | |
1296 } | |
1297 | |
1298 return g_list_reverse(new_list); | |
1299 } | |
1300 | |
1301 GList *filelist_filter(GList *list, gint is_dir_list) | |
1302 { | |
1303 GList *work; | |
1304 | |
1305 if (!is_dir_list && file_filter_disable && show_dot_files) return list; | |
1306 | |
1307 work = list; | |
1308 while (work) | |
1309 { | |
1310 FileData *fd = (FileData *)(work->data); | |
1311 const gchar *name = fd->name; | |
1312 | |
1313 if ((!show_dot_files && ishidden(name)) || | |
1314 (!is_dir_list && !filter_name_exists(name)) || | |
1315 (is_dir_list && name[0] == '.' && (strcmp(name, GQVIEW_CACHE_LOCAL_THUMB) == 0 || | |
1316 strcmp(name, GQVIEW_CACHE_LOCAL_METADATA) == 0)) ) | |
1317 { | |
1318 GList *link = work; | |
1319 work = work->next; | |
1320 list = g_list_remove_link(list, link); | |
1321 file_data_unref(fd); | |
1322 g_list_free(link); | |
1323 } | |
1324 else | |
1325 { | |
1326 work = work->next; | |
1327 } | |
1328 } | |
1329 | |
1330 return list; | |
1331 } | |
1332 | |
1333 /* | |
1334 *----------------------------------------------------------------------------- | |
1335 * filelist recursive | |
1336 *----------------------------------------------------------------------------- | |
1337 */ | |
1338 | |
1339 static gint filelist_sort_path_cb(gconstpointer a, gconstpointer b) | |
1340 { | |
1341 return CASE_SORT(((FileData *)a)->path, ((FileData *)b)->path); | |
1342 } | |
1343 | |
1344 GList *filelist_sort_path(GList *list) | |
1345 { | |
1346 return g_list_sort(list, filelist_sort_path_cb); | |
1347 } | |
1348 | |
1349 static void filelist_recursive_append(GList **list, GList *dirs) | |
1350 { | |
1351 GList *work; | |
1352 | |
1353 work = dirs; | |
1354 while (work) | |
1355 { | |
1356 FileData *fd = (FileData *)(work->data); | |
1357 const gchar *path = fd->path; | |
1358 GList *f = NULL; | |
1359 GList *d = NULL; | |
1360 | |
1361 if (filelist_read(path, &f, &d)) | |
1362 { | |
1363 f = filelist_filter(f, FALSE); | |
1364 f = filelist_sort_path(f); | |
1365 *list = g_list_concat(*list, f); | |
1366 | |
1367 d = filelist_filter(d, TRUE); | |
1368 d = filelist_sort_path(d); | |
1369 filelist_recursive_append(list, d); | |
1370 filelist_free(d); | |
1371 } | |
1372 | |
1373 work = work->next; | |
1374 } | |
1375 } | |
1376 | |
1377 GList *filelist_recursive(const gchar *path) | |
1378 { | |
1379 GList *list = NULL; | |
1380 GList *d = NULL; | |
1381 | |
1382 if (!filelist_read(path, &list, &d)) return NULL; | |
1383 list = filelist_filter(list, FALSE); | |
1384 list = filelist_sort_path(list); | |
1385 | |
1386 d = filelist_filter(d, TRUE); | |
1387 d = filelist_sort_path(d); | |
1388 filelist_recursive_append(&list, d); | |
1389 filelist_free(d); | |
1390 | |
1391 return list; | |
1392 } |