Use util_clip_triangle() in pan_item_tri_new()
[geeqie.git] / src / filedata.h
index 736dab0..547a9fb 100644 (file)
 #ifndef FILEDATA_H
 #define FILEDATA_H
 
+#include <sys/types.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib.h>
+
+#include <config.h>
+
+#include "typedefs.h"
+
+struct ExifData;
+struct HistMap;
+
 #ifdef DEBUG
 #define DEBUG_FILEDATA
 #endif
@@ -32,13 +44,112 @@ gchar *text_from_size(gint64 size);
 gchar *text_from_size_abrev(gint64 size);
 const gchar *text_from_time(time_t t);
 
-/* scan for sidecar files - expensive */
+enum FileDataChangeType {
+       FILEDATA_CHANGE_DELETE,
+       FILEDATA_CHANGE_MOVE,
+       FILEDATA_CHANGE_RENAME,
+       FILEDATA_CHANGE_COPY,
+       FILEDATA_CHANGE_UNSPECIFIED,
+       FILEDATA_CHANGE_WRITE_METADATA
+};
+
+enum NotifyPriority {
+       NOTIFY_PRIORITY_HIGH = 0,
+       NOTIFY_PRIORITY_MEDIUM,
+       NOTIFY_PRIORITY_LOW
+};
+
+enum SelectionType {
+       SELECTION_NONE          = 0,
+       SELECTION_SELECTED      = 1 << 0,
+       SELECTION_PRELIGHT      = 1 << 1,
+       SELECTION_FOCUS         = 1 << 2
+};
+
+struct FileDataChangeInfo {
+       FileDataChangeType type;
+       gchar *source;
+       gchar *dest;
+       gint error;
+       gboolean regroup_when_finished;
+};
+
+struct FileData {
+       guint magick;
+       gint type;
+       gchar *original_path; /**< key to file_data_pool hash table */
+       gchar *path;
+       const gchar *name;
+       const gchar *extension;
+       gchar *extended_extension;
+       FileFormatClass format_class;
+       gchar *format_name; /**< set by the image loader */
+       gchar *collate_key_name;
+       gchar *collate_key_name_nocase;
+       gchar *collate_key_name_natural;
+       gchar *collate_key_name_nocase_natural;
+       gint64 size;
+       time_t date;
+       time_t cdate;
+       mode_t mode; /**< this is needed at least for notification in view_dir because it is preserved after the file/directory is deleted */
+       gint sidecar_priority;
+
+       guint marks; /**< each bit represents one mark */
+       guint valid_marks; /**< zero bit means that the corresponding mark needs to be reread */
+
+
+       GList *sidecar_files;
+       FileData *parent; /**< parent file if this is a sidecar file, NULL otherwise */
+       FileDataChangeInfo *change; /**< for rename, move ... */
+       GdkPixbuf *thumb_pixbuf;
+
+       GdkPixbuf *pixbuf; /**< full-size image, only complete images, NULL during loading
+                             all FileData with non-NULL pixbuf are referenced by image_cache */
+
+       HistMap *histmap;
+
+       gboolean locked;
+       gint ref;
+       gint version; /**< increased when any field in this structure is changed */
+       gboolean disable_grouping;
+
+       gint user_orientation;
+       gint exif_orientation;
+
+       ExifData *exif;
+       time_t exifdate;
+       time_t exifdate_digitized;
+       GHashTable *modified_xmp; /**< hash table which contains unwritten xmp metadata in format: key->list of string values */
+       GList *cached_metadata;
+       gint rating;
+       gboolean metadata_in_idle_loaded;
+
+       gchar *owner;
+       gchar *group;
+       gchar *sym_link;
+
+       SelectionType selected;  /**< Used by view-file-icon. */
+
+       gint page_num;
+       gint page_total;
+};
+
+/**
+ * @headerfile file_data_new_group
+ * scan for sidecar files - expensive
+ */
 FileData *file_data_new_group(const gchar *path_utf8);
 
-/* should be used on helper files which can't have sidecars */
+/**
+ * @headerfile file_data_new_no_grouping
+ * should be used on helper files which can't have sidecars
+ */
 FileData *file_data_new_no_grouping(const gchar *path_utf8);
 
-/* should be used on dirs */
+/**
+ * @headerfile file_data_new_dir
+ * should be used on dirs
+ */
 FileData *file_data_new_dir(const gchar *path_utf8);
 
 FileData *file_data_new_simple(const gchar *path_utf8);
@@ -70,10 +181,9 @@ void file_data_disable_grouping_list(GList *fd_list, gboolean disable);
 
 gint filelist_sort_compare_filedata(FileData *fa, FileData *fb);
 gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gboolean ascend);
-GList *filelist_sort(GList *list, SortType method, gboolean ascend);
-GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gboolean ascend);
-GList *filelist_sort_full(GList *list, SortType method, gboolean ascend, GCompareFunc cb);
-GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gboolean ascend, GCompareFunc cb);
+GList *filelist_sort(GList *list, SortType method, gboolean ascend, gboolean case_sensitive);
+GList *filelist_sort_full(GList *list, SortType method, gboolean ascend, gboolean case_sensitive, GCompareFunc cb);
+GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gboolean ascend, gboolean case_sensitive, GCompareFunc cb);
 
 gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs);
 gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs);
@@ -86,10 +196,10 @@ GList *filelist_filter(GList *list, gboolean is_dir_list);
 
 GList *filelist_sort_path(GList *list);
 GList *filelist_recursive(FileData *dir_fd);
-GList *filelist_recursive_full(FileData *dir_fd, SortType method, gboolean ascend);
+GList *filelist_recursive_full(FileData *dir_fd, SortType method, gboolean ascend, gboolean case_sensitive);
 
-typedef gboolean (* FileDataGetMarkFunc)(FileData *fd, gint n, gpointer data);
-typedef gboolean (* FileDataSetMarkFunc)(FileData *fd, gint n, gboolean value, gpointer data);
+using FileDataGetMarkFunc = gboolean (*)(FileData *, gint, gpointer);
+using FileDataSetMarkFunc = gboolean (*)(FileData *, gint, gboolean, gpointer);
 gboolean file_data_register_mark_func(gint n, FileDataGetMarkFunc get_mark_func, FileDataSetMarkFunc set_mark_func, gpointer data, GDestroyNotify notify);
 void file_data_get_registered_mark_func(gint n, FileDataGetMarkFunc *get_mark_func, FileDataSetMarkFunc *set_mark_func, gpointer *data);
 
@@ -100,14 +210,14 @@ void file_data_set_mark(FileData *fd, gint n, gboolean value);
 gboolean file_data_filter_marks(FileData *fd, guint filter);
 GList *file_data_filter_marks_list(GList *list, guint filter);
 
+gboolean file_data_mark_to_selection(FileData *fd, gint mark, MarkToSelectionMode mode, gboolean selected);
+void file_data_selection_to_mark(FileData *fd, gint mark, SelectionToMarkMode mode);
+
 gboolean file_data_filter_file_filter(FileData *fd, GRegex *filter);
 GList *file_data_filter_file_filter_list(GList *list, GRegex *filter);
 
 GList *file_data_filter_class_list(GList *list, guint filter);
 
-gint file_data_get_user_orientation(FileData *fd);
-void file_data_set_user_orientation(FileData *fd, gint value);
-
 gchar *file_data_sc_list_to_string(FileData *fd);
 
 gchar *file_data_get_sidecar_path(FileData *fd, gboolean existing_only);
@@ -159,7 +269,7 @@ void file_data_sc_free_ci_list(GList *fd_list);
 GList *file_data_process_groups_in_selection(GList *list, gboolean ungroup, GList **ungrouped);
 
 
-typedef void (*FileDataNotifyFunc)(FileData *fd, NotifyType type, gpointer data);
+using FileDataNotifyFunc = void (*)(FileData *, NotifyType, gpointer);
 gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority);
 gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data);
 void file_data_send_notification(FileData *fd, NotifyType type);
@@ -170,7 +280,7 @@ gboolean file_data_unregister_real_time_monitor(FileData *fd);
 void read_exif_time_data(FileData *file);
 void read_exif_time_digitized_data(FileData *file);
 
-gboolean marks_list_save(gchar *path, gboolean clear);
+gboolean marks_list_save(gchar *path, gboolean save);
 gboolean marks_list_load(const gchar *path);
 void marks_clear_all();
 void read_rating_data(FileData *file);
@@ -179,5 +289,7 @@ void file_data_inc_page_num(FileData *fd);
 void file_data_dec_page_num(FileData *fd);
 void file_data_set_page_total(FileData *fd, gint page_total);
 void file_data_set_page_num(FileData *fd, gint page_num);
+
+void file_data_dump();
 #endif
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */