Mercurial > geeqie.yaz
annotate src/filefilter.c @ 596:f8c93e1d728d
use some of the new functions in filedata.c
author | nadvornik |
---|---|
date | Tue, 06 May 2008 20:24:16 +0000 |
parents | 5963c394ba53 |
children | 651ae2be1031 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
3 * (C) 2006 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
1 | 5 * |
6 * Author: John Ellis | |
7 * | |
9 | 8 * This software is released under the GNU General Public License (GNU GPL). |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 11 */ |
12 | |
13 | |
281 | 14 #include "main.h" |
586 | 15 #include "filefilter.h" |
1 | 16 |
9 | 17 #include "cache.h" |
507 | 18 #include "debug.h" |
9 | 19 #include "rcfile.h" |
307
667e49f52168
Move secure save code to its own files: secure_save.{c,h}.
zas_
parents:
283
diff
changeset
|
20 #include "secure_save.h" |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
21 #include "thumb_standard.h" |
9 | 22 #include "ui_fileops.h" |
1 | 23 |
24 | |
25 /* | |
26 *----------------------------------------------------------------------------- | |
27 * file filtering | |
28 *----------------------------------------------------------------------------- | |
29 */ | |
30 | |
9 | 31 static GList *filter_list = NULL; |
32 static GList *extension_list = NULL; | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
33 static GList *sidecar_ext_list = NULL; |
9 | 34 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
35 static GList *file_class_extension_list[FILE_FORMAT_CLASSES]; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
36 |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
37 |
9 | 38 gint ishidden(const gchar *name) |
1 | 39 { |
40 if (name[0] != '.') return FALSE; | |
41 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE; | |
42 return TRUE; | |
43 } | |
44 | |
9 | 45 static FilterEntry *filter_entry_new(const gchar *key, const gchar *description, |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
46 const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 47 { |
48 FilterEntry *fe; | |
49 | |
50 fe = g_new0(FilterEntry, 1); | |
51 fe->key = g_strdup(key); | |
52 fe->description = g_strdup(description); | |
53 fe->extensions = g_strdup(extensions); | |
54 fe->enabled = enabled; | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
55 fe->file_class = file_class; |
442 | 56 |
9 | 57 return fe; |
58 } | |
59 | |
60 static void filter_entry_free(FilterEntry *fe) | |
61 { | |
62 if (!fe) return; | |
63 | |
64 g_free(fe->key); | |
65 g_free(fe->description); | |
66 g_free(fe->extensions); | |
67 g_free(fe); | |
68 } | |
69 | |
70 GList *filter_get_list(void) | |
71 { | |
72 return filter_list; | |
73 } | |
74 | |
75 void filter_remove_entry(FilterEntry *fe) | |
76 { | |
77 if (!g_list_find(filter_list, fe)) return; | |
78 | |
79 filter_list = g_list_remove(filter_list, fe); | |
80 filter_entry_free(fe); | |
81 } | |
82 | |
83 static gint filter_key_exists(const gchar *key) | |
84 { | |
85 GList *work; | |
86 | |
87 if (!key) return FALSE; | |
88 | |
89 work = filter_list; | |
90 while (work) | |
91 { | |
92 FilterEntry *fe = work->data; | |
93 work = work->next; | |
94 | |
95 if (strcmp(fe->key, key) == 0) return TRUE; | |
96 } | |
97 | |
98 return FALSE; | |
99 } | |
100 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
101 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 102 { |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
103 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, file_class, enabled)); |
9 | 104 } |
105 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
106 void filter_add_unique(const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 107 { |
108 gchar *key; | |
109 gint n; | |
110 | |
111 key = g_strdup("user0"); | |
112 n = 1; | |
113 while (filter_key_exists(key)) | |
114 { | |
115 g_free(key); | |
116 if (n > 999) return; | |
117 key = g_strdup_printf("user%d", n); | |
118 n++; | |
119 } | |
120 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
121 filter_add(key, description, extensions, file_class, enabled); |
9 | 122 g_free(key); |
123 } | |
124 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
125 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 126 { |
127 GList *work; | |
128 | |
129 if (!key) return; | |
130 | |
131 work = filter_list; | |
132 while (work) | |
133 { | |
134 FilterEntry *fe = work->data; | |
135 work = work->next; | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
136 if (fe->key && strcmp(fe->key, key) == 0) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
137 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
138 if (fe->file_class == FORMAT_CLASS_UNKNOWN) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
139 fe->file_class = file_class; /* for compatibility */ |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
140 return; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
141 } |
9 | 142 } |
143 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
144 filter_add(key, description, extensions, file_class, enabled); |
9 | 145 } |
146 | |
147 void filter_reset(void) | |
1 | 148 { |
149 GList *work; | |
9 | 150 |
151 work = filter_list; | |
152 while (work) | |
153 { | |
154 FilterEntry *fe = work->data; | |
155 work = work->next; | |
156 filter_entry_free(fe); | |
157 } | |
158 | |
159 g_list_free(filter_list); | |
160 filter_list = NULL; | |
161 } | |
162 | |
163 void filter_add_defaults(void) | |
164 { | |
165 GSList *list, *work; | |
166 | |
167 list = gdk_pixbuf_get_formats(); | |
168 work = list; | |
169 while (work) | |
170 { | |
171 GdkPixbufFormat *format; | |
172 gchar *name; | |
173 gchar *desc; | |
174 gchar **extensions; | |
175 GString *filter = NULL; | |
176 gint i; | |
442 | 177 |
9 | 178 format = work->data; |
179 work = work->next; | |
180 | |
181 name = gdk_pixbuf_format_get_name(format); | |
182 desc = gdk_pixbuf_format_get_description(format); | |
183 extensions = gdk_pixbuf_format_get_extensions(format); | |
184 | |
185 i = 0; | |
186 while (extensions[i]) | |
187 { | |
188 if (!filter) | |
189 { | |
190 filter = g_string_new("."); | |
191 filter = g_string_append(filter, extensions[i]); | |
192 } | |
193 else | |
194 { | |
195 filter = g_string_append(filter, ";."); | |
196 filter = g_string_append(filter, extensions[i]); | |
197 } | |
198 i++; | |
199 } | |
200 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
201 DEBUG_1("loader reported [%s] [%s] [%s]", name, desc, filter->str); |
9 | 202 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
203 filter_add_if_missing(name, desc, filter->str, FORMAT_CLASS_IMAGE, TRUE); |
9 | 204 |
205 g_free(name); | |
206 g_free(desc); | |
207 g_strfreev(extensions); | |
208 g_string_free(filter, TRUE); | |
209 } | |
210 g_slist_free(list); | |
1 | 211 |
9 | 212 /* add defaults even if gdk-pixbuf does not have them, but disabled */ |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
213 filter_add_if_missing("jpeg", "JPEG group", ".jpg;.jpeg;.jpe", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
214 filter_add_if_missing("png", "Portable Network Graphic", ".png", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
215 filter_add_if_missing("tiff", "Tiff", ".tif;.tiff", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
216 filter_add_if_missing("pnm", "Packed Pixel formats", ".pbm;.pgm;.pnm;.ppm", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
217 filter_add_if_missing("gif", "Graphics Interchange Format", ".gif", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
218 filter_add_if_missing("xbm", "X bitmap", ".xbm", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
219 filter_add_if_missing("xpm", "X pixmap", ".xpm", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
220 filter_add_if_missing("bmp", "Bitmap", ".bmp", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
221 filter_add_if_missing("ico", "Icon file", ".ico;.cur", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
222 filter_add_if_missing("ras", "Raster", ".ras", FORMAT_CLASS_IMAGE, FALSE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
223 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, FALSE); |
442 | 224 |
202
f95654aeec4b
added all possible raw extensions that I could find
nadvornik
parents:
196
diff
changeset
|
225 /* non-image files that might be desirable to show */ |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
226 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE); |
587 | 227 filter_add_if_missing("gqv", GQ_APPNAME " image collection", ".gqv", FORMAT_CLASS_META, TRUE); |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
228 |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
229 /* These are the raw camera formats with embedded jpeg/exif. |
202
f95654aeec4b
added all possible raw extensions that I could find
nadvornik
parents:
196
diff
changeset
|
230 * (see format_raw.c and/or exiv2.cc) |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
231 */ |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
232 filter_add_if_missing("arw", "Sony raw format", ".arw;.srf;.sr2", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
233 filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
234 filter_add_if_missing("kdc", "Kodak raw format", ".kdc;.dcr", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
235 filter_add_if_missing("raf", "Fujifilm raw format", ".raf", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
236 filter_add_if_missing("mef", "Mamiya raw format", ".mef;.mos", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
237 filter_add_if_missing("mrw", "Minolta raw format", ".mrw", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
238 filter_add_if_missing("nef", "Nikon raw format", ".nef", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
239 filter_add_if_missing("orf", "Olympus raw format", ".orf", FORMAT_CLASS_RAWIMAGE, TRUE); |
277 | 240 filter_add_if_missing("pef", "Pentax or Samsung raw format", ".pef;.ptx", FORMAT_CLASS_RAWIMAGE, TRUE); |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
241 filter_add_if_missing("dng", "Adobe Digital Negative raw format", ".dng", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
242 filter_add_if_missing("x3f", "Sigma raw format", ".x3f", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
243 filter_add_if_missing("raw", "Panasonic raw format", ".raw", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
244 filter_add_if_missing("r3d", "Red raw format", ".r3d", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
245 filter_add_if_missing("3fr", "Hasselblad raw format", ".3fr", FORMAT_CLASS_RAWIMAGE, TRUE); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
246 filter_add_if_missing("erf", "Epson raw format", ".erf", FORMAT_CLASS_RAWIMAGE, TRUE); |
9 | 247 } |
248 | |
147
b2266996fa83
added possibility to specify prefered file type for external commands
nadvornik
parents:
146
diff
changeset
|
249 GList *filter_to_list(const gchar *extensions) |
9 | 250 { |
251 GList *list = NULL; | |
252 const gchar *p; | |
253 | |
254 if (!extensions) return NULL; | |
255 | |
256 p = extensions; | |
257 while (*p != '\0') | |
258 { | |
259 const gchar *b; | |
260 gint l = 0; | |
261 | |
262 b = p; | |
263 while (*p != '\0' && *p != ';') | |
264 { | |
265 p++; | |
266 l++; | |
267 } | |
268 list = g_list_append(list, g_strndup(b, l)); | |
269 if (*p == ';') p++; | |
270 } | |
271 | |
272 return list; | |
273 } | |
274 | |
275 void filter_rebuild(void) | |
276 { | |
277 GList *work; | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
278 gint i; |
9 | 279 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
280 string_list_free(extension_list); |
9 | 281 extension_list = NULL; |
282 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
283 for (i = 0; i < FILE_FORMAT_CLASSES; i++) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
284 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
285 string_list_free(file_class_extension_list[i]); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
286 file_class_extension_list[i] = NULL; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
287 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
288 |
9 | 289 work = filter_list; |
290 while (work) | |
291 { | |
292 FilterEntry *fe; | |
293 | |
294 fe = work->data; | |
295 work = work->next; | |
296 | |
297 if (fe->enabled) | |
298 { | |
299 GList *ext; | |
300 | |
301 ext = filter_to_list(fe->extensions); | |
302 if (ext) extension_list = g_list_concat(extension_list, ext); | |
442 | 303 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
304 if (fe->file_class >= 0 && fe->file_class < FILE_FORMAT_CLASSES) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
305 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
306 ext = filter_to_list(fe->extensions); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
307 if (ext) file_class_extension_list[fe->file_class] = g_list_concat(file_class_extension_list[fe->file_class], ext); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
308 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
309 else |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
310 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
311 printf("WARNING: invalid file class %d\n", fe->file_class); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
312 } |
9 | 313 } |
314 } | |
315 } | |
316 | |
317 gint filter_name_exists(const gchar *name) | |
318 { | |
319 GList *work; | |
215 | 320 gint ln; |
321 | |
332 | 322 if (!extension_list || options->file_filter.disable) return TRUE; |
9 | 323 |
215 | 324 ln = strlen(name); |
9 | 325 work = extension_list; |
1 | 326 while (work) |
327 { | |
328 gchar *filter = work->data; | |
329 gint lf = strlen(filter); | |
215 | 330 |
1 | 331 if (ln >= lf) |
332 { | |
333 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE; | |
334 } | |
335 work = work->next; | |
336 } | |
337 | |
338 return FALSE; | |
339 } | |
340 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
341 gint filter_file_class(const gchar *name, FileFormatClass file_class) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
342 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
343 GList *work; |
215 | 344 gint ln; |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
345 |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
346 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
347 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
348 printf("WARNING: invalid file class %d\n", file_class); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
349 return FALSE; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
350 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
351 |
215 | 352 ln = strlen(name); |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
353 work = file_class_extension_list[file_class]; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
354 while (work) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
355 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
356 gchar *filter = work->data; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
357 gint lf = strlen(filter); |
215 | 358 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
359 if (ln >= lf) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
360 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
361 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
362 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
363 work = work->next; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
364 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
365 |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
366 return FALSE; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
367 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
368 |
276 | 369 void filter_write_list(SecureSaveInfo *ssi) |
1 | 370 { |
9 | 371 GList *work; |
372 | |
373 work = filter_list; | |
374 while (work) | |
375 { | |
376 FilterEntry *fe = work->data; | |
377 work = work->next; | |
442 | 378 |
217 | 379 gchar *extensions = escquote_value(fe->extensions); |
380 gchar *description = escquote_value(fe->description); | |
9 | 381 |
370 | 382 secure_fprintf(ssi, "file_filter.ext: \"%s%s\" %s %s %d\n", |
276 | 383 (fe->enabled) ? "" : "#", |
370 | 384 fe->key, extensions, description, fe->file_class); |
217 | 385 g_free(extensions); |
386 g_free(description); | |
9 | 387 } |
1 | 388 } |
389 | |
9 | 390 void filter_parse(const gchar *text) |
1 | 391 { |
9 | 392 const gchar *p; |
393 gchar *key; | |
394 gchar *ext; | |
395 gchar *desc; | |
396 gint enabled = TRUE; | |
370 | 397 gint file_class; |
9 | 398 |
399 if (!text || text[0] != '"') return; | |
400 | |
217 | 401 key = quoted_value(text, &p); |
9 | 402 if (!key) return; |
403 | |
217 | 404 ext = quoted_value(p, &p); |
405 desc = quoted_value(p, &p); | |
442 | 406 |
370 | 407 file_class = strtol(p, NULL, 10); |
442 | 408 |
370 | 409 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) file_class = FORMAT_CLASS_UNKNOWN; |
9 | 410 |
411 if (key && key[0] == '#') | |
412 { | |
413 gchar *tmp; | |
414 tmp = g_strdup(key + 1); | |
415 g_free(key); | |
416 key = tmp; | |
417 | |
418 enabled = FALSE; | |
1 | 419 } |
420 | |
370 | 421 if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, file_class, enabled); |
9 | 422 |
423 g_free(key); | |
424 g_free(ext); | |
425 g_free(desc); | |
426 } | |
1 | 427 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
428 /* |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
429 *----------------------------------------------------------------------------- |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
430 * sidecar extension list |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
431 *----------------------------------------------------------------------------- |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
432 */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
433 |
586 | 434 GList *sidecar_ext_get_list(void) |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
435 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
436 return sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
437 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
438 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
439 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
|
440 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
441 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
442 gchar *value; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
443 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
444 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
445 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
446 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
447 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
448 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
449 g_free(ext); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
450 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
451 g_list_free(sidecar_ext_list); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
452 sidecar_ext_list = NULL; |
442 | 453 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
454 if (quoted) |
217 | 455 value = quoted_value(text, NULL); |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
456 else |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
457 value = g_strdup(text); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
458 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
459 if (value == NULL) return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
460 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
461 sidecar_ext_list = filter_to_list(value); |
442 | 462 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
463 g_free(value); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
464 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
465 |
276 | 466 void sidecar_ext_write(SecureSaveInfo *ssi) |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
467 { |
347 | 468 secure_fprintf(ssi, "sidecar.ext: \"%s\"\n", sidecar_ext_to_string()); |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
469 } |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
470 |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
471 char *sidecar_ext_to_string() |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
472 { |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
473 GList *work; |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
474 GString *str = g_string_new(""); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
475 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
476 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
477 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
478 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
479 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
480 work = work->next; |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
481 g_string_append(str, ext); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
482 if (work) g_string_append(str, ";"); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
483 } |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
484 return g_string_free(str, FALSE); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
485 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
486 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
487 void sidecar_ext_add_defaults() |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
488 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
172
diff
changeset
|
489 sidecar_ext_parse(".jpg;.cr2;.nef;.crw;.xmp", FALSE); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
490 } |