Mercurial > geeqie
annotate src/filefilter.c @ 586:905688aa2317
split filelist.c to filefilter.c and filedata.c
author | nadvornik |
---|---|
date | Mon, 05 May 2008 19:11:12 +0000 |
parents | src/filelist.c@9dc0513837b5 |
children | 5963c394ba53 |
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); |
43
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
227 |
ee03f36e9e4b
Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
228 /* 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
|
229 * (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
|
230 */ |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 filter_add_if_missing("orf", "Olympus raw format", ".orf", FORMAT_CLASS_RAWIMAGE, TRUE); |
277 | 239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 filter_add_if_missing("erf", "Epson raw format", ".erf", FORMAT_CLASS_RAWIMAGE, TRUE); |
9 | 246 } |
247 | |
147
b2266996fa83
added possibility to specify prefered file type for external commands
nadvornik
parents:
146
diff
changeset
|
248 GList *filter_to_list(const gchar *extensions) |
9 | 249 { |
250 GList *list = NULL; | |
251 const gchar *p; | |
252 | |
253 if (!extensions) return NULL; | |
254 | |
255 p = extensions; | |
256 while (*p != '\0') | |
257 { | |
258 const gchar *b; | |
259 gint l = 0; | |
260 | |
261 b = p; | |
262 while (*p != '\0' && *p != ';') | |
263 { | |
264 p++; | |
265 l++; | |
266 } | |
267 list = g_list_append(list, g_strndup(b, l)); | |
268 if (*p == ';') p++; | |
269 } | |
270 | |
271 return list; | |
272 } | |
273 | |
274 void filter_rebuild(void) | |
275 { | |
276 GList *work; | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
277 gint i; |
9 | 278 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
279 string_list_free(extension_list); |
9 | 280 extension_list = NULL; |
281 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
282 for (i = 0; i < FILE_FORMAT_CLASSES; i++) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
283 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
284 string_list_free(file_class_extension_list[i]); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
285 file_class_extension_list[i] = NULL; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
286 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
287 |
9 | 288 work = filter_list; |
289 while (work) | |
290 { | |
291 FilterEntry *fe; | |
292 | |
293 fe = work->data; | |
294 work = work->next; | |
295 | |
296 if (fe->enabled) | |
297 { | |
298 GList *ext; | |
299 | |
300 ext = filter_to_list(fe->extensions); | |
301 if (ext) extension_list = g_list_concat(extension_list, ext); | |
442 | 302 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
303 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
|
304 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
305 ext = filter_to_list(fe->extensions); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
306 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
|
307 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
308 else |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
309 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
310 printf("WARNING: invalid file class %d\n", fe->file_class); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
311 } |
9 | 312 } |
313 } | |
314 } | |
315 | |
316 gint filter_name_exists(const gchar *name) | |
317 { | |
318 GList *work; | |
215 | 319 gint ln; |
320 | |
332 | 321 if (!extension_list || options->file_filter.disable) return TRUE; |
9 | 322 |
215 | 323 ln = strlen(name); |
9 | 324 work = extension_list; |
1 | 325 while (work) |
326 { | |
327 gchar *filter = work->data; | |
328 gint lf = strlen(filter); | |
215 | 329 |
1 | 330 if (ln >= lf) |
331 { | |
332 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE; | |
333 } | |
334 work = work->next; | |
335 } | |
336 | |
337 return FALSE; | |
338 } | |
339 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
340 gint filter_file_class(const gchar *name, FileFormatClass file_class) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
341 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
342 GList *work; |
215 | 343 gint ln; |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
344 |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
345 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
346 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
347 printf("WARNING: invalid file class %d\n", file_class); |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
348 return FALSE; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
349 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
350 |
215 | 351 ln = strlen(name); |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
352 work = file_class_extension_list[file_class]; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
353 while (work) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
354 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
355 gchar *filter = work->data; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
356 gint lf = strlen(filter); |
215 | 357 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
358 if (ln >= lf) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
359 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
360 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
361 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
362 work = work->next; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
363 } |
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 return FALSE; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
366 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
367 |
276 | 368 void filter_write_list(SecureSaveInfo *ssi) |
1 | 369 { |
9 | 370 GList *work; |
371 | |
372 work = filter_list; | |
373 while (work) | |
374 { | |
375 FilterEntry *fe = work->data; | |
376 work = work->next; | |
442 | 377 |
217 | 378 gchar *extensions = escquote_value(fe->extensions); |
379 gchar *description = escquote_value(fe->description); | |
9 | 380 |
370 | 381 secure_fprintf(ssi, "file_filter.ext: \"%s%s\" %s %s %d\n", |
276 | 382 (fe->enabled) ? "" : "#", |
370 | 383 fe->key, extensions, description, fe->file_class); |
217 | 384 g_free(extensions); |
385 g_free(description); | |
9 | 386 } |
1 | 387 } |
388 | |
9 | 389 void filter_parse(const gchar *text) |
1 | 390 { |
9 | 391 const gchar *p; |
392 gchar *key; | |
393 gchar *ext; | |
394 gchar *desc; | |
395 gint enabled = TRUE; | |
370 | 396 gint file_class; |
9 | 397 |
398 if (!text || text[0] != '"') return; | |
399 | |
217 | 400 key = quoted_value(text, &p); |
9 | 401 if (!key) return; |
402 | |
217 | 403 ext = quoted_value(p, &p); |
404 desc = quoted_value(p, &p); | |
442 | 405 |
370 | 406 file_class = strtol(p, NULL, 10); |
442 | 407 |
370 | 408 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) file_class = FORMAT_CLASS_UNKNOWN; |
9 | 409 |
410 if (key && key[0] == '#') | |
411 { | |
412 gchar *tmp; | |
413 tmp = g_strdup(key + 1); | |
414 g_free(key); | |
415 key = tmp; | |
416 | |
417 enabled = FALSE; | |
1 | 418 } |
419 | |
370 | 420 if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, file_class, enabled); |
9 | 421 |
422 g_free(key); | |
423 g_free(ext); | |
424 g_free(desc); | |
425 } | |
1 | 426 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
427 /* |
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 * sidecar extension list |
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 */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
432 |
586 | 433 GList *sidecar_ext_get_list(void) |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
434 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
435 return sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
436 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
437 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
438 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
|
439 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
440 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
441 gchar *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 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
444 while (work) |
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 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
447 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
448 g_free(ext); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
449 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
450 g_list_free(sidecar_ext_list); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
451 sidecar_ext_list = NULL; |
442 | 452 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
453 if (quoted) |
217 | 454 value = quoted_value(text, NULL); |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
455 else |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
456 value = g_strdup(text); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
457 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
458 if (value == NULL) return; |
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 sidecar_ext_list = filter_to_list(value); |
442 | 461 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
462 g_free(value); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
463 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
464 |
276 | 465 void sidecar_ext_write(SecureSaveInfo *ssi) |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
466 { |
347 | 467 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
|
468 } |
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 char *sidecar_ext_to_string() |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
471 { |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
472 GList *work; |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
473 GString *str = g_string_new(""); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
474 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
475 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
476 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
477 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
478 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
479 work = work->next; |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
480 g_string_append(str, ext); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
481 if (work) g_string_append(str, ";"); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
482 } |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
483 return g_string_free(str, FALSE); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
484 } |
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 void sidecar_ext_add_defaults() |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
487 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
172
diff
changeset
|
488 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
|
489 } |