annotate src/filefilter.c @ 1319:358685fb9dc9

Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
author zas_
date Tue, 24 Feb 2009 21:08:16 +0000
parents c1d108ab3388
children 15208b140481
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 188
diff changeset
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
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1239
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
5 *
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
6 * Author: John Ellis
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
7 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
11 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
12
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
13
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 277
diff changeset
14 #include "main.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 576
diff changeset
15 #include "filefilter.h"
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
16
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
17 #include "cache.h"
1023
650c02c0c8ff Move quoted_value() and escquote_value() to misc.[ch].
zas_
parents: 781
diff changeset
18 #include "misc.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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
21 #include "ui_fileops.h"
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
22 #include "rcfile.h"
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
23
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
24 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
25 *-----------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
26 * file filtering
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
27 *-----------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
28 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
29
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
30 static GList *filter_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
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
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
36 static GList *file_writable_list = NULL; /* writable files */
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
37 static GList *file_sidecar_list = NULL; /* files with allowed sidecar */
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
38
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
39
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
40 gint ishidden(const gchar *name)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
41 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
42 if (name[0] != '.') return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
43 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
44 return TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
45 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
46
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
47 static FilterEntry *filter_entry_new(const gchar *key, const gchar *description,
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
48 const gchar *extensions, FileFormatClass file_class,
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
49 gboolean writable, gboolean allow_sidecar, gboolean enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
50 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
51 FilterEntry *fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
52
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
53 fe = g_new0(FilterEntry, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
54 fe->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
55 fe->description = g_strdup(description);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
56 fe->extensions = g_strdup(extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
57 fe->enabled = enabled;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
58 fe->file_class = file_class;
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
59 fe->writable = writable;
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
60 fe->allow_sidecar = allow_sidecar;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
61
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
62 return fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
63 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
65 static void filter_entry_free(FilterEntry *fe)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
66 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
67 if (!fe) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
68
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
69 g_free(fe->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
70 g_free(fe->description);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
71 g_free(fe->extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
72 g_free(fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
73 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
74
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
75 GList *filter_get_list(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
76 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
77 return filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
78 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
79
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
80 void filter_remove_entry(FilterEntry *fe)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
81 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
82 if (!g_list_find(filter_list, fe)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
83
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
84 filter_list = g_list_remove(filter_list, fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
85 filter_entry_free(fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
86 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
87
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
88 static FilterEntry *filter_get_by_key(const gchar *key)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
89 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
90 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
91
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
92 if (!key) return NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
93
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
94 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
95 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
96 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
97 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
98 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
99
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
100 if (strcmp(fe->key, key) == 0) return fe;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
102
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
103 return NULL;
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
104 }
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
105
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
106 static gint filter_key_exists(const gchar *key)
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
107 {
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
108 return (filter_get_by_key(key) == NULL ? FALSE : TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
109 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
110
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
111 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gboolean writable, gboolean allow_sidecar, gint enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
112 {
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
113 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, file_class, writable, allow_sidecar, enabled));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
114 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
115
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
116 void filter_add_unique(const gchar *description, const gchar *extensions, FileFormatClass file_class, gboolean writable, gboolean allow_sidecar, gint enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
117 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
118 gchar *key;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
119 guint n;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
121 key = g_strdup("user0");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
122 n = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
123 while (filter_key_exists(key))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
124 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
125 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
126 if (n > 999) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
127 key = g_strdup_printf("user%d", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
128 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
129 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
130
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
131 filter_add(key, description, extensions, file_class, writable, allow_sidecar, enabled);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
132 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
133 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
134
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
135 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gboolean writable, gboolean allow_sidecar, gint enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
136 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
137 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
138
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
139 if (!key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
141 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
142 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
143 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
144 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
145 work = work->next;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
146 if (fe->key && strcmp(fe->key, key) == 0)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
147 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
148 if (fe->file_class == FORMAT_CLASS_UNKNOWN)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
149 fe->file_class = file_class; /* for compatibility */
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
150
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
151 if (fe->writable && fe->allow_sidecar)
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
152 {
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
153 fe->writable = writable;
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
154 fe->allow_sidecar = allow_sidecar;
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
155 }
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
156 return;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
157 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
158 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
159
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
160 filter_add(key, description, extensions, file_class, writable, allow_sidecar, enabled);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
161 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
163 void filter_reset(void)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
164 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
165 GList *work;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
167 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
168 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
169 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
170 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
171 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
172 filter_entry_free(fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
173 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
175 g_list_free(filter_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
176 filter_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
177 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
178
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
179 void filter_add_defaults(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
181 GSList *list, *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
183 list = gdk_pixbuf_get_formats();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
184 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
185 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
186 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
187 GdkPixbufFormat *format;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
188 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
189 gchar *desc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
190 gchar **extensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
191 GString *filter = NULL;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
192 guint i;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
193
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
194 format = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
195 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
197 name = gdk_pixbuf_format_get_name(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
198 desc = gdk_pixbuf_format_get_description(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
199 extensions = gdk_pixbuf_format_get_extensions(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
201 i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
202 while (extensions[i])
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
203 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
204 if (!filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
205 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
206 filter = g_string_new(".");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
207 filter = g_string_append(filter, extensions[i]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
208 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
209 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
211 filter = g_string_append(filter, ";.");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
212 filter = g_string_append(filter, extensions[i]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
213 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
214 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
215 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
216
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
217 DEBUG_1("loader reported [%s] [%s] [%s]", name, desc, filter->str);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
218
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
219 filter_add_if_missing(name, desc, filter->str, FORMAT_CLASS_IMAGE, TRUE, FALSE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
221 g_free(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
222 g_free(desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
223 g_strfreev(extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
224 g_string_free(filter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
225 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
226 g_slist_free(list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
227
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
228 /* add defaults even if gdk-pixbuf does not have them, but disabled */
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
229 filter_add_if_missing("jpeg", "JPEG group", ".jpg;.jpeg;.jpe", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
230 filter_add_if_missing("png", "Portable Network Graphic", ".png", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
231 filter_add_if_missing("tiff", "Tiff", ".tif;.tiff", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
232 filter_add_if_missing("pnm", "Packed Pixel formats", ".pbm;.pgm;.pnm;.ppm", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
233 filter_add_if_missing("gif", "Graphics Interchange Format", ".gif", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
234 filter_add_if_missing("xbm", "X bitmap", ".xbm", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
235 filter_add_if_missing("xpm", "X pixmap", ".xpm", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
236 filter_add_if_missing("bmp", "Bitmap", ".bmp", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
237 filter_add_if_missing("ico", "Icon file", ".ico;.cur", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
238 filter_add_if_missing("ras", "Raster", ".ras", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
239 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, TRUE, FALSE, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
240
202
f95654aeec4b added all possible raw extensions that I could find
nadvornik
parents: 196
diff changeset
241 /* non-image files that might be desirable to show */
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
242 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE, FALSE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
243 filter_add_if_missing("gqv", GQ_APPNAME " image collection", GQ_COLLECTION_EXT, FORMAT_CLASS_META, FALSE, FALSE, TRUE);
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
244
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
245 /* 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
246 * (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
247 */
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
248 filter_add_if_missing("arw", "Sony raw format", ".arw;.srf;.sr2", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
249 filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
250 filter_add_if_missing("kdc", "Kodak raw format", ".kdc;.dcr;.k25", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
251 filter_add_if_missing("raf", "Fujifilm raw format", ".raf", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
252 filter_add_if_missing("mef", "Mamiya raw format", ".mef;.mos", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
253 filter_add_if_missing("mrw", "Minolta raw format", ".mrw", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
254 filter_add_if_missing("nef", "Nikon raw format", ".nef", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
255 filter_add_if_missing("orf", "Olympus raw format", ".orf", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
256 filter_add_if_missing("pef", "Pentax or Samsung raw format", ".pef;.ptx", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
257 filter_add_if_missing("dng", "Adobe Digital Negative raw format", ".dng", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
258 filter_add_if_missing("x3f", "Sigma raw format", ".x3f", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
259 filter_add_if_missing("raw", "Panasonic raw format", ".raw", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
260 filter_add_if_missing("r3d", "Red raw format", ".r3d", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
261 filter_add_if_missing("3fr", "Hasselblad raw format", ".3fr", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
262 filter_add_if_missing("erf", "Epson raw format", ".erf", FORMAT_CLASS_RAWIMAGE, FALSE, TRUE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
263 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
264
147
b2266996fa83 added possibility to specify prefered file type for external commands
nadvornik
parents: 146
diff changeset
265 GList *filter_to_list(const gchar *extensions)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
266 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
267 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
268 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
270 if (!extensions) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
271
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
272 p = extensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
273 while (*p != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
274 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
275 const gchar *b;
1235
052f26dbe8cf Silent warnings.
zas_
parents: 1229
diff changeset
276 gchar *ext;
1229
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
277 gint file_class = -1;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
278 guint l = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
279
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
280 b = p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
281 while (*p != '\0' && *p != ';')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
282 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
283 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
284 l++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
285 }
1229
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
286
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
287 ext = g_strndup(b, l);
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
288
1307
e8f21b91885d Glibification again.
zas_
parents: 1284
diff changeset
289 if (g_ascii_strcasecmp(ext, "%image") == 0) file_class = FORMAT_CLASS_IMAGE;
e8f21b91885d Glibification again.
zas_
parents: 1284
diff changeset
290 else if (g_ascii_strcasecmp(ext, "%raw") == 0) file_class = FORMAT_CLASS_RAWIMAGE;
e8f21b91885d Glibification again.
zas_
parents: 1284
diff changeset
291 else if (g_ascii_strcasecmp(ext, "%meta") == 0) file_class = FORMAT_CLASS_META;
1229
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
292
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
293 if (file_class == -1)
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
294 {
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
295 list = g_list_append(list, ext);
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
296 }
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
297 else
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
298 {
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
299 list = g_list_concat(list, string_list_copy(file_class_extension_list[file_class]));
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
300 g_free(ext);
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
301 }
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
302
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
303 if (*p == ';') p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
306 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
307 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
309 void filter_rebuild(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
311 GList *work;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
312 guint i;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
313
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
314 string_list_free(extension_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
315 extension_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
316
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
317 string_list_free(file_writable_list);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
318 file_writable_list = NULL;
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
319
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
320 string_list_free(file_sidecar_list);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
321 file_sidecar_list = NULL;
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
322
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
323 for (i = 0; i < FILE_FORMAT_CLASSES; i++)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
324 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
325 string_list_free(file_class_extension_list[i]);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
326 file_class_extension_list[i] = NULL;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
327 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
328
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
329 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
330 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
331 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
332 FilterEntry *fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
333
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
334 fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
335 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
336
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
337 if (fe->enabled)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
338 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
339 GList *ext;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
340
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
341 ext = filter_to_list(fe->extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
342 if (ext) extension_list = g_list_concat(extension_list, ext);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
343
1177
5a20c47e7a14 Fix up unsigned expression always true/false warnings.
zas_
parents: 1055
diff changeset
344 if (fe->file_class < FILE_FORMAT_CLASSES)
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 ext = filter_to_list(fe->extensions);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
347 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
348 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
349 else
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
350 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
351 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
352 }
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
353
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
354 if (fe->writable)
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
355 {
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
356 ext = filter_to_list(fe->extensions);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
357 if (ext) file_writable_list = g_list_concat(file_writable_list, ext);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
358 }
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
359
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
360 if (fe->allow_sidecar)
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
361 {
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
362 ext = filter_to_list(fe->extensions);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
363 if (ext) file_sidecar_list = g_list_concat(file_sidecar_list, ext);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
364 }
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
365
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
366 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
367 }
1229
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
368
878718372aca sidecar files grouping was made case-insensitive
nadvornik
parents: 1207
diff changeset
369 sidecar_ext_parse(options->sidecar.ext, FALSE); /* this must be updated after changed file extensions */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
370 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
371
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
372 static gboolean filter_name_find(GList *filter, const gchar *name)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
374 GList *work;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
375 guint ln;
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
376
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
377 ln = strlen(name);
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
378 work = filter;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
379 while (work)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
380 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
381 gchar *filter = work->data;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
382 guint lf = strlen(filter);
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
383
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
384 if (ln >= lf)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
385 {
605
651ae2be1031 Use g_ascii_strncasecmp() instead of strncasecmp() where applicable.
zas_
parents: 587
diff changeset
386 /* FIXME: utf8 */
1307
e8f21b91885d Glibification again.
zas_
parents: 1284
diff changeset
387 if (g_ascii_strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
388 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
389 work = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
390 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
391
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
392 return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
393 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
394
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
395
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
396 gboolean filter_name_exists(const gchar *name)
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
397 {
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
398 if (!extension_list || options->file_filter.disable) return TRUE;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
399
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
400 return filter_name_find(extension_list, name);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
401 }
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
402
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
403 gboolean filter_file_class(const gchar *name, FileFormatClass file_class)
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
404 {
1177
5a20c47e7a14 Fix up unsigned expression always true/false warnings.
zas_
parents: 1055
diff changeset
405 if (file_class >= FILE_FORMAT_CLASSES)
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
406 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
407 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
408 return FALSE;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
409 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
410
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
411 return filter_name_find(file_class_extension_list[file_class], name);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
412 }
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
413
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
414 gboolean filter_name_is_writable(const gchar *name)
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
415 {
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
416 return filter_name_find(file_writable_list, name);
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
417 }
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
418
1239
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
419 gboolean filter_name_allow_sidecar(const gchar *name)
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
420 {
254b09942e68 metadata write mode (direct or sidecar) made configurable for each file
nadvornik
parents: 1235
diff changeset
421 return filter_name_find(file_sidecar_list, name);
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
422 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
423
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
424 void filter_write_list(GString *outstr, gint indent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
425 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
426 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
427
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
428 WRITE_STRING("<filter>\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
429 indent++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
430
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
431 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
432 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
433 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
434 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
435 work = work->next;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
436
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
437 WRITE_STRING("<file_type\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
438 indent++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
439 WRITE_CHAR(*fe, key);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
440 WRITE_BOOL(*fe, enabled);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
441 WRITE_CHAR(*fe, extensions);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
442 WRITE_CHAR(*fe, description);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
443 WRITE_UINT(*fe, file_class);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
444 WRITE_BOOL(*fe, writable);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
445 WRITE_BOOL(*fe, allow_sidecar);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
446 indent--;
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
447 WRITE_STRING("/>\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
448 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
449 indent--;
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
450 WRITE_STRING("</filter>\n");
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
451 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
452
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
453 void filter_load_file_type(const gchar **attribute_names, const gchar **attribute_values)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
454 {
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
455 FilterEntry fe;
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
456 FilterEntry *old_fe;
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
457 memset(&fe, 0, sizeof(fe));
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
458 while (*attribute_names)
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
459 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
460 const gchar *option = *attribute_names++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
461 const gchar *value = *attribute_values++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
462
1315
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
463 if (READ_CHAR(fe, key)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
464 if (READ_BOOL(fe, enabled)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
465 if (READ_CHAR(fe, extensions)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
466 if (READ_CHAR(fe, description)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
467 if (READ_UINT(fe, file_class)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
468 if (READ_BOOL(fe, writable)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
469 if (READ_BOOL(fe, allow_sidecar)) continue;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
470
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
471 printf("unknown attribute %s = %s\n", option, value);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
472 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
473 if (fe.file_class >= FILE_FORMAT_CLASSES) fe.file_class = FORMAT_CLASS_UNKNOWN;
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
474
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
475 if (fe.key && fe.key[0] != 0)
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
476 {
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
477 old_fe = filter_get_by_key(fe.key);
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
478
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
479 if (old_fe != NULL) filter_remove_entry(old_fe);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
480 filter_add(fe.key, fe.description, fe.extensions, fe.file_class, fe.writable, fe.allow_sidecar, fe.enabled);
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
481 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
482 g_free(fe.key);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
483 g_free(fe.extensions);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
484 g_free(fe.description);
55ea4962887a config file format changed to XML
nadvornik
parents: 1307
diff changeset
485 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
486
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
487
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
488 /*
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
489 *-----------------------------------------------------------------------------
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
490 * sidecar extension list
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
491 *-----------------------------------------------------------------------------
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
492 */
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
493
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 576
diff changeset
494 GList *sidecar_ext_get_list(void)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
495 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
496 return sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
497 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
498
1190
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
499 static void sidecar_ext_free_list(void)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
500 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
501 GList *work;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
502
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
503 work = sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
504 while (work)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
505 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
506 gchar *ext = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
507 work = work->next;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
508 g_free(ext);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
509 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
510 g_list_free(sidecar_ext_list);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
511 sidecar_ext_list = NULL;
1190
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
512 }
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
513
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
514 void sidecar_ext_parse(const gchar *text, gboolean quoted)
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
515 {
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
516 gchar *value;
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
517
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
518 sidecar_ext_free_list();
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
519
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
520 if (quoted)
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
521 value = quoted_value(text, NULL);
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
522 else
1207
4742b47b75d1 Fix two minor compilation warnings.
zas_
parents: 1190
diff changeset
523 value = (gchar *) text;
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
524
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
525 if (value == NULL) return;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
526
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
527 sidecar_ext_list = filter_to_list(value);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
528
1190
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
529 if (quoted) g_free(value);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
530 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
531
1190
a4ea0c74a6e2 File filters cleanup: add .pef .dng and .arw extensions to default sidecar extensions list, add .k25 in Kodak raw extensions, simplify and optimize sidecar_ext_parse().
zas_
parents: 1177
diff changeset
532
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1023
diff changeset
533 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */