Mercurial > geeqie
annotate src/filefilter.c @ 684:9f00d0d874fa
Save order of Properties dialog tabs to rc file.
Users of GTK+ <2.10 can set tabs order directly in the rc file,
others can move tabs using drag'n drop.
The option is named properties.tabs_order, its default value
is "123" which is General, Keywords, Exif tabs (left to right).
author | zas_ |
---|---|
date | Sun, 18 May 2008 21:14:01 +0000 |
parents | fbebf5cf4a55 |
children | a7289f9e8d29 |
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" |
18 #include "rcfile.h" | |
307
667e49f52168
Move secure save code to its own files: secure_save.{c,h}.
zas_
parents:
283
diff
changeset
|
19 #include "secure_save.h" |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
53
diff
changeset
|
20 #include "thumb_standard.h" |
9 | 21 #include "ui_fileops.h" |
1 | 22 |
23 | |
24 /* | |
25 *----------------------------------------------------------------------------- | |
26 * file filtering | |
27 *----------------------------------------------------------------------------- | |
28 */ | |
29 | |
9 | 30 static GList *filter_list = NULL; |
31 static GList *extension_list = NULL; | |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
32 static GList *sidecar_ext_list = NULL; |
9 | 33 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
34 static GList *file_class_extension_list[FILE_FORMAT_CLASSES]; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
35 |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
36 |
9 | 37 gint ishidden(const gchar *name) |
1 | 38 { |
39 if (name[0] != '.') return FALSE; | |
40 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE; | |
41 return TRUE; | |
42 } | |
43 | |
9 | 44 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
|
45 const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 46 { |
47 FilterEntry *fe; | |
48 | |
49 fe = g_new0(FilterEntry, 1); | |
50 fe->key = g_strdup(key); | |
51 fe->description = g_strdup(description); | |
52 fe->extensions = g_strdup(extensions); | |
53 fe->enabled = enabled; | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
54 fe->file_class = file_class; |
442 | 55 |
9 | 56 return fe; |
57 } | |
58 | |
59 static void filter_entry_free(FilterEntry *fe) | |
60 { | |
61 if (!fe) return; | |
62 | |
63 g_free(fe->key); | |
64 g_free(fe->description); | |
65 g_free(fe->extensions); | |
66 g_free(fe); | |
67 } | |
68 | |
69 GList *filter_get_list(void) | |
70 { | |
71 return filter_list; | |
72 } | |
73 | |
74 void filter_remove_entry(FilterEntry *fe) | |
75 { | |
76 if (!g_list_find(filter_list, fe)) return; | |
77 | |
78 filter_list = g_list_remove(filter_list, fe); | |
79 filter_entry_free(fe); | |
80 } | |
81 | |
82 static gint filter_key_exists(const gchar *key) | |
83 { | |
84 GList *work; | |
85 | |
86 if (!key) return FALSE; | |
87 | |
88 work = filter_list; | |
89 while (work) | |
90 { | |
91 FilterEntry *fe = work->data; | |
92 work = work->next; | |
93 | |
94 if (strcmp(fe->key, key) == 0) return TRUE; | |
95 } | |
96 | |
97 return FALSE; | |
98 } | |
99 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
100 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 101 { |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
102 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, file_class, enabled)); |
9 | 103 } |
104 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
105 void filter_add_unique(const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 106 { |
107 gchar *key; | |
108 gint n; | |
109 | |
110 key = g_strdup("user0"); | |
111 n = 1; | |
112 while (filter_key_exists(key)) | |
113 { | |
114 g_free(key); | |
115 if (n > 999) return; | |
116 key = g_strdup_printf("user%d", n); | |
117 n++; | |
118 } | |
119 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
120 filter_add(key, description, extensions, file_class, enabled); |
9 | 121 g_free(key); |
122 } | |
123 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
124 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled) |
9 | 125 { |
126 GList *work; | |
127 | |
128 if (!key) return; | |
129 | |
130 work = filter_list; | |
131 while (work) | |
132 { | |
133 FilterEntry *fe = work->data; | |
134 work = work->next; | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
135 if (fe->key && strcmp(fe->key, key) == 0) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
136 { |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
137 if (fe->file_class == FORMAT_CLASS_UNKNOWN) |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
138 fe->file_class = file_class; /* for compatibility */ |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
139 return; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
140 } |
9 | 141 } |
142 | |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
143 filter_add(key, description, extensions, file_class, enabled); |
9 | 144 } |
145 | |
146 void filter_reset(void) | |
1 | 147 { |
148 GList *work; | |
9 | 149 |
150 work = filter_list; | |
151 while (work) | |
152 { | |
153 FilterEntry *fe = work->data; | |
154 work = work->next; | |
155 filter_entry_free(fe); | |
156 } | |
157 | |
158 g_list_free(filter_list); | |
159 filter_list = NULL; | |
160 } | |
161 | |
162 void filter_add_defaults(void) | |
163 { | |
164 GSList *list, *work; | |
165 | |
166 list = gdk_pixbuf_get_formats(); | |
167 work = list; | |
168 while (work) | |
169 { | |
170 GdkPixbufFormat *format; | |
171 gchar *name; | |
172 gchar *desc; | |
173 gchar **extensions; | |
174 GString *filter = NULL; | |
175 gint i; | |
442 | 176 |
9 | 177 format = work->data; |
178 work = work->next; | |
179 | |
180 name = gdk_pixbuf_format_get_name(format); | |
181 desc = gdk_pixbuf_format_get_description(format); | |
182 extensions = gdk_pixbuf_format_get_extensions(format); | |
183 | |
184 i = 0; | |
185 while (extensions[i]) | |
186 { | |
187 if (!filter) | |
188 { | |
189 filter = g_string_new("."); | |
190 filter = g_string_append(filter, extensions[i]); | |
191 } | |
192 else | |
193 { | |
194 filter = g_string_append(filter, ";."); | |
195 filter = g_string_append(filter, extensions[i]); | |
196 } | |
197 i++; | |
198 } | |
199 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
200 DEBUG_1("loader reported [%s] [%s] [%s]", name, desc, filter->str); |
9 | 201 |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
202 filter_add_if_missing(name, desc, filter->str, FORMAT_CLASS_IMAGE, TRUE); |
9 | 203 |
204 g_free(name); | |
205 g_free(desc); | |
206 g_strfreev(extensions); | |
207 g_string_free(filter, TRUE); | |
208 } | |
209 g_slist_free(list); | |
1 | 210 |
9 | 211 /* 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, FALSE); |
442 | 223 |
202
f95654aeec4b
added all possible raw extensions that I could find
nadvornik
parents:
196
diff
changeset
|
224 /* non-image files that might be desirable to show */ |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
225 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE); |
587 | 226 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
|
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 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
310 log_printf("WARNING: invalid file class %d\n", fe->file_class); |
212
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 { | |
605
651ae2be1031
Use g_ascii_strncasecmp() instead of strncasecmp() where applicable.
zas_
parents:
587
diff
changeset
|
332 /* FIXME: utf8 */ |
1 | 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 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
348 log_printf("WARNING: invalid file class %d\n", file_class); |
212
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 { |
605
651ae2be1031
Use g_ascii_strncasecmp() instead of strncasecmp() where applicable.
zas_
parents:
587
diff
changeset
|
361 /* FIXME: utf8 */ |
212
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
362 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE; |
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 work = work->next; |
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 |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
367 return FALSE; |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
368 } |
c7021159079d
differentiate among normal image, raw image and metadata
nadvornik
parents:
202
diff
changeset
|
369 |
276 | 370 void filter_write_list(SecureSaveInfo *ssi) |
1 | 371 { |
9 | 372 GList *work; |
373 | |
374 work = filter_list; | |
375 while (work) | |
376 { | |
377 FilterEntry *fe = work->data; | |
378 work = work->next; | |
442 | 379 |
217 | 380 gchar *extensions = escquote_value(fe->extensions); |
381 gchar *description = escquote_value(fe->description); | |
9 | 382 |
370 | 383 secure_fprintf(ssi, "file_filter.ext: \"%s%s\" %s %s %d\n", |
276 | 384 (fe->enabled) ? "" : "#", |
370 | 385 fe->key, extensions, description, fe->file_class); |
217 | 386 g_free(extensions); |
387 g_free(description); | |
9 | 388 } |
1 | 389 } |
390 | |
9 | 391 void filter_parse(const gchar *text) |
1 | 392 { |
9 | 393 const gchar *p; |
394 gchar *key; | |
395 gchar *ext; | |
396 gchar *desc; | |
397 gint enabled = TRUE; | |
370 | 398 gint file_class; |
9 | 399 |
400 if (!text || text[0] != '"') return; | |
401 | |
217 | 402 key = quoted_value(text, &p); |
9 | 403 if (!key) return; |
404 | |
217 | 405 ext = quoted_value(p, &p); |
406 desc = quoted_value(p, &p); | |
442 | 407 |
370 | 408 file_class = strtol(p, NULL, 10); |
442 | 409 |
370 | 410 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) file_class = FORMAT_CLASS_UNKNOWN; |
9 | 411 |
412 if (key && key[0] == '#') | |
413 { | |
414 gchar *tmp; | |
415 tmp = g_strdup(key + 1); | |
416 g_free(key); | |
417 key = tmp; | |
418 | |
419 enabled = FALSE; | |
1 | 420 } |
421 | |
370 | 422 if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, file_class, enabled); |
9 | 423 |
424 g_free(key); | |
425 g_free(ext); | |
426 g_free(desc); | |
427 } | |
1 | 428 |
145
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 *----------------------------------------------------------------------------- |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
431 * sidecar extension list |
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 */ |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
434 |
586 | 435 GList *sidecar_ext_get_list(void) |
145
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 return sidecar_ext_list; |
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 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
440 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
|
441 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
442 GList *work; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
443 gchar *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 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
446 while (work) |
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 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
449 work = work->next; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
450 g_free(ext); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
451 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
452 g_list_free(sidecar_ext_list); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
453 sidecar_ext_list = NULL; |
442 | 454 |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
455 if (quoted) |
217 | 456 value = quoted_value(text, NULL); |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
457 else |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
458 value = g_strdup(text); |
145
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 if (value == NULL) return; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
461 |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
462 sidecar_ext_list = filter_to_list(value); |
442 | 463 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
464 g_free(value); |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
465 } |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
466 |
276 | 467 void sidecar_ext_write(SecureSaveInfo *ssi) |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
468 { |
347 | 469 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
|
470 } |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
471 |
609
b690cecbf5b8
Use function(void) instead of function() for declaring functions which
zas_
parents:
605
diff
changeset
|
472 gchar *sidecar_ext_to_string(void) |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
473 { |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
474 GList *work; |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
475 GString *str = g_string_new(""); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
476 |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
477 work = sidecar_ext_list; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
478 while (work) |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
479 { |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
480 gchar *ext = work->data; |
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
481 work = work->next; |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
482 g_string_append(str, ext); |
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
483 if (work) g_string_append(str, ";"); |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
484 } |
170
9a56e3d13e67
basic sidecar files configuration via preferences dialog
nadvornik
parents:
167
diff
changeset
|
485 return g_string_free(str, FALSE); |
145
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 |
609
b690cecbf5b8
Use function(void) instead of function() for declaring functions which
zas_
parents:
605
diff
changeset
|
488 void sidecar_ext_add_defaults(void) |
145
8be2cc687304
fixed grouping sidecar files and made it configurable via config file
nadvornik
parents:
143
diff
changeset
|
489 { |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
172
diff
changeset
|
490 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
|
491 } |