Use FileData locks to avoid expensive reloads with marks enabled
[geeqie.git] / src / filedata.h
1 /*
2  * Geeqie
3  * (C) 2004 John Ellis
4  * Copyright (C) 2008 - 2012 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #ifndef FILEDATA_H
15 #define FILEDATA_H
16
17 #ifdef DEBUG
18 #define DEBUG_FILEDATA
19 #endif
20
21 #define FD_MAGICK 0x12345678u
22
23 gchar *text_from_size(gint64 size);
24 gchar *text_from_size_abrev(gint64 size);
25 const gchar *text_from_time(time_t t);
26
27 /* scan for sidecar files - expensive */
28 FileData *file_data_new_group(const gchar *path_utf8);
29
30 /* should be used on helper files which can't have sidecars */
31 FileData *file_data_new_no_grouping(const gchar *path_utf8);
32
33 /* should be used on dirs */
34 FileData *file_data_new_dir(const gchar *path_utf8);
35
36 #ifdef DEBUG_FILEDATA
37 FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd);
38 void file_data_unref_debug(const gchar *file, gint line, FileData *fd);
39 #define file_data_ref(fd) file_data_ref_debug(__FILE__, __LINE__, fd)
40 #define file_data_unref(fd) file_data_unref_debug(__FILE__, __LINE__, fd)
41 #else
42 FileData *file_data_ref(FileData *fd);
43 void file_data_unref(FileData *fd);
44 #endif
45
46 void file_data_lock(FileData *fd);
47 void file_data_unlock(FileData *fd);
48 void file_data_lock_list(GList *list);
49 void file_data_unlock_list(GList *list);
50
51 gboolean file_data_check_changed_files(FileData *fd);
52
53 void file_data_increment_version(FileData *fd);
54
55 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest);
56 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd);
57
58 void file_data_disable_grouping(FileData *fd, gboolean disable);
59 void file_data_disable_grouping_list(GList *fd_list, gboolean disable);
60
61 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb);
62 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gboolean ascend);
63 GList *filelist_sort(GList *list, SortType method, gboolean ascend);
64 GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gboolean ascend);
65 GList *filelist_sort_full(GList *list, SortType method, gboolean ascend, GCompareFunc cb);
66 GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gboolean ascend, GCompareFunc cb);
67
68 gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs);
69 gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs);
70 void filelist_free(GList *list);
71 GList *filelist_copy(GList *list);
72 GList *filelist_from_path_list(GList *list);
73 GList *filelist_to_path_list(GList *list);
74
75 GList *filelist_filter(GList *list, gboolean is_dir_list);
76
77 GList *filelist_sort_path(GList *list);
78 GList *filelist_recursive(FileData *dir_fd);
79
80 typedef gboolean (* FileDataGetMarkFunc)(FileData *fd, gint n, gpointer data);
81 typedef gboolean (* FileDataSetMarkFunc)(FileData *fd, gint n, gboolean value, gpointer data);
82 gboolean file_data_register_mark_func(gint n, FileDataGetMarkFunc get_mark_func, FileDataSetMarkFunc set_mark_func, gpointer data, GDestroyNotify notify);
83 void file_data_get_registered_mark_func(gint n, FileDataGetMarkFunc *get_mark_func, FileDataSetMarkFunc *set_mark_func, gpointer *data);
84
85
86 gboolean file_data_get_mark(FileData *fd, gint n);
87 guint file_data_get_marks(FileData *fd);
88 void file_data_set_mark(FileData *fd, gint n, gboolean value);
89 gboolean file_data_filter_marks(FileData *fd, guint filter);
90 GList *file_data_filter_marks_list(GList *list, guint filter);
91
92 gint file_data_get_user_orientation(FileData *fd);
93 void file_data_set_user_orientation(FileData *fd, gint value);
94
95 gchar *file_data_sc_list_to_string(FileData *fd);
96
97 gchar *file_data_get_sidecar_path(FileData *fd, gboolean existing_only);
98
99
100 gboolean file_data_add_ci(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest);
101 gboolean file_data_sc_add_ci_copy(FileData *fd, const gchar *dest_path);
102 gboolean file_data_sc_add_ci_move(FileData *fd, const gchar *dest_path);
103 gboolean file_data_sc_add_ci_rename(FileData *fd, const gchar *dest_path);
104 gboolean file_data_sc_add_ci_delete(FileData *fd);
105 gboolean file_data_sc_add_ci_unspecified(FileData *fd, const gchar *dest_path);
106
107 gboolean file_data_sc_add_ci_delete_list(GList *fd_list);
108 gboolean file_data_sc_add_ci_copy_list(GList *fd_list, const gchar *dest);
109 gboolean file_data_sc_add_ci_move_list(GList *fd_list, const gchar *dest);
110 gboolean file_data_sc_add_ci_rename_list(GList *fd_list, const gchar *dest);
111 gboolean file_data_sc_add_ci_unspecified_list(GList *fd_list, const gchar *dest);
112 gboolean file_data_add_ci_write_metadata_list(GList *fd_list);
113
114 gboolean file_data_sc_update_ci_copy_list(GList *fd_list, const gchar *dest);
115 gboolean file_data_sc_update_ci_move_list(GList *fd_list, const gchar *dest);
116 gboolean file_data_sc_update_ci_unspecified_list(GList *fd_list, const gchar *dest);
117
118
119 gboolean file_data_sc_update_ci_copy(FileData *fd, const gchar *dest_path);
120 gboolean file_data_sc_update_ci_move(FileData *fd, const gchar *dest_path);
121 gboolean file_data_sc_update_ci_rename(FileData *fd, const gchar *dest_path);
122 gboolean file_data_sc_update_ci_unspecified(FileData *fd, const gchar *dest_path);
123
124 gchar *file_data_get_error_string(gint error);
125
126 gint file_data_verify_ci(FileData *fd);
127 gint file_data_verify_ci_list(GList *list, gchar **desc, gboolean with_sidecars);
128
129 gboolean file_data_perform_ci(FileData *fd);
130 gboolean file_data_apply_ci(FileData *fd);
131 void file_data_free_ci(FileData *fd);
132 void file_data_free_ci_list(GList *fd_list);
133
134 void file_data_set_regroup_when_finished(FileData *fd, gboolean enable);
135
136 gint file_data_sc_verify_ci(FileData *fd);
137
138 gboolean file_data_sc_perform_ci(FileData *fd);
139 gboolean file_data_sc_apply_ci(FileData *fd);
140 void file_data_sc_free_ci(FileData *fd);
141 void file_data_sc_free_ci_list(GList *fd_list);
142
143 GList *file_data_process_groups_in_selection(GList *list, gboolean ungroup, GList **ungrouped);
144
145
146 typedef void (*FileDataNotifyFunc)(FileData *fd, NotifyType type, gpointer data);
147 gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority);
148 gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data);
149 void file_data_send_notification(FileData *fd, NotifyType type);
150
151 gboolean file_data_register_real_time_monitor(FileData *fd);
152 gboolean file_data_unregister_real_time_monitor(FileData *fd);
153
154 #endif
155 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */