annotate src/filelist.c @ 442:4b2d7f9af171

Big whitespaces cleanup: - drop whitespaces at end of lines - convert eight spaces to tab at start of lines - drop spurious spaces mixed with tabs - remove empty lines at end of files
author zas_
date Sun, 20 Apr 2008 13:04:57 +0000
parents 10efd67e5d3c
children 48c8e49b571c
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
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
4 *
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
5 * Author: John Ellis
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
6 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
7 * 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
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
10 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
11
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 277
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
14 #include "filelist.h"
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
15
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
16 #include "cache.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
17 #include "rcfile.h"
307
667e49f52168 Move secure save code to its own files: secure_save.{c,h}.
zas_
parents: 283
diff changeset
18 #include "secure_save.h"
79
528e3432e0c0 Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
19 #include "thumb_standard.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
20 #include "ui_fileops.h"
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
21
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
240
cce347409480 Fix two more gcc warnings related to function declarations.
zas_
parents: 217
diff changeset
35 static gint sidecar_file_priority(const gchar *path);
cce347409480 Fix two more gcc warnings related to function declarations.
zas_
parents: 217
diff changeset
36
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
37
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
38 gint ishidden(const gchar *name)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
39 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
40 if (name[0] != '.') return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
41 if (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
42 return TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
43 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
44
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
45 static FilterEntry *filter_entry_new(const gchar *key, const gchar *description,
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
46 const gchar *extensions, FileFormatClass file_class, gint enabled)
9
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 FilterEntry *fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
49
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
50 fe = g_new0(FilterEntry, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
51 fe->key = g_strdup(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
52 fe->description = g_strdup(description);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
53 fe->extensions = g_strdup(extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
54 fe->enabled = enabled;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
55 fe->file_class = file_class;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
56
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
57 return fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
58 }
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 static void filter_entry_free(FilterEntry *fe)
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 if (!fe) return;
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 g_free(fe->key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
65 g_free(fe->description);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
66 g_free(fe->extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
67 g_free(fe);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
70 GList *filter_get_list(void)
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 return filter_list;
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 void filter_remove_entry(FilterEntry *fe)
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 if (!g_list_find(filter_list, fe)) return;
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 filter_list = g_list_remove(filter_list, fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
80 filter_entry_free(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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
83 static gint filter_key_exists(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
84 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
85 GList *work;
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 if (!key) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
88
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
89 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
90 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
92 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
93 work = work->next;
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 if (strcmp(fe->key, key) == 0) return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
98 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
99 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
100
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
101 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
102 {
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
103 filter_list = g_list_append(filter_list, filter_entry_new(key, description, extensions, file_class, enabled));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
104 }
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 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
107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
108 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
109 gint n;
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 key = g_strdup("user0");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
112 n = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
113 while (filter_key_exists(key))
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 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
116 if (n > 999) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
117 key = g_strdup_printf("user%d", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
118 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
119 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
120
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
121 filter_add(key, description, extensions, file_class, enabled);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
122 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
123 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
124
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
125 static void filter_add_if_missing(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled)
9
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
129 if (!key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
131 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
132 while (work)
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 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
135 work = work->next;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
136 if (fe->key && strcmp(fe->key, key) == 0)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
137 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
138 if (fe->file_class == FORMAT_CLASS_UNKNOWN)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
139 fe->file_class = file_class; /* for compatibility */
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
140 return;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
141 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
143
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
144 filter_add(key, description, extensions, file_class, enabled);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
147 void filter_reset(void)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
148 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
149 GList *work;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
151 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
152 while (work)
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 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
155 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
156 filter_entry_free(fe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
157 }
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 g_list_free(filter_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
160 filter_list = NULL;
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_add_defaults(void)
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 GSList *list, *work;
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 list = gdk_pixbuf_get_formats();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
168 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
169 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
170 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
171 GdkPixbufFormat *format;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
172 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
173 gchar *desc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
174 gchar **extensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
175 GString *filter = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
176 gint i;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
177
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
178 format = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
179 work = work->next;
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 name = gdk_pixbuf_format_get_name(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
182 desc = gdk_pixbuf_format_get_description(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
183 extensions = gdk_pixbuf_format_get_extensions(format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
185 i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
186 while (extensions[i])
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 if (!filter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
189 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
190 filter = g_string_new(".");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
191 filter = g_string_append(filter, extensions[i]);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
194 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
195 filter = g_string_append(filter, ";.");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
196 filter = g_string_append(filter, extensions[i]);
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 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
199 }
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 if (debug) printf("loader reported [%s] [%s] [%s]\n", name, desc, filter->str);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
202
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
203 filter_add_if_missing(name, desc, filter->str, FORMAT_CLASS_IMAGE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
205 g_free(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
206 g_free(desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
207 g_strfreev(extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
208 g_string_free(filter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
209 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
210 g_slist_free(list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
211
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
212 /* add defaults even if gdk-pixbuf does not have them, but disabled */
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
213 filter_add_if_missing("jpeg", "JPEG group", ".jpg;.jpeg;.jpe", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
214 filter_add_if_missing("png", "Portable Network Graphic", ".png", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
215 filter_add_if_missing("tiff", "Tiff", ".tif;.tiff", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
216 filter_add_if_missing("pnm", "Packed Pixel formats", ".pbm;.pgm;.pnm;.ppm", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
217 filter_add_if_missing("gif", "Graphics Interchange Format", ".gif", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
218 filter_add_if_missing("xbm", "X bitmap", ".xbm", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
219 filter_add_if_missing("xpm", "X pixmap", ".xpm", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
220 filter_add_if_missing("bmp", "Bitmap", ".bmp", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
221 filter_add_if_missing("ico", "Icon file", ".ico;.cur", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
222 filter_add_if_missing("ras", "Raster", ".ras", FORMAT_CLASS_IMAGE, FALSE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
223 filter_add_if_missing("svg", "Scalable Vector Graphics", ".svg", FORMAT_CLASS_IMAGE, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
224
202
f95654aeec4b added all possible raw extensions that I could find
nadvornik
parents: 196
diff changeset
225 /* non-image files that might be desirable to show */
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
226 filter_add_if_missing("xmp", "XMP sidecar", ".xmp", FORMAT_CLASS_META, TRUE);
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
227
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
228 /* These are the raw camera formats with embedded jpeg/exif.
202
f95654aeec4b added all possible raw extensions that I could find
nadvornik
parents: 196
diff changeset
229 * (see format_raw.c and/or exiv2.cc)
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
230 */
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
231 filter_add_if_missing("arw", "Sony raw format", ".arw;.srf;.sr2", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
232 filter_add_if_missing("crw", "Canon raw format", ".crw;.cr2", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
233 filter_add_if_missing("kdc", "Kodak raw format", ".kdc;.dcr", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
234 filter_add_if_missing("raf", "Fujifilm raw format", ".raf", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
235 filter_add_if_missing("mef", "Mamiya raw format", ".mef;.mos", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
236 filter_add_if_missing("mrw", "Minolta raw format", ".mrw", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
237 filter_add_if_missing("nef", "Nikon raw format", ".nef", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
238 filter_add_if_missing("orf", "Olympus raw format", ".orf", FORMAT_CLASS_RAWIMAGE, TRUE);
277
9de0f88b2b91 Add support for some Samsung raw files (.pef).
zas_
parents: 276
diff changeset
239 filter_add_if_missing("pef", "Pentax or Samsung raw format", ".pef;.ptx", FORMAT_CLASS_RAWIMAGE, TRUE);
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
240 filter_add_if_missing("dng", "Adobe Digital Negative raw format", ".dng", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
241 filter_add_if_missing("x3f", "Sigma raw format", ".x3f", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
242 filter_add_if_missing("raw", "Panasonic raw format", ".raw", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
243 filter_add_if_missing("r3d", "Red raw format", ".r3d", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
244 filter_add_if_missing("3fr", "Hasselblad raw format", ".3fr", FORMAT_CLASS_RAWIMAGE, TRUE);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
245 filter_add_if_missing("erf", "Epson raw format", ".erf", FORMAT_CLASS_RAWIMAGE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
246 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
247
147
b2266996fa83 added possibility to specify prefered file type for external commands
nadvornik
parents: 146
diff changeset
248 GList *filter_to_list(const gchar *extensions)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
249 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
250 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
251 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
253 if (!extensions) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
255 p = extensions;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
256 while (*p != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
257 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
258 const gchar *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
259 gint l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
261 b = p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
262 while (*p != '\0' && *p != ';')
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 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
265 l++;
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 list = g_list_append(list, g_strndup(b, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
268 if (*p == ';') 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
271 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
272 }
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 void filter_rebuild(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
275 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
276 GList *work;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
277 gint i;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
278
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
279 string_list_free(extension_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
280 extension_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
281
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
282 for (i = 0; i < FILE_FORMAT_CLASSES; i++)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
283 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
284 string_list_free(file_class_extension_list[i]);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
285 file_class_extension_list[i] = NULL;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
286 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
287
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
288 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
289 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
290 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
291 FilterEntry *fe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
292
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
293 fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
294 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
295
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
296 if (fe->enabled)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
297 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
298 GList *ext;
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 ext = filter_to_list(fe->extensions);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
301 if (ext) extension_list = g_list_concat(extension_list, ext);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
302
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
303 if (fe->file_class >= 0 && fe->file_class < FILE_FORMAT_CLASSES)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
304 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
305 ext = filter_to_list(fe->extensions);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
306 if (ext) file_class_extension_list[fe->file_class] = g_list_concat(file_class_extension_list[fe->file_class], ext);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
307 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
308 else
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
309 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
310 printf("WARNING: invalid file class %d\n", fe->file_class);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
311 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
312 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
313 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
314 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
316 gint filter_name_exists(const gchar *name)
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 GList *work;
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
319 gint ln;
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
320
332
3c4bad726e98 Rename file filtering options.
zas_
parents: 318
diff changeset
321 if (!extension_list || options->file_filter.disable) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
322
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
323 ln = strlen(name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
324 work = extension_list;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
325 while (work)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
326 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
327 gchar *filter = work->data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
328 gint lf = strlen(filter);
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
329
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
330 if (ln >= lf)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
331 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
332 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
333 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
334 work = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
335 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
336
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
337 return FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
338 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
339
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
340 gint filter_file_class(const gchar *name, FileFormatClass file_class)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
341 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
342 GList *work;
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
343 gint ln;
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
344
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
345 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
346 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
347 printf("WARNING: invalid file class %d\n", file_class);
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
348 return FALSE;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
349 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
350
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
351 ln = strlen(name);
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
352 work = file_class_extension_list[file_class];
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
353 while (work)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
354 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
355 gchar *filter = work->data;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
356 gint lf = strlen(filter);
215
f2b439c7f973 Move strlen() calls outside the while loop.
zas_
parents: 212
diff changeset
357
212
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
358 if (ln >= lf)
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
359 {
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
360 if (strncasecmp(name + ln - lf, filter, lf) == 0) return TRUE;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
361 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
362 work = work->next;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
363 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
364
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
365 return FALSE;
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
366 }
c7021159079d differentiate among normal image, raw image and metadata
nadvornik
parents: 202
diff changeset
367
276
4f526d436873 Implement secure rc file saving.
zas_
parents: 248
diff changeset
368 void filter_write_list(SecureSaveInfo *ssi)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
369 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
370 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
372 work = filter_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
373 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
374 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
375 FilterEntry *fe = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
376 work = work->next;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
377
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
378 gchar *extensions = escquote_value(fe->extensions);
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
379 gchar *description = escquote_value(fe->description);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
380
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
381 secure_fprintf(ssi, "file_filter.ext: \"%s%s\" %s %s %d\n",
276
4f526d436873 Implement secure rc file saving.
zas_
parents: 248
diff changeset
382 (fe->enabled) ? "" : "#",
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
383 fe->key, extensions, description, fe->file_class);
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
384 g_free(extensions);
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
385 g_free(description);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
386 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
387 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
388
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
389 void filter_parse(const gchar *text)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
390 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
391 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
392 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
393 gchar *ext;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
394 gchar *desc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
395 gint enabled = TRUE;
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
396 gint file_class;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
397
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
398 if (!text || text[0] != '"') return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
399
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
400 key = quoted_value(text, &p);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
401 if (!key) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
402
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
403 ext = quoted_value(p, &p);
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
404 desc = quoted_value(p, &p);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
405
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
406 file_class = strtol(p, NULL, 10);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
407
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
408 if (file_class < 0 || file_class >= FILE_FORMAT_CLASSES) file_class = FORMAT_CLASS_UNKNOWN;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
409
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
410 if (key && key[0] == '#')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
411 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
412 gchar *tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
413 tmp = g_strdup(key + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
414 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
415 key = tmp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
417 enabled = FALSE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
418 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
419
370
1eaea84877ce save file_class to config file
nadvornik
parents: 356
diff changeset
420 if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, file_class, enabled);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
422 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
423 g_free(ext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
424 g_free(desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
425 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
426
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
427 GList *path_list_filter(GList *list, gint is_dir_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
429 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
430
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 347
diff changeset
431 if (!is_dir_list && options->file_filter.disable && options->file_filter.show_hidden_files) return list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
433 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
434 while (work)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
435 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
436 gchar *name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
437 const gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
438
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
439 base = filename_from_path(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
440
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 347
diff changeset
441 if ((!options->file_filter.show_hidden_files && ishidden(base)) ||
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
442 (!is_dir_list && !filter_name_exists(base)) ||
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
443 (is_dir_list && base[0] == '.' && (strcmp(base, GQ_CACHE_LOCAL_THUMB) == 0 ||
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
444 strcmp(base, GQ_CACHE_LOCAL_METADATA) == 0)) )
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
445 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
446 GList *link = work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
447 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
448 list = g_list_remove_link(list, link);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
449 g_free(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
450 g_list_free(link);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
451 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
452 else
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
453 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
454 work = work->next;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
455 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
456 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
458 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
459 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
460
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
461
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
462 /*
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
463 *-----------------------------------------------------------------------------
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
464 * sidecar extension list
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
465 *-----------------------------------------------------------------------------
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
466 */
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
467
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
468 static GList *sidecar_ext_get_list(void)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
469 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
470 return sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
471 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
472
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
473 void sidecar_ext_parse(const gchar *text, gint quoted)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
474 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
475 GList *work;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
476 gchar *value;
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 work = sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
479 while (work)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
480 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
481 gchar *ext = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
482 work = work->next;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
483 g_free(ext);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
484 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
485 g_list_free(sidecar_ext_list);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
486 sidecar_ext_list = NULL;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
487
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
488 if (quoted)
217
5bdab7ed4bcd use quoted_value everywhere
nadvornik
parents: 215
diff changeset
489 value = quoted_value(text, NULL);
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
490 else
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
491 value = g_strdup(text);
145
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 if (value == NULL) return;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
494
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
495 sidecar_ext_list = filter_to_list(value);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
496
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
497 g_free(value);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
498 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
499
276
4f526d436873 Implement secure rc file saving.
zas_
parents: 248
diff changeset
500 void sidecar_ext_write(SecureSaveInfo *ssi)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
501 {
347
6dc0eaa0fcea sidecar_ext -> sidecar.ext
zas_
parents: 332
diff changeset
502 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
503 }
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
504
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
505 char *sidecar_ext_to_string()
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
506 {
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
507 GList *work;
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
508 GString *str = g_string_new("");
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
509
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
510 work = sidecar_ext_list;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
511 while (work)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
512 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
513 gchar *ext = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
514 work = work->next;
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
515 g_string_append(str, ext);
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
516 if (work) g_string_append(str, ";");
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
517 }
170
9a56e3d13e67 basic sidecar files configuration via preferences dialog
nadvornik
parents: 167
diff changeset
518 return g_string_free(str, FALSE);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
519 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
520
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
521 void sidecar_ext_add_defaults()
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
522 {
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 172
diff changeset
523 sidecar_ext_parse(".jpg;.cr2;.nef;.crw;.xmp", FALSE);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
524 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
525
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
526 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
527 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
528 * path list recursive
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
529 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
530 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
531
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
532 static gint path_list_sort_cb(gconstpointer a, gconstpointer b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
533 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
534 return CASE_SORT((gchar *)a, (gchar *)b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
535 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
536
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
537 GList *path_list_sort(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
538 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
539 return g_list_sort(list, path_list_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
540 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
541
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
542 static void path_list_recursive_append(GList **list, GList *dirs)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
543 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
544 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
545
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
546 work = dirs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
547 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
548 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
549 const gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
550 GList *f = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
551 GList *d = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
553 if (path_list(path, &f, &d))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
554 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
555 f = path_list_filter(f, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
556 f = path_list_sort(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
557 *list = g_list_concat(*list, f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
559 d = path_list_filter(d, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
560 d = path_list_sort(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
561 path_list_recursive_append(list, d);
52
a210a19f26da Sun Jun 5 03:05:39 2005 John Ellis <johne@verizon.net>
gqview
parents: 45
diff changeset
562 path_list_free(d);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
563 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
564
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
565 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
566 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
567 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
569 GList *path_list_recursive(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
570 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
571 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
572 GList *d = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
574 if (!path_list(path, &list, &d)) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
575 list = path_list_filter(list, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
576 list = path_list_sort(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
577
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
578 d = path_list_filter(d, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
579 d = path_list_sort(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
580 path_list_recursive_append(&list, d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
581 path_list_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
582
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
583 return list;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
584 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
585
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
586 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
587 *-----------------------------------------------------------------------------
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
588 * text conversion utils
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
589 *-----------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
590 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
591
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
592 gchar *text_from_size(gint64 size)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
593 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
594 gchar *a, *b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
595 gchar *s, *d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
596 gint l, n, i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
597
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
598 /* what I would like to use is printf("%'d", size)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
599 * BUT: not supported on every libc :(
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
600 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
601 if (size > G_MAXUINT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
602 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
603 /* the %lld conversion is not valid in all libcs, so use a simple work-around */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
604 a = g_strdup_printf("%d%09d", (guint)(size / 1000000000), (guint)(size % 1000000000));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
605 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
606 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
607 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
608 a = g_strdup_printf("%d", (guint)size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
609 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
610 l = strlen(a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
611 n = (l - 1)/ 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
612 if (n < 1) return a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
613
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
614 b = g_new(gchar, l + n + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
615
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
616 s = a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
617 d = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
618 i = l - n * 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
619 while (*s != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
620 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
621 if (i < 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
622 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
623 i = 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
624 *d = ',';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
625 d++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
626 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
627
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
628 *d = *s;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
629 s++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
630 d++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
631 i--;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
632 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
633 *d = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
634
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
635 g_free(a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
636 return b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
637 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
638
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
639 gchar *text_from_size_abrev(gint64 size)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
640 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
641 if (size < (gint64)1024)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
642 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
643 return g_strdup_printf(_("%d bytes"), (gint)size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
644 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
645 if (size < (gint64)1048576)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
646 {
15
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
647 return g_strdup_printf(_("%.1f K"), (double)size / 1024.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
648 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
649 if (size < (gint64)1073741824)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
650 {
15
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
651 return g_strdup_printf(_("%.1f MB"), (double)size / 1048576.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
652 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
653
15
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
654 /* to avoid overflowing the double, do division in two steps */
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
655 size /= 1048576;
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
656 return g_strdup_printf(_("%.1f GB"), (double)size / 1024.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
657 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
659 /* note: returned string is valid until next call to text_from_time() */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
660 const gchar *text_from_time(time_t t)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
661 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
662 static gchar *ret = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
663 gchar buf[128];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
664 gint buflen;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
665 struct tm *btime;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
666 GError *error = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
667
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
668 btime = localtime(&t);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
669
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
670 /* the %x warning about 2 digit years is not an error */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
671 buflen = strftime(buf, sizeof(buf), "%x %H:%M", btime);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
672 if (buflen < 1) return "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
674 g_free(ret);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
675 ret = g_locale_to_utf8(buf, buflen, NULL, NULL, &error);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
676 if (error)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
677 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
678 printf("Error converting locale strftime to UTF-8: %s\n", error->message);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
679 g_error_free(error);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
680 return "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
681 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
682
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
683 return ret;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
684 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
685
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
686 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
687 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
688 * file info struct
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
689 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
690 */
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
691
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
692 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source);
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
693 static void file_data_check_sidecars(FileData *fd);
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
694 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
695
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
696
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
697 static void file_data_set_path(FileData *fd, const gchar *path)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
698 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
699
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
700 if (strcmp(path, "/") == 0)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
701 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
702 fd->path = g_strdup(path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
703 fd->name = fd->path;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
704 fd->extension = fd->name + 1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
705 return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
706 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
707
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
708 fd->path = g_strdup(path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
709 fd->name = filename_from_path(fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
710
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
711 if (strcmp(fd->name, "..") == 0)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
712 {
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
713 gchar *dir = remove_level_from_path(path);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
714 g_free(fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
715 fd->path = remove_level_from_path(dir);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
716 g_free(dir);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
717 fd->name = "..";
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
718 fd->extension = fd->name + 2;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
719 return;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
720 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
721 else if (strcmp(fd->name, ".") == 0)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
722 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
723 g_free(fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
724 fd->path = remove_level_from_path(path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
725 fd->name = ".";
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
726 fd->extension = fd->name + 1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
727 return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
728 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
729
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
730 fd->extension = extension_from_path(fd->path);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
731 if (fd->extension == NULL)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
732 fd->extension = fd->name + strlen(fd->name);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
733 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
734
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
735 static void file_data_check_changed_files(FileData *fd, struct stat *st)
164
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
736 {
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
737 GList *work;
164
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
738 if (fd->size != st->st_size ||
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
739 fd->date != st->st_mtime)
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
740 {
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
741 fd->size = st->st_size;
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
742 fd->date = st->st_mtime;
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
743 if (fd->pixbuf) g_object_unref(fd->pixbuf);
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
744 fd->pixbuf = NULL;
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
745 }
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
746
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
747 work = fd->sidecar_files;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
748 while (work)
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
749 {
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
750 FileData *sfd = work->data;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
751 struct stat st;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
752
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
753 if (!stat_utf8(sfd->path, &st))
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
754 {
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
755 file_data_disconnect_sidecar_file(fd, sfd);
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
756 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
757
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
758 file_data_check_changed_files(sfd, &st);
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
759 work = work->next;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
760 }
164
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
761 }
f8bd5d49eed8 update FileData on file change
nadvornik
parents: 148
diff changeset
762
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
763 static GHashTable *file_data_pool = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
764
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
765 static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
766 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
767 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
768
172
d18b94f1ca80 debug messages cleanup
nadvornik
parents: 170
diff changeset
769 if (debug) printf("file_data_new: '%s' %d\n", path_utf8, check_sidecars);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
770
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
771 if (!file_data_pool)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
772 file_data_pool = g_hash_table_new (g_str_hash, g_str_equal);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
773
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
774 fd = g_hash_table_lookup(file_data_pool, path_utf8);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
775 if (fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
776 {
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
777 file_data_check_changed_files(fd, st);
172
d18b94f1ca80 debug messages cleanup
nadvornik
parents: 170
diff changeset
778 if (debug) printf("file_data_pool hit: '%s'\n", fd->path);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
779 return file_data_ref(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
780 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
781
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
782 fd = g_new0(FileData, 1);
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
783
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
784 file_data_set_path(fd, path_utf8);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
785
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
786 fd->original_path = g_strdup(path_utf8);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
787 fd->size = st->st_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
788 fd->date = st->st_mtime;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
789 fd->pixbuf = NULL;
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
790 fd->sidecar_files = NULL;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
791 fd->ref = 1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
792 fd->magick = 0x12345678;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
793
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
794 g_hash_table_insert(file_data_pool, fd->original_path, fd);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
795
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
796 if (check_sidecars && sidecar_file_priority(fd->extension))
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
797 file_data_check_sidecars(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
798 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
799 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
800
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
801 static void file_data_check_sidecars(FileData *fd)
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
802 {
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
803 int base_len = fd->extension - fd->path;
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
804 GString *fname = g_string_new_len(fd->path, base_len);
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
805 FileData *parent_fd = NULL;
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
806 GList *work = sidecar_ext_get_list();
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
807 while (work)
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
808 {
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
809 /* check for possible sidecar files;
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
810 the sidecar files created here are referenced only via fd->sidecar_files or fd->parent,
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
811 they have fd->ref set to 0 and file_data unref must chack and free them all together
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
812 (using fd->ref would cause loops and leaks)
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
813 */
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
814
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
815 FileData *new_fd;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
816
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
817 gchar *ext = work->data;
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
818 work = work->next;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
819
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
820 if (strcmp(ext, fd->extension) == 0)
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
821 {
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
822 new_fd = fd; /* processing the original file */
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
823 }
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
824 else
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
825 {
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
826 struct stat nst;
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
827 g_string_truncate(fname, base_len);
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
828 g_string_append(fname, ext);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
829
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
830 if (!stat_utf8(fname->str, &nst))
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
831 continue;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
832
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
833 new_fd = file_data_new(fname->str, &nst, FALSE);
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
834 new_fd->ref--; /* do not use ref here */
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
835 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
836
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
837 if (!parent_fd)
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
838 parent_fd = new_fd; /* parent is the one with the highest prio, found first */
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
839 else
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
840 file_data_merge_sidecar_files(parent_fd, new_fd);
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
841 }
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
842 g_string_free(fname, TRUE);
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
843 }
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
844
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
845
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
846 static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean check_sidecars)
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
847 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
848 gchar *path_utf8 = path_to_utf8(path);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
849 FileData *ret = file_data_new(path_utf8, st, check_sidecars);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
850 g_free(path_utf8);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
851 return ret;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
852 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
853
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
854 FileData *file_data_new_simple(const gchar *path_utf8)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
855 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
856 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
857
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
858 if (!stat_utf8(path_utf8, &st))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
859 {
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
860 st.st_size = 0;
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
861 st.st_mtime = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
862 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
863
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
864 return file_data_new(path_utf8, &st, TRUE);
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
865 }
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
866
141
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
867 FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd)
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
868 {
141
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
869 sfd->parent = target;
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
870 if(!g_list_find(target->sidecar_files, sfd))
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
871 target->sidecar_files = g_list_prepend(target->sidecar_files, sfd);
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
872 return target;
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
873 }
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
874
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
875
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
876 FileData *file_data_merge_sidecar_files(FileData *target, FileData *source)
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
877 {
141
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
878 GList *work;
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
879 file_data_add_sidecar_file(target, source);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
880
141
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
881 work = source->sidecar_files;
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
882 while (work)
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
883 {
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
884 FileData *sfd = work->data;
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
885 file_data_add_sidecar_file(target, sfd);
141
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
886 work = work->next;
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
887 }
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
888
146
e8285b0c0c7d prevent duplicate sidecar files; code cleanup
nadvornik
parents: 145
diff changeset
889 g_list_free(source->sidecar_files);
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
890 source->sidecar_files = NULL;
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
891
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
892 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE);
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
893 return target;
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
894 }
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
895
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
896
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
897
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
898 FileData *file_data_ref(FileData *fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
899 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
900 if (fd == NULL) return NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
901
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
902 // return g_memdup(fd, sizeof(FileData));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
903 g_assert(fd->magick == 0x12345678);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
904 fd->ref++;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
905 return fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
906 }
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
907
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
908 static void file_data_free(FileData *fd)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
909 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
910 g_assert(fd->magick == 0x12345678);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
911 g_assert(fd->ref == 0);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
912
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
913 g_hash_table_remove(file_data_pool, fd->original_path);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
914
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
915 g_free(fd->path);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
916 g_free(fd->original_path);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
917 if (fd->pixbuf) g_object_unref(fd->pixbuf);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
918
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
919
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
920 g_assert(fd->sidecar_files == NULL); /* sidecar files must be freed before calling this */
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
921
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
922 file_data_change_info_free(NULL, fd);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
923 g_free(fd);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
924 }
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
925
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
926 void file_data_unref(FileData *fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
927 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
928 if (fd == NULL) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
929 g_assert(fd->magick == 0x12345678);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
930
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
931 fd->ref--;
425
10efd67e5d3c file_dat_unref: display number of references as well of path (debug only).
zas_
parents: 370
diff changeset
932 if (debug) printf("file_data_unref (%d): '%s'\n", fd->ref, fd->path);
10efd67e5d3c file_dat_unref: display number of references as well of path (debug only).
zas_
parents: 370
diff changeset
933
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
934 if (fd->ref == 0)
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
935 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
936 FileData *parent = fd->parent ? fd->parent : fd;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
937
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
938 GList *work;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
939
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
940 if (parent->ref > 0)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
941 return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
942
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
943 work = parent->sidecar_files;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
944 while (work)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
945 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
946 FileData *sfd = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
947 if (sfd->ref > 0)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
948 return;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
949 work = work->next;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
950 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
951
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
952 /* none of parent/children is referenced, we can free everything */
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
953
172
d18b94f1ca80 debug messages cleanup
nadvornik
parents: 170
diff changeset
954 if (debug) printf("file_data_unref: deleting '%s', parent '%s'\n", fd->path, parent->path);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
955
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
956 work = parent->sidecar_files;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
957 while (work)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
958 {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
959 FileData *sfd = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
960 file_data_free(sfd);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
961 work = work->next;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
962 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
963
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
964 g_list_free(parent->sidecar_files);
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
965 parent->sidecar_files = NULL;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
966
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
967 file_data_free(parent);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
968
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
969 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
970 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
971
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
972 FileData *file_data_disconnect_sidecar_file(FileData *target, FileData *sfd)
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
973 {
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
974 sfd->parent = target;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
975 g_assert(g_list_find(target->sidecar_files, sfd));
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
976
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
977 target->sidecar_files = g_list_remove(target->sidecar_files, sfd);
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
978 sfd->parent = NULL;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
979
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
980 if (sfd->ref == 0) {
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
981 file_data_free(sfd);
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
982 return NULL;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
983 }
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
984
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
985 return sfd;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
986 }
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
987
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
988 /* compare name without extension */
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
989 gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2)
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
990 {
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
991 size_t len1 = fd1->extension - fd1->name;
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
992 size_t len2 = fd2->extension - fd2->name;
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
993
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
994 if (len1 < len2) return -1;
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
995 if (len1 > len2) return 1;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
996
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
997 return strncmp(fd1->name, fd2->name, len1);
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
998 }
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
999
240
cce347409480 Fix two more gcc warnings related to function declarations.
zas_
parents: 217
diff changeset
1000 void file_data_do_change(FileData *fd)
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1001 {
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1002 //FIXME sidecars
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1003 g_assert(fd->change);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1004 g_free(fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1005 g_hash_table_remove(file_data_pool, fd->original_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1006 g_free(fd->original_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1007 file_data_set_path(fd, fd->change->dest);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1008 fd->original_path = g_strdup(fd->change->dest);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1009 g_hash_table_insert(file_data_pool, fd->original_path, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1010
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1011 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1012
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1013 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest)
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1014 {
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1015
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1016 FileDataChangeInfo *fdci;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1017
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1018 if (fd->change) return FALSE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1019
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1020 fdci = g_new0(FileDataChangeInfo, 1);
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1021
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1022 fdci->type = type;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1023
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1024 if (src)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1025 fdci->source = g_strdup(src);
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1026 else
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1027 fdci->source = g_strdup(fd->path);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1028
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1029 if (dest)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1030 fdci->dest = g_strdup(dest);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1031
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1032 fd->change = fdci;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 141
diff changeset
1033 return TRUE;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1034 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1035
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1036 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1037 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1038 if (!fdci && fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1039 fdci = fd->change;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1040
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1041 if (!fdci)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1042 return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1043
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1044 g_free(fdci->source);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1045 g_free(fdci->dest);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1046
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1047 g_free(fdci);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1048
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1049 if (fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1050 fd->change = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1051 }
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1052
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1053
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1054
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1055
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1056 /*
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1057 *-----------------------------------------------------------------------------
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1058 * sidecar file info struct
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1059 *-----------------------------------------------------------------------------
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1060 */
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1061
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1062
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1063
240
cce347409480 Fix two more gcc warnings related to function declarations.
zas_
parents: 217
diff changeset
1064 static gint sidecar_file_priority(const gchar *path)
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1065 {
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1066 const char *extension = extension_from_path(path);
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1067 int i = 1;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1068 GList *work;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1069 if (extension == NULL)
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1070 return 0;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1071
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1072 work = sidecar_ext_get_list();
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1073
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1074 while (work) {
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1075 gchar *ext = work->data;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1076 work = work->next;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1077 if (strcmp(extension, ext) == 0) return i;
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1078 i++;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1079 }
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1080 return 0;
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1081 }
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1082
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1083 gchar *sidecar_file_data_list_to_string(FileData *fd)
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1084 {
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1085 GList *work;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1086 GString *result = g_string_new("");
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1087
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1088 work = fd->sidecar_files;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1089 while (work)
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1090 {
141
bdc16027fa6f use FileData even for sidecar file list
nadvornik
parents: 139
diff changeset
1091 FileData *sfd = work->data;
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1092 result = g_string_append(result, "+ ");
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1093 result = g_string_append(result, sfd->extension);
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1094 work = work->next;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1095 if (work) result = g_string_append_c(result, ' ');
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1096 }
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1097
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1098 return g_string_free(result, FALSE);
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1099 }
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1100
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1101 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1102 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1103 * load file list
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1104 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1105 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1107 static SortType filelist_sort_method = SORT_NONE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1108 static gint filelist_sort_ascend = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1109
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1110
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1111 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1113 if (!filelist_sort_ascend)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1114 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1115 FileData *tmp = fa;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1116 fa = fb;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1117 fb = tmp;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1118 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1119
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1120 switch (filelist_sort_method)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1121 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1122 case SORT_SIZE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1123 if (fa->size < fb->size) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1124 if (fa->size > fb->size) return 1;
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1125 return CASE_SORT(fa->name, fb->name); /* fall back to name */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1126 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1127 case SORT_TIME:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1128 if (fa->date < fb->date) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1129 if (fa->date > fb->date) return 1;
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1130 return CASE_SORT(fa->name, fb->name); /* fall back to name */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1131 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1132 #ifdef HAVE_STRVERSCMP
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1133 case SORT_NUMBER:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1134 return strverscmp(fa->name, fb->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1135 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1136 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1137 case SORT_NAME:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1138 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1139 return CASE_SORT(fa->name, fb->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1140 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1141 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1143
167
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1144 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gint ascend)
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1145 {
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1146 filelist_sort_method = method;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1147 filelist_sort_ascend = ascend;
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1148 return filelist_sort_compare_filedata(fa, fb);
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1149 }
05bf5d364dba fixed filelist refresh
nadvornik
parents: 164
diff changeset
1150
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1151 static gint filelist_sort_file_cb(void *a, void *b)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1152 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1153 return filelist_sort_compare_filedata(a, b);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1154 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1155
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1156 GList *filelist_sort_full(GList *list, SortType method, gint ascend, GCompareFunc cb)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1157 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1158 filelist_sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1159 filelist_sort_ascend = ascend;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1160 return g_list_sort(list, cb);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1161 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1162
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1163 GList *filelist_insert_sort_full(GList *list, void *data, SortType method, gint ascend, GCompareFunc cb)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1164 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1165 filelist_sort_method = method;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1166 filelist_sort_ascend = ascend;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1167 return g_list_insert_sorted(list, data, cb);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1168 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1169
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1170 GList *filelist_sort(GList *list, SortType method, gint ascend)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1171 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1172 return filelist_sort_full(list, method, ascend, (GCompareFunc) filelist_sort_file_cb);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1173 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1175 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1176 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1177 return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1178 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1179
137
be3328a58875 started support for sidecar files like xmp, raw+jpeg etc.
nadvornik
parents: 101
diff changeset
1180
148
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1181 static GList *filelist_filter_out_sidecars(GList *flist)
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1182 {
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1183 GList *work = flist;
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1184 GList *flist_filtered = NULL;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1185
148
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1186 while (work)
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1187 {
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1188 FileData *fd = work->data;
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1189 work = work->next;
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1190 if (fd->parent) /* remove fd's that are children */
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1191 file_data_unref(fd);
148
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1192 else
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1193 flist_filtered = g_list_prepend(flist_filtered, fd);
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1194 }
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1195 g_list_free(flist);
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1196 return flist_filtered;
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1197 }
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1198
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1199 static gint filelist_read_real(const gchar *path, GList **files, GList **dirs, gint follow_symlinks)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1200 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1201 DIR *dp;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1202 struct dirent *dir;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1203 struct stat ent_sbuf;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1204 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1205 GList *dlist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1206 GList *flist;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1207
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1208 dlist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1209 flist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1211 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1212 if (!pathl || (dp = opendir(pathl)) == NULL)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1213 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1214 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1215 if (files) *files = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1216 if (dirs) *dirs = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1217 return FALSE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1218 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1219
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1220 /* root dir fix */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1221 if (pathl[0] == '/' && pathl[1] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1222 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1223 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1224 pathl = g_strdup("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1225 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1226
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1227 while ((dir = readdir(dp)) != NULL)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1228 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1229 gchar *name = dir->d_name;
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 347
diff changeset
1230 if (options->file_filter.show_hidden_files || !ishidden(name))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1231 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1232 gchar *filepath = g_strconcat(pathl, "/", name, NULL);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1233 if ((follow_symlinks ?
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1234 stat(filepath, &ent_sbuf) :
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1235 lstat(filepath, &ent_sbuf)) >= 0)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1236 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1237 if (S_ISDIR(ent_sbuf.st_mode))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1238 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1239 /* we ignore the .thumbnails dir for cleanliness */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1240 if ((dirs) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1241 !(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) &&
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
1242 strcmp(name, GQ_CACHE_LOCAL_THUMB) != 0 &&
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
1243 strcmp(name, GQ_CACHE_LOCAL_METADATA) != 0 &&
79
528e3432e0c0 Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
1244 strcmp(name, THUMB_FOLDER_LOCAL) != 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1245 {
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 143
diff changeset
1246 dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, FALSE));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1247 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1248 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1249 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1250 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1251 if ((files) && filter_name_exists(name))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1252 {
148
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1253 flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1254 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1255 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1256 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1257 g_free(filepath);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1258 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1259 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1260
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1261 closedir(dp);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1262
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1263 g_free(pathl);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1264
148
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1265 flist = filelist_filter_out_sidecars(flist);
a8b4b99c9359 improved directory scanning a bit
nadvornik
parents: 147
diff changeset
1266
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1267 if (dirs) *dirs = dlist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1268 if (files) *files = flist;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1269
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1270 return TRUE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1271 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1272
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1273 gint filelist_read(const gchar *path, GList **files, GList **dirs)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1274 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1275 return filelist_read_real(path, files, dirs, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1276 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1277
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1278 gint filelist_read_lstat(const gchar *path, GList **files, GList **dirs)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1279 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1280 return filelist_read_real(path, files, dirs, FALSE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1281 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1282
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1283 void filelist_free(GList *list)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1284 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1285 GList *work;
3
gqview
parents: 1
diff changeset
1286
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1287 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1288 while (work)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1289 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1290 file_data_unref((FileData *)work->data);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1291 work = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1292 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1293
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1294 g_list_free(list);
3
gqview
parents: 1
diff changeset
1295 }
gqview
parents: 1
diff changeset
1296
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1297
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1298 GList *filelist_copy(GList *list)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1299 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1300 GList *new_list = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1301 GList *work;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1302
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1303 work = list;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1304 while (work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1305 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1306 FileData *fd;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1307
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1308 fd = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1309 work = work->next;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1310
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1311 new_list = g_list_prepend(new_list, file_data_ref(fd));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1312 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1313
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1314 return g_list_reverse(new_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1315 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1316
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1317 GList *filelist_from_path_list(GList *list)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1318 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1319 GList *new_list = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1320 GList *work;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1321
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1322 work = list;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1323 while (work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1324 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1325 gchar *path;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1326
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1327 path = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1328 work = work->next;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1329
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1330 new_list = g_list_prepend(new_list, file_data_new_simple(path));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1331 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1332
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1333 return g_list_reverse(new_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1334 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1335
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1336 GList *filelist_to_path_list(GList *list)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1337 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1338 GList *new_list = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1339 GList *work;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1340
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1341 work = list;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1342 while (work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1343 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1344 FileData *fd;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1345
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1346 fd = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1347 work = work->next;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1348
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1349 new_list = g_list_prepend(new_list, g_strdup(fd->path));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1350 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 425
diff changeset
1351
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1352 return g_list_reverse(new_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1353 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1354
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1355 GList *filelist_filter(GList *list, gint is_dir_list)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1356 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1357 GList *work;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1358
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 347
diff changeset
1359 if (!is_dir_list && options->file_filter.disable && options->file_filter.show_hidden_files) return list;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1360
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1361 work = list;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1362 while (work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1363 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1364 FileData *fd = (FileData *)(work->data);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1365 const gchar *name = fd->name;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1366
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 347
diff changeset
1367 if ((!options->file_filter.show_hidden_files && ishidden(name)) ||
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1368 (!is_dir_list && !filter_name_exists(name)) ||
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
1369 (is_dir_list && name[0] == '.' && (strcmp(name, GQ_CACHE_LOCAL_THUMB) == 0 ||
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
1370 strcmp(name, GQ_CACHE_LOCAL_METADATA) == 0)) )
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1371 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1372 GList *link = work;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1373 work = work->next;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1374 list = g_list_remove_link(list, link);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1375 file_data_unref(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1376 g_list_free(link);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1377 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1378 else
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1379 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1380 work = work->next;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1381 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1382 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1383
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1384 return list;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1385 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1386
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1387 /*
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1388 *-----------------------------------------------------------------------------
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1389 * filelist recursive
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1390 *-----------------------------------------------------------------------------
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1391 */
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1392
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1393 static gint filelist_sort_path_cb(gconstpointer a, gconstpointer b)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1394 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1395 return CASE_SORT(((FileData *)a)->path, ((FileData *)b)->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1396 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1397
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1398 GList *filelist_sort_path(GList *list)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1399 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1400 return g_list_sort(list, filelist_sort_path_cb);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1401 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1402
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1403 static void filelist_recursive_append(GList **list, GList *dirs)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1404 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1405 GList *work;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1406
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1407 work = dirs;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1408 while (work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1409 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1410 FileData *fd = (FileData *)(work->data);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1411 const gchar *path = fd->path;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1412 GList *f = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1413 GList *d = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1414
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1415 if (filelist_read(path, &f, &d))
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1416 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1417 f = filelist_filter(f, FALSE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1418 f = filelist_sort_path(f);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1419 *list = g_list_concat(*list, f);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1420
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1421 d = filelist_filter(d, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1422 d = filelist_sort_path(d);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1423 filelist_recursive_append(list, d);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1424 filelist_free(d);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1425 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1426
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1427 work = work->next;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1428 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1429 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1430
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1431 GList *filelist_recursive(const gchar *path)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1432 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1433 GList *list = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1434 GList *d = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1435
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1436 if (!filelist_read(path, &list, &d)) return NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1437 list = filelist_filter(list, FALSE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1438 list = filelist_sort_path(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1439
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1440 d = filelist_filter(d, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1441 d = filelist_sort_path(d);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1442 filelist_recursive_append(&list, d);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1443 filelist_free(d);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1444
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1445 return list;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 137
diff changeset
1446 }