Fix missing translation
[geeqie.git] / src / filedata.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef FILEDATA_H
23 #define FILEDATA_H
24
25 #include <gdk-pixbuf/gdk-pixbuf.h>
26
27 #include <config.h>
28
29 #include "typedefs.h"
30
31 struct ExifData;
32 struct HistMap;
33
34 #ifdef DEBUG
35 #define DEBUG_FILEDATA
36 #endif
37
38 #define FD_MAGICK 0x12345678u
39
40 gchar *text_from_size(gint64 size);
41 gchar *text_from_size_abrev(gint64 size);
42 const gchar *text_from_time(time_t t);
43
44 enum FileDataChangeType {
45         FILEDATA_CHANGE_DELETE,
46         FILEDATA_CHANGE_MOVE,
47         FILEDATA_CHANGE_RENAME,
48         FILEDATA_CHANGE_COPY,
49         FILEDATA_CHANGE_UNSPECIFIED,
50         FILEDATA_CHANGE_WRITE_METADATA
51 };
52
53 enum NotifyPriority {
54         NOTIFY_PRIORITY_HIGH = 0,
55         NOTIFY_PRIORITY_MEDIUM,
56         NOTIFY_PRIORITY_LOW
57 };
58
59 enum SelectionType {
60         SELECTION_NONE          = 0,
61         SELECTION_SELECTED      = 1 << 0,
62         SELECTION_PRELIGHT      = 1 << 1,
63         SELECTION_FOCUS         = 1 << 2
64 };
65
66 struct FileDataChangeInfo {
67         FileDataChangeType type;
68         gchar *source;
69         gchar *dest;
70         gint error;
71         gboolean regroup_when_finished;
72 };
73
74 struct FileData {
75         guint magick;
76         gint type;
77         gchar *original_path; /**< key to file_data_pool hash table */
78         gchar *path;
79         const gchar *name;
80         const gchar *extension;
81         gchar *extended_extension;
82         FileFormatClass format_class;
83         gchar *format_name; /**< set by the image loader */
84         gchar *collate_key_name;
85         gchar *collate_key_name_nocase;
86         gchar *collate_key_name_natural;
87         gchar *collate_key_name_nocase_natural;
88         gint64 size;
89         time_t date;
90         time_t cdate;
91         mode_t mode; /**< this is needed at least for notification in view_dir because it is preserved after the file/directory is deleted */
92         gint sidecar_priority;
93
94         guint marks; /**< each bit represents one mark */
95         guint valid_marks; /**< zero bit means that the corresponding mark needs to be reread */
96
97
98         GList *sidecar_files;
99         FileData *parent; /**< parent file if this is a sidecar file, NULL otherwise */
100         FileDataChangeInfo *change; /**< for rename, move ... */
101         GdkPixbuf *thumb_pixbuf;
102
103         GdkPixbuf *pixbuf; /**< full-size image, only complete images, NULL during loading
104                               all FileData with non-NULL pixbuf are referenced by image_cache */
105
106         HistMap *histmap;
107
108         gboolean locked;
109         gint ref;
110         gint version; /**< increased when any field in this structure is changed */
111         gboolean disable_grouping;
112
113         gint user_orientation;
114         gint exif_orientation;
115
116         ExifData *exif;
117         time_t exifdate;
118         time_t exifdate_digitized;
119         GHashTable *modified_xmp; /**< hash table which contains unwritten xmp metadata in format: key->list of string values */
120         GList *cached_metadata;
121         gint rating;
122         gboolean metadata_in_idle_loaded;
123
124         gchar *owner;
125         gchar *group;
126         gchar *sym_link;
127
128         SelectionType selected;  /**< Used by view-file-icon. */
129
130         gint page_num;
131         gint page_total;
132 };
133
134 /**
135  * @headerfile file_data_new_group
136  * scan for sidecar files - expensive
137  */
138 FileData *file_data_new_group(const gchar *path_utf8);
139
140 /**
141  * @headerfile file_data_new_no_grouping
142  * should be used on helper files which can't have sidecars
143  */
144 FileData *file_data_new_no_grouping(const gchar *path_utf8);
145
146 /**
147  * @headerfile file_data_new_dir
148  * should be used on dirs
149  */
150 FileData *file_data_new_dir(const gchar *path_utf8);
151
152 FileData *file_data_new_simple(const gchar *path_utf8);
153
154 #ifdef DEBUG_FILEDATA
155 FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd);
156 void file_data_unref_debug(const gchar *file, gint line, FileData *fd);
157 #define file_data_ref(fd) file_data_ref_debug(__FILE__, __LINE__, fd)
158 #define file_data_unref(fd) file_data_unref_debug(__FILE__, __LINE__, fd)
159 #else
160 FileData *file_data_ref(FileData *fd);
161 void file_data_unref(FileData *fd);
162 #endif
163
164 void file_data_lock(FileData *fd);
165 void file_data_unlock(FileData *fd);
166 void file_data_lock_list(GList *list);
167 void file_data_unlock_list(GList *list);
168
169 gboolean file_data_check_changed_files(FileData *fd);
170
171 void file_data_increment_version(FileData *fd);
172
173 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest);
174 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd);
175
176 void file_data_disable_grouping(FileData *fd, gboolean disable);
177 void file_data_disable_grouping_list(GList *fd_list, gboolean disable);
178
179 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb);
180 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gboolean ascend);
181 GList *filelist_sort(GList *list, SortType method, gboolean ascend, gboolean case_sensitive);
182 GList *filelist_sort_full(GList *list, SortType method, gboolean ascend, gboolean case_sensitive, GCompareFunc cb);
183 GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gboolean ascend, gboolean case_sensitive, GCompareFunc cb);
184
185 gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs);
186 gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs);
187 void filelist_free(GList *list);
188 GList *filelist_copy(GList *list);
189 GList *filelist_from_path_list(GList *list);
190 GList *filelist_to_path_list(GList *list);
191
192 GList *filelist_filter(GList *list, gboolean is_dir_list);
193
194 GList *filelist_sort_path(GList *list);
195 GList *filelist_recursive(FileData *dir_fd);
196 GList *filelist_recursive_full(FileData *dir_fd, SortType method, gboolean ascend, gboolean case_sensitive);
197
198 using FileDataGetMarkFunc = gboolean (*)(FileData *, gint, gpointer);
199 using FileDataSetMarkFunc = gboolean (*)(FileData *, gint, gboolean, gpointer);
200 gboolean file_data_register_mark_func(gint n, FileDataGetMarkFunc get_mark_func, FileDataSetMarkFunc set_mark_func, gpointer data, GDestroyNotify notify);
201 void file_data_get_registered_mark_func(gint n, FileDataGetMarkFunc *get_mark_func, FileDataSetMarkFunc *set_mark_func, gpointer *data);
202
203
204 gboolean file_data_get_mark(FileData *fd, gint n);
205 guint file_data_get_marks(FileData *fd);
206 void file_data_set_mark(FileData *fd, gint n, gboolean value);
207 gboolean file_data_filter_marks(FileData *fd, guint filter);
208 GList *file_data_filter_marks_list(GList *list, guint filter);
209
210 gboolean file_data_filter_file_filter(FileData *fd, GRegex *filter);
211 GList *file_data_filter_file_filter_list(GList *list, GRegex *filter);
212
213 GList *file_data_filter_class_list(GList *list, guint filter);
214
215 gchar *file_data_sc_list_to_string(FileData *fd);
216
217 gchar *file_data_get_sidecar_path(FileData *fd, gboolean existing_only);
218
219
220 gboolean file_data_add_ci(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest);
221 gboolean file_data_sc_add_ci_copy(FileData *fd, const gchar *dest_path);
222 gboolean file_data_sc_add_ci_move(FileData *fd, const gchar *dest_path);
223 gboolean file_data_sc_add_ci_rename(FileData *fd, const gchar *dest_path);
224 gboolean file_data_sc_add_ci_delete(FileData *fd);
225 gboolean file_data_sc_add_ci_unspecified(FileData *fd, const gchar *dest_path);
226
227 gboolean file_data_sc_add_ci_delete_list(GList *fd_list);
228 gboolean file_data_sc_add_ci_copy_list(GList *fd_list, const gchar *dest);
229 gboolean file_data_sc_add_ci_move_list(GList *fd_list, const gchar *dest);
230 gboolean file_data_sc_add_ci_rename_list(GList *fd_list, const gchar *dest);
231 gboolean file_data_sc_add_ci_unspecified_list(GList *fd_list, const gchar *dest);
232 gboolean file_data_add_ci_write_metadata_list(GList *fd_list);
233
234 gboolean file_data_sc_update_ci_copy_list(GList *fd_list, const gchar *dest);
235 gboolean file_data_sc_update_ci_move_list(GList *fd_list, const gchar *dest);
236 gboolean file_data_sc_update_ci_unspecified_list(GList *fd_list, const gchar *dest);
237
238
239 gboolean file_data_sc_update_ci_copy(FileData *fd, const gchar *dest_path);
240 gboolean file_data_sc_update_ci_move(FileData *fd, const gchar *dest_path);
241 gboolean file_data_sc_update_ci_rename(FileData *fd, const gchar *dest_path);
242 gboolean file_data_sc_update_ci_unspecified(FileData *fd, const gchar *dest_path);
243
244 gchar *file_data_get_error_string(gint error);
245
246 gint file_data_verify_ci(FileData *fd, GList *list);
247 gint file_data_verify_ci_list(GList *list, gchar **desc, gboolean with_sidecars);
248
249 gboolean file_data_perform_ci(FileData *fd);
250 gboolean file_data_apply_ci(FileData *fd);
251 void file_data_free_ci(FileData *fd);
252 void file_data_free_ci_list(GList *fd_list);
253
254 void file_data_set_regroup_when_finished(FileData *fd, gboolean enable);
255
256 gint file_data_sc_verify_ci(FileData *fd, GList *list);
257
258 gboolean file_data_sc_perform_ci(FileData *fd);
259 gboolean file_data_sc_apply_ci(FileData *fd);
260 void file_data_sc_free_ci(FileData *fd);
261 void file_data_sc_free_ci_list(GList *fd_list);
262
263 GList *file_data_process_groups_in_selection(GList *list, gboolean ungroup, GList **ungrouped);
264
265
266 using FileDataNotifyFunc = void (*)(FileData *, NotifyType, gpointer);
267 gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority);
268 gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data);
269 void file_data_send_notification(FileData *fd, NotifyType type);
270
271 gboolean file_data_register_real_time_monitor(FileData *fd);
272 gboolean file_data_unregister_real_time_monitor(FileData *fd);
273
274 void read_exif_time_data(FileData *file);
275 void read_exif_time_digitized_data(FileData *file);
276
277 gboolean marks_list_save(gchar *path, gboolean save);
278 gboolean marks_list_load(const gchar *path);
279 void marks_clear_all();
280 void read_rating_data(FileData *file);
281
282 void file_data_inc_page_num(FileData *fd);
283 void file_data_dec_page_num(FileData *fd);
284 void file_data_set_page_total(FileData *fd, gint page_total);
285 void file_data_set_page_num(FileData *fd, gint page_num);
286
287 void file_data_dump();
288 #endif
289 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */