annotate src/filefilter.c @ 1223:18d08b10b80e

implemented a possibility to connect keywords with marks
author nadvornik
date Thu, 25 Dec 2008 12:39:34 +0000
parents 4742b47b75d1
children 878718372aca
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
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 442
diff changeset
4 * Copyright (C) 2008 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"
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
22
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
23 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
24 *-----------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
25 * file filtering
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
26 *-----------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
27 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
28
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
29 static GList *filter_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
30 static GList *extension_list = NULL;
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
31 static GList *sidecar_ext_list = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
32
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
33 static GList *file_class_extension_list[FILE_FORMAT_CLASSES];
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
34
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
35
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
36 gint ishidden(const gchar *name)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
37 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
38 if (name[0] != '.') return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
39 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
40 return TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
41 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
42
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
43 static FilterEntry *filter_entry_new(const gchar *key, const gchar *description,
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
44 const gchar *extensions, FileFormatClass file_class, gboolean enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
45 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
46 FilterEntry *fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
48 fe = g_new0(FilterEntry, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
49 fe->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
50 fe->description = g_strdup(description);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
51 fe->extensions = g_strdup(extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
52 fe->enabled = enabled;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
53 fe->file_class = file_class;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
54
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
55 return fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
56 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
58 static void filter_entry_free(FilterEntry *fe)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
59 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
60 if (!fe) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
61
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
62 g_free(fe->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
63 g_free(fe->description);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
64 g_free(fe->extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
65 g_free(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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
68 GList *filter_get_list(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
69 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
70 return filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
71 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
73 void filter_remove_entry(FilterEntry *fe)
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 if (!g_list_find(filter_list, fe)) return;
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 filter_list = g_list_remove(filter_list, fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
78 filter_entry_free(fe);
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
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
81 static FilterEntry *filter_get_by_key(const gchar *key)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
82 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
83 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
84
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
85 if (!key) return NULL;
9
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 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
88 while (work)
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 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
91 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
92
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
93 if (strcmp(fe->key, key) == 0) return fe;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
94 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
95
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
96 return NULL;
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
97 }
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
98
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
99 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
100 {
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
101 return (filter_get_by_key(key) == NULL ? FALSE : TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
102 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
103
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
104 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
105 {
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
106 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, file_class, enabled));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
107 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
108
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
109 void filter_add_unique(const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
110 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
111 gchar *key;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
112 guint n;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
114 key = g_strdup("user0");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
115 n = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
116 while (filter_key_exists(key))
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 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
119 if (n > 999) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
120 key = g_strdup_printf("user%d", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
121 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
122 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
123
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
124 filter_add(key, description, extensions, file_class, enabled);
9
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
127
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
128 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled)
9
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
132 if (!key) return;
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 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
135 while (work)
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 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
138 work = work->next;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
139 if (fe->key && strcmp(fe->key, key) == 0)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
140 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
141 if (fe->file_class == FORMAT_CLASS_UNKNOWN)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
142 fe->file_class = file_class; /* for compatibility */
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
143 return;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
144 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
146
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
147 filter_add(key, description, extensions, file_class, enabled);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
148 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
149
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
150 void filter_reset(void)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
151 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
152 GList *work;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
154 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
155 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
156 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
157 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
158 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
159 filter_entry_free(fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
160 }
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 g_list_free(filter_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
163 filter_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
164 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
166 void filter_add_defaults(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
167 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
168 GSList *list, *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 list = gdk_pixbuf_get_formats();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
171 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
172 while (work)
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 GdkPixbufFormat *format;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
175 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
176 gchar *desc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
177 gchar **extensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
178 GString *filter = NULL;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
179 guint i;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
180
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
181 format = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
182 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
184 name = gdk_pixbuf_format_get_name(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
185 desc = gdk_pixbuf_format_get_description(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
186 extensions = gdk_pixbuf_format_get_extensions(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
188 i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
189 while (extensions[i])
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
190 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
191 if (!filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
192 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
193 filter = g_string_new(".");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
194 filter = g_string_append(filter, extensions[i]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
195 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
196 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
197 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
198 filter = g_string_append(filter, ";.");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
199 filter = g_string_append(filter, extensions[i]);
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++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
202 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
203
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
204 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
205
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
206 filter_add_if_missing(name, desc, filter->str, FORMAT_CLASS_IMAGE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
208 g_free(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
209 g_free(desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
210 g_strfreev(extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
211 g_string_free(filter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
212 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
213 g_slist_free(list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
214
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
215 /* 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
227
202
f95654aeec4b added all possible raw extensions that I could find
nadvornik
parents: 196
diff changeset
228 /* non-image files that might be desirable to show */
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
229 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE);
781
2d2cca2bceb0 Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
zas_
parents: 743
diff changeset
230 filter_add_if_missing("gqv", GQ_APPNAME " image collection", GQ_COLLECTION_EXT, FORMAT_CLASS_META, TRUE);
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
231
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
232 /* 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
233 * (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
234 */
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
235 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
236 filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", FORMAT_CLASS_RAWIMAGE, TRUE);
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
237 filter_add_if_missing("kdc", "Kodak raw format", ".kdc;.dcr;.k25", FORMAT_CLASS_RAWIMAGE, TRUE);
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
238 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
239 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
240 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
241 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
242 filter_add_if_missing("orf", "Olympus raw format", ".orf", FORMAT_CLASS_RAWIMAGE, TRUE);
277
9de0f88b2b91 Add support for some Samsung raw files (.pef).
zas_
parents: 276
diff changeset
243 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
244 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
245 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
246 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
247 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
248 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
249 filter_add_if_missing("erf", "Epson raw format", ".erf", FORMAT_CLASS_RAWIMAGE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
250 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
251
147
b2266996fa83 added possibility to specify prefered file type for external commands
nadvornik
parents: 146
diff changeset
252 GList *filter_to_list(const gchar *extensions)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
253 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
254 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
255 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
257 if (!extensions) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
259 p = extensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
260 while (*p != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
261 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
262 const gchar *b;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
263 guint l = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
264
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
265 b = p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
266 while (*p != '\0' && *p != ';')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
267 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
268 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
269 l++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
270 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
271 list = g_list_append(list, g_strndup(b, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
272 if (*p == ';') p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
273 }
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 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
276 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
278 void filter_rebuild(void)
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 GList *work;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
281 guint i;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
282
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
283 string_list_free(extension_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
284 extension_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
285
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
286 for (i = 0; i < FILE_FORMAT_CLASSES; i++)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
287 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
288 string_list_free(file_class_extension_list[i]);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
289 file_class_extension_list[i] = NULL;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
290 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
291
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
292 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
293 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
294 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
295 FilterEntry *fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
297 fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
298 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
299
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
300 if (fe->enabled)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
302 GList *ext;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
303
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
304 ext = filter_to_list(fe->extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
305 if (ext) extension_list = g_list_concat(extension_list, ext);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
306
1177
5a20c47e7a14 Fix up unsigned expression always true/false warnings.
zas_
parents: 1055
diff changeset
307 if (fe->file_class < FILE_FORMAT_CLASSES)
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
308 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
309 ext = filter_to_list(fe->extensions);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
310 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
311 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
312 else
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
313 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
314 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
315 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
316 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
318 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
320 gint filter_name_exists(const gchar *name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
321 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
322 GList *work;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
323 guint ln;
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
324
332
3c4bad726e98 Rename file filtering options.
zas_
parents: 318
diff changeset
325 if (!extension_list || options->file_filter.disable) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
326
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
327 ln = strlen(name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
328 work = extension_list;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
329 while (work)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
330 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
331 gchar *filter = work->data;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
332 guint lf = strlen(filter);
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
333
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
334 if (ln >= lf)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
335 {
605
651ae2be1031 Use g_ascii_strncasecmp() instead of strncasecmp() where applicable.
zas_
parents: 587
diff changeset
336 /* FIXME: utf8 */
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
337 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
338 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
339 work = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
340 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
341
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
342 return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
343 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
344
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
345 gint filter_file_class(const gchar *name, FileFormatClass file_class)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
346 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
347 GList *work;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
348 guint ln;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
349
1177
5a20c47e7a14 Fix up unsigned expression always true/false warnings.
zas_
parents: 1055
diff changeset
350 if (file_class >= FILE_FORMAT_CLASSES)
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
351 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
352 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
353 return FALSE;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
354 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
355
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
356 ln = strlen(name);
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
357 work = file_class_extension_list[file_class];
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
358 while (work)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
359 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
360 gchar *filter = work->data;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
361 guint lf = strlen(filter);
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
362
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
363 if (ln >= lf)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
364 {
605
651ae2be1031 Use g_ascii_strncasecmp() instead of strncasecmp() where applicable.
zas_
parents: 587
diff changeset
365 /* FIXME: utf8 */
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
366 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
367 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
368 work = work->next;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
369 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
370
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
371 return FALSE;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
372 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
373
276
4f526d436873 Implement secure rc file saving.
zas_
parents: 248
diff changeset
374 void filter_write_list(SecureSaveInfo *ssi)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
375 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
376 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
378 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
379 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
380 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
381 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
382 work = work->next;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
383
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
384 gchar *extensions = escquote_value(fe->extensions);
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
385 gchar *description = escquote_value(fe->description);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
386
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
387 secure_fprintf(ssi, "file_filter.ext: \"%s%s\" %s %s %d\n",
276
4f526d436873 Implement secure rc file saving.
zas_
parents: 248
diff changeset
388 (fe->enabled) ? "" : "#",
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
389 fe->key, extensions, description, fe->file_class);
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
390 g_free(extensions);
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
391 g_free(description);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
392 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
393 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
394
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
395 void filter_parse(const gchar *text)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
396 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
397 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
398 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
399 gchar *ext;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
400 gchar *desc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
401 gint enabled = TRUE;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
402 guint file_class;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
403
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
404 if (!text || text[0] != '"') return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
405
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
406 key = quoted_value(text, &p);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
407 if (!key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
408
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
409 ext = quoted_value(p, &p);
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
410 desc = quoted_value(p, &p);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
411
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
412 file_class = strtoul(p, NULL, 10);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
413
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 673
diff changeset
414 if (file_class >= FILE_FORMAT_CLASSES) file_class = FORMAT_CLASS_UNKNOWN;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
416 if (key && key[0] == '#')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
417 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
418 gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
419 tmp = g_strdup(key + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
420 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
421 key = tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
422
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
423 enabled = FALSE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
424 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
425
743
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
426 if (key && strlen(key) > 0 && ext)
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
427 {
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
428 FilterEntry *fe = filter_get_by_key(key);
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
429
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
430 if (fe != NULL) filter_remove_entry(fe);
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
431 filter_add(key, desc, ext, file_class, enabled);
77ff94c0490a Try to load a system-wide rc file if any, before per-user rc file.
zas_
parents: 736
diff changeset
432 }
9
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 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
435 g_free(ext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
436 g_free(desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
437 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
438
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
439 /*
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
440 *-----------------------------------------------------------------------------
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
441 * sidecar extension list
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
442 *-----------------------------------------------------------------------------
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
443 */
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
444
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 576
diff changeset
445 GList *sidecar_ext_get_list(void)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
446 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
447 return sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
448 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
449
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
450 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
451 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
452 GList *work;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
453
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
454 work = sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
455 while (work)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
456 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
457 gchar *ext = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
458 work = work->next;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
459 g_free(ext);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
460 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
461 g_list_free(sidecar_ext_list);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
462 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
463 }
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
464
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
465 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
466 {
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
467 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
468
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
469 sidecar_ext_free_list();
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
470
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
471 if (quoted)
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
472 value = quoted_value(text, NULL);
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
473 else
1207
4742b47b75d1 Fix two minor compilation warnings.
zas_
parents: 1190
diff changeset
474 value = (gchar *) text;
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
475
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
476 if (value == NULL) return;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
477
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
478 sidecar_ext_list = filter_to_list(value);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
479
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
480 if (quoted) g_free(value);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
481 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
482
276
4f526d436873 Implement secure rc file saving.
zas_
parents: 248
diff changeset
483 void sidecar_ext_write(SecureSaveInfo *ssi)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
484 {
347
6dc0eaa0fcea sidecar_ext -> sidecar.ext
zas_
parents: 332
diff changeset
485 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
486 }
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
487
609
b690cecbf5b8 Use function(void) instead of function() for declaring functions which
zas_
parents: 605
diff changeset
488 gchar *sidecar_ext_to_string(void)
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
489 {
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
490 GList *work;
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
491 GString *str = g_string_new("");
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
492
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
493 work = sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
494 while (work)
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 gchar *ext = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
497 work = work->next;
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
498 g_string_append(str, ext);
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
499 if (work) g_string_append(str, ";");
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
500 }
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
501 return g_string_free(str, FALSE);
145
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
609
b690cecbf5b8 Use function(void) instead of function() for declaring functions which
zas_
parents: 605
diff changeset
504 void sidecar_ext_add_defaults(void)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
505 {
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
506 sidecar_ext_parse(".jpg;.cr2;.nef;.crw;.pef;.dng;.arw;.xmp", FALSE);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
507 }
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
508
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1023
diff changeset
509 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */