Simplify vflist_get_formatted()
[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 #ifdef DEBUG
26 #define DEBUG_FILEDATA
27 #endif
28
29 #define FD_MAGICK 0x12345678u
30
31 gchar *text_from_size(gint64 size);
32 gchar *text_from_size_abrev(gint64 size);
33 const gchar *text_from_time(time_t t);
34
35 /**
36  * @headerfile file_data_new_group
37  * scan for sidecar files - expensive
38  */
39 FileData *file_data_new_group(const gchar *path_utf8);
40
41 /**
42  * @headerfile file_data_new_no_grouping
43  * should be used on helper files which can't have sidecars
44  */
45 FileData *file_data_new_no_grouping(const gchar *path_utf8);
46
47 /**
48  * @headerfile file_data_new_dir
49  * should be used on dirs
50  */
51 FileData *file_data_new_dir(const gchar *path_utf8);
52
53 FileData *file_data_new_simple(const gchar *path_utf8);
54
55 #ifdef DEBUG_FILEDATA
56 FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd);
57 void file_data_unref_debug(const gchar *file, gint line, FileData *fd);
58 #define file_data_ref(fd) file_data_ref_debug(__FILE__, __LINE__, fd)
59 #define file_data_unref(fd) file_data_unref_debug(__FILE__, __LINE__, fd)
60 #else
61 FileData *file_data_ref(FileData *fd);
62 void file_data_unref(FileData *fd);
63 #endif
64
65 void file_data_lock(FileData *fd);
66 void file_data_unlock(FileData *fd);
67 void file_data_lock_list(GList *list);
68 void file_data_unlock_list(GList *list);
69
70 gboolean file_data_check_changed_files(FileData *fd);
71
72 void file_data_increment_version(FileData *fd);
73
74 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest);
75 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd);
76
77 void file_data_disable_grouping(FileData *fd, gboolean disable);
78 void file_data_disable_grouping_list(GList *fd_list, gboolean disable);
79
80 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb);
81 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gboolean ascend);
82 GList *filelist_sort(GList *list, SortType method, gboolean ascend);
83 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gboolean ascend);
84 GList *filelist_sort_full(GList *list, SortType method, gboolean ascend, GCompareFunc cb);
85 GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gboolean ascend, GCompareFunc cb);
86
87 gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs);
88 gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs);
89 void filelist_free(GList *list);
90 GList *filelist_copy(GList *list);
91 GList *filelist_from_path_list(GList *list);
92 GList *filelist_to_path_list(GList *list);
93
94 GList *filelist_filter(GList *list, gboolean is_dir_list);
95
96 GList *filelist_sort_path(GList *list);
97 GList *filelist_recursive(FileData *dir_fd);
98 GList *filelist_recursive_full(FileData *dir_fd, SortType method, gboolean ascend);
99
100 typedef gboolean (* FileDataGetMarkFunc)(FileData *fd, gint n, gpointer data);
101 typedef gboolean (* FileDataSetMarkFunc)(FileData *fd, gint n, gboolean value, gpointer data);
102 gboolean file_data_register_mark_func(gint n, FileDataGetMarkFunc get_mark_func, FileDataSetMarkFunc set_mark_func, gpointer data, GDestroyNotify notify);
103 void file_data_get_registered_mark_func(gint n, FileDataGetMarkFunc *get_mark_func, FileDataSetMarkFunc *set_mark_func, gpointer *data);
104
105
106 gboolean file_data_get_mark(FileData *fd, gint n);
107 guint file_data_get_marks(FileData *fd);
108 void file_data_set_mark(FileData *fd, gint n, gboolean value);
109 gboolean file_data_filter_marks(FileData *fd, guint filter);
110 GList *file_data_filter_marks_list(GList *list, guint filter);
111
112 gboolean file_data_filter_file_filter(FileData *fd, GRegex *filter);
113 GList *file_data_filter_file_filter_list(GList *list, GRegex *filter);
114
115 GList *file_data_filter_class_list(GList *list, guint filter);
116
117 gint file_data_get_user_orientation(FileData *fd);
118 void file_data_set_user_orientation(FileData *fd, gint value);
119
120 gchar *file_data_sc_list_to_string(FileData *fd);
121
122 gchar *file_data_get_sidecar_path(FileData *fd, gboolean existing_only);
123
124
125 gboolean file_data_add_ci(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest);
126 gboolean file_data_sc_add_ci_copy(FileData *fd, const gchar *dest_path);
127 gboolean file_data_sc_add_ci_move(FileData *fd, const gchar *dest_path);
128 gboolean file_data_sc_add_ci_rename(FileData *fd, const gchar *dest_path);
129 gboolean file_data_sc_add_ci_delete(FileData *fd);
130 gboolean file_data_sc_add_ci_unspecified(FileData *fd, const gchar *dest_path);
131
132 gboolean file_data_sc_add_ci_delete_list(GList *fd_list);
133 gboolean file_data_sc_add_ci_copy_list(GList *fd_list, const gchar *dest);
134 gboolean file_data_sc_add_ci_move_list(GList *fd_list, const gchar *dest);
135 gboolean file_data_sc_add_ci_rename_list(GList *fd_list, const gchar *dest);
136 gboolean file_data_sc_add_ci_unspecified_list(GList *fd_list, const gchar *dest);
137 gboolean file_data_add_ci_write_metadata_list(GList *fd_list);
138
139 gboolean file_data_sc_update_ci_copy_list(GList *fd_list, const gchar *dest);
140 gboolean file_data_sc_update_ci_move_list(GList *fd_list, const gchar *dest);
141 gboolean file_data_sc_update_ci_unspecified_list(GList *fd_list, const gchar *dest);
142
143
144 gboolean file_data_sc_update_ci_copy(FileData *fd, const gchar *dest_path);
145 gboolean file_data_sc_update_ci_move(FileData *fd, const gchar *dest_path);
146 gboolean file_data_sc_update_ci_rename(FileData *fd, const gchar *dest_path);
147 gboolean file_data_sc_update_ci_unspecified(FileData *fd, const gchar *dest_path);
148
149 gchar *file_data_get_error_string(gint error);
150
151 gint file_data_verify_ci(FileData *fd, GList *list);
152 gint file_data_verify_ci_list(GList *list, gchar **desc, gboolean with_sidecars);
153
154 gboolean file_data_perform_ci(FileData *fd);
155 gboolean file_data_apply_ci(FileData *fd);
156 void file_data_free_ci(FileData *fd);
157 void file_data_free_ci_list(GList *fd_list);
158
159 void file_data_set_regroup_when_finished(FileData *fd, gboolean enable);
160
161 gint file_data_sc_verify_ci(FileData *fd, GList *list);
162
163 gboolean file_data_sc_perform_ci(FileData *fd);
164 gboolean file_data_sc_apply_ci(FileData *fd);
165 void file_data_sc_free_ci(FileData *fd);
166 void file_data_sc_free_ci_list(GList *fd_list);
167
168 GList *file_data_process_groups_in_selection(GList *list, gboolean ungroup, GList **ungrouped);
169
170
171 typedef void (*FileDataNotifyFunc)(FileData *fd, NotifyType type, gpointer data);
172 gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority);
173 gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data);
174 void file_data_send_notification(FileData *fd, NotifyType type);
175
176 gboolean file_data_register_real_time_monitor(FileData *fd);
177 gboolean file_data_unregister_real_time_monitor(FileData *fd);
178
179 void read_exif_time_data(FileData *file);
180 void read_exif_time_digitized_data(FileData *file);
181
182 gboolean marks_list_save(gchar *path, gboolean clear);
183 gboolean marks_list_load(const gchar *path);
184 void marks_clear_all();
185 void read_rating_data(FileData *file);
186
187 void file_data_inc_page_num(FileData *fd);
188 void file_data_dec_page_num(FileData *fd);
189 void file_data_set_page_total(FileData *fd, gint page_total);
190 void file_data_set_page_num(FileData *fd, gint page_num);
191 #endif
192 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */