prepared infrastructure for delayed metadata writting - refreshing
[geeqie.git] / src / typedefs.h
1 /*
2  * Geeqie
3  * (C) 2006 John Ellis
4  * Copyright (C) 2008 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 TYPEDEFS_H
15 #define TYPEDEFS_H
16
17 typedef enum {
18         ZOOM_RESET_ORIGINAL     = 0,
19         ZOOM_RESET_FIT_WINDOW   = 1,
20         ZOOM_RESET_NONE         = 2
21 } ZoomMode;
22
23 typedef enum {
24         MOUSE_BUTTON_LEFT       = 1,
25         MOUSE_BUTTON_MIDDLE     = 2,
26         MOUSE_BUTTON_RIGHT      = 3,
27         MOUSE_BUTTON_WHEEL_UP   = 4,
28         MOUSE_BUTTON_WHEEL_DOWN = 5
29 } MouseButton;
30
31 typedef enum {
32         DIRVIEW_LIST,
33         DIRVIEW_TREE
34 } DirViewType;
35
36 typedef enum {
37         FILEVIEW_LIST,
38         FILEVIEW_ICON
39 } FileViewType;
40
41 typedef enum {
42         CMD_COPY = GQ_EDITOR_GENERIC_SLOTS,
43         CMD_MOVE,
44         CMD_RENAME,
45         CMD_DELETE,
46         CMD_FOLDER,
47         GQ_EDITOR_SLOTS
48 } SpecialEditor;
49
50 typedef enum {
51         SORT_NONE,
52         SORT_NAME,
53         SORT_SIZE,
54         SORT_TIME,
55         SORT_PATH,
56         SORT_NUMBER
57 } SortType;
58
59 typedef enum {
60         ALTER_NONE,             /* do nothing */
61         ALTER_ROTATE_90,
62         ALTER_ROTATE_90_CC,     /* counterclockwise */
63         ALTER_ROTATE_180,
64         ALTER_MIRROR,
65         ALTER_FLIP,
66         ALTER_DESATURATE
67 } AlterType;
68
69 typedef enum {
70         LAYOUT_HIDE   = 0,
71         LAYOUT_LEFT   = 1 << 0,
72         LAYOUT_RIGHT  = 1 << 1,
73         LAYOUT_TOP    = 1 << 2,
74         LAYOUT_BOTTOM = 1 << 3
75 } LayoutLocation;
76
77
78 typedef enum {
79         IMAGE_STATE_NONE        = 0,
80         IMAGE_STATE_IMAGE       = 1 << 0,
81         IMAGE_STATE_LOADING     = 1 << 1,
82         IMAGE_STATE_ERROR       = 1 << 2,
83         IMAGE_STATE_COLOR_ADJ   = 1 << 3,
84         IMAGE_STATE_ROTATE_AUTO = 1 << 4,
85         IMAGE_STATE_ROTATE_USER = 1 << 5,
86         IMAGE_STATE_DELAY_FLIP  = 1 << 6
87 } ImageState;
88
89 typedef enum {
90         SPLIT_NONE = 0,
91         SPLIT_VERT,
92         SPLIT_HOR,
93         SPLIT_QUAD,
94 } ImageSplitMode;
95
96 typedef enum {
97         FILEDATA_CHANGE_DELETE,
98         FILEDATA_CHANGE_MOVE,
99         FILEDATA_CHANGE_RENAME,
100         FILEDATA_CHANGE_COPY,
101         FILEDATA_CHANGE_UNSPECIFIED
102 } FileDataChangeType;
103
104 typedef enum {
105         MTS_MODE_MINUS,
106         MTS_MODE_SET,
107         MTS_MODE_OR,
108         MTS_MODE_AND
109 } MarkToSelectionMode;
110
111 typedef enum {
112         STM_MODE_RESET,
113         STM_MODE_SET,
114         STM_MODE_TOGGLE
115 } SelectionToMarkMode;
116
117 typedef enum {
118         FORMAT_CLASS_UNKNOWN,
119         FORMAT_CLASS_IMAGE,
120         FORMAT_CLASS_RAWIMAGE,
121         FORMAT_CLASS_META,
122         FILE_FORMAT_CLASSES
123 } FileFormatClass;
124
125 typedef enum {
126         SS_ERR_NONE = 0,
127         SS_ERR_DISABLED, /**< secsave is disabled. */
128         SS_ERR_OUT_OF_MEM, /**< memory allocation failure */
129
130         /* see err field in SecureSaveInfo */
131         SS_ERR_OPEN_READ,
132         SS_ERR_OPEN_WRITE,
133         SS_ERR_STAT,
134         SS_ERR_ACCESS,
135         SS_ERR_MKSTEMP,
136         SS_ERR_RENAME,
137         SS_ERR_OTHER,
138 } SecureSaveErrno;
139
140 typedef enum {
141         NOTIFY_PRIORITY_HIGH = 0,
142         NOTIFY_PRIORITY_MEDIUM,
143         NOTIFY_PRIORITY_LOW
144 } NotifyPriority;
145         
146 typedef enum {
147         NOTIFY_TYPE_INTERNAL = 0, /* changed internal data only, like marks */
148         NOTIFY_TYPE_REREAD,       /* changed file size, date, etc., file name remains unchanged */
149         NOTIFY_TYPE_CHANGE        /* generic change described by fd->change */
150 } NotifyType;
151
152 typedef enum {
153         CHANGE_OK                      = 0,
154         CHANGE_WARN_DEST_EXISTS        = 1 << 0,
155         CHANGE_WARN_NO_WRITE_PERM      = 1 << 1,
156         CHANGE_WARN_SAME               = 1 << 2,
157         CHANGE_WARN_CHANGED_EXT        = 1 << 3,
158         CHANGE_ERROR_MASK              = (~0) << 4, /* the values below are fatal errors */
159         CHANGE_NO_READ_PERM            = 1 << 4,
160         CHANGE_NO_WRITE_PERM_DIR       = 1 << 5,
161         CHANGE_NO_DEST_DIR             = 1 << 6,
162         CHANGE_NO_WRITE_PERM_DEST_DIR  = 1 << 7,
163         CHANGE_NO_WRITE_PERM_DEST      = 1 << 8,
164         CHANGE_DEST_EXISTS             = 1 << 9,
165         CHANGE_NO_SRC                  = 1 << 10,
166         CHANGE_GENERIC_ERROR           = 1 << 16
167 } ChangeError;
168
169 #define MAX_SPLIT_IMAGES 4
170
171 typedef struct _ImageLoader ImageLoader;
172 typedef struct _ThumbLoader ThumbLoader;
173
174 typedef struct _CollectInfo CollectInfo;
175 typedef struct _CollectionData CollectionData;
176 typedef struct _CollectTable CollectTable;
177 typedef struct _CollectWindow CollectWindow;
178
179 typedef struct _ImageWindow ImageWindow;
180
181 typedef struct _FileData FileData;
182 typedef struct _FileDataChangeInfo FileDataChangeInfo;
183
184 typedef struct _LayoutWindow LayoutWindow;
185
186 typedef struct _ViewDir ViewDir;
187 typedef struct _ViewDirInfoList ViewDirInfoList;
188 typedef struct _ViewDirInfoTree ViewDirInfoTree;
189
190 typedef struct _ViewFile ViewFile;
191 typedef struct _ViewFileInfoList ViewFileInfoList;
192 typedef struct _ViewFileInfoIcon ViewFileInfoIcon;
193
194 typedef struct _SlideShowData SlideShowData;
195 typedef struct _FullScreenData FullScreenData;
196
197 typedef struct _PixmapFolders PixmapFolders;
198 typedef struct _Histogram Histogram;
199
200 typedef struct _SecureSaveInfo SecureSaveInfo;
201
202 typedef struct _ExifData ExifData;
203
204 typedef struct _Editor Editor;
205 struct _Editor {
206         gchar *name;
207         gchar *command;
208 };
209
210 struct _ImageLoader;
211
212 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
213
214 struct _ThumbLoader
215 {
216         gint standard_loader;
217
218         ImageLoader *il;
219         FileData *fd;           /* fd->pixbuf contains final (scaled) image when done */
220
221         gint cache_enable;
222         gint cache_hit;
223         gdouble percent_done;
224
225         gint max_w;
226         gint max_h;
227
228         ThumbLoaderFunc func_done;
229         ThumbLoaderFunc func_error;
230         ThumbLoaderFunc func_progress;
231
232         gpointer data;
233
234         gint idle_done_id;
235 };
236
237 struct _CollectInfo
238 {
239         FileData *fd;
240         GdkPixbuf *pixbuf;
241         guint flag_mask;
242 };
243
244 struct _CollectionData
245 {
246         gchar *path;
247         gchar *name;
248         GList *list;
249         SortType sort_method;
250
251         ThumbLoader *thumb_loader;
252         CollectInfo *thumb_info;
253
254         void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
255         gpointer info_updated_data;
256
257         gint ref;
258
259         /* geometry */
260         gint window_read;
261         gint window_x;
262         gint window_y;
263         gint window_w;
264         gint window_h;
265
266         /* contents changed since save flag */
267         gint changed;
268
269         GHashTable *existence;
270 };
271
272 struct _CollectTable
273 {
274         GtkWidget *scrolled;
275         GtkWidget *listview;
276         gint columns;
277         gint rows;
278
279         CollectionData *cd;
280
281         GList *selection;
282         CollectInfo *prev_selection;
283
284         CollectInfo *click_info;
285
286         GtkWidget *tip_window;
287         gint tip_delay_id;
288         CollectInfo *tip_info;
289
290         GdkWindow *marker_window;
291         CollectInfo *marker_info;
292
293         GtkWidget *status_label;
294         GtkWidget *extra_label;
295
296         gint focus_row;
297         gint focus_column;
298         CollectInfo *focus_info;
299
300         GtkWidget *popup;
301         CollectInfo *drop_info;
302         GList *drop_list;
303
304         gint sync_idle_id;
305         gint drop_idle_id;
306
307         gint show_text;
308 };
309
310 struct _CollectWindow
311 {
312         GtkWidget *window;
313         CollectTable *table;
314         GtkWidget *status_box;
315         GList *list;
316
317         GtkWidget *close_dialog;
318
319         CollectionData *cd;
320 };
321
322 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
323                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
324 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
325                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
326
327 struct _ImageWindow
328 {
329         GtkWidget *widget;      /* use this to add it and show it */
330         GtkWidget *pr;
331         GtkWidget *frame;
332
333         FileData *image_fd;
334
335         gint unknown;           /* failed to load image */
336
337         ImageLoader *il;        /* FIXME - image loader should probably go to FileData, but it must first support
338                                    sending callbacks to multiple ImageWindows in parallel */
339
340         gint has_frame;
341
342         /* top level (not necessarily parent) window */
343         gint top_window_sync;   /* resize top_window when image dimensions change */
344         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
345         gchar *title;           /* window title to display left of file name */
346         gchar *title_right;     /* window title to display right of file name */
347         gint title_show_zoom;   /* option to include zoom in window title */
348
349         gint completed;
350         ImageState state;       /* mask of IMAGE_STATE_* flags about current image */
351
352         void (*func_update)(ImageWindow *imd, gpointer data);
353         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
354         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
355         ImageTileRequestFunc func_tile_request;
356         ImageTileDisposeFunc func_tile_dispose;
357
358         gpointer data_update;
359         gpointer data_complete;
360         gpointer data_state;
361         gpointer data_tile;
362
363         /* button, scroll functions */
364         void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer);
365         void (*func_drag)(ImageWindow *, GdkEventButton *event, gdouble dx, gdouble dy, gpointer);
366         void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer);
367
368         gpointer data_button;
369         gpointer data_drag;
370         gpointer data_scroll;
371
372         /* scroll notification (for scroll bar implementation) */
373         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
374
375         gpointer data_scroll_notify;
376
377         /* collection info */
378         CollectionData *collection;
379         CollectInfo *collection_info;
380
381         /* color profiles */
382         gint color_profile_enable;
383         gint color_profile_input;
384         gint color_profile_screen;
385         gint color_profile_use_image;
386         gint color_profile_from_image;
387         gpointer cm;
388
389         AlterType delay_alter_type;
390
391         FileData *read_ahead_fd;
392         ImageLoader *read_ahead_il;
393
394         gint prev_color_row;
395
396         gint auto_refresh;
397
398         gint delay_flip;
399         gint orientation;
400         gint desaturate;
401
402         gint overlay_show_zoom; /* set to true if overlay is showing zoom ratio */
403 };
404
405 #define FILEDATA_MARKS_SIZE 6
406
407 struct _FileDataChangeInfo {
408         FileDataChangeType type;
409         gchar *source;
410         gchar *dest;
411         gint error;
412 };
413
414 struct _FileData {
415         gint magick;
416         gint type;
417         gchar *original_path; /* key to file_data_pool hash table */
418         gchar *path;
419         const gchar *name;
420         const gchar *extension;
421         gchar *collate_key_name;
422         gchar *collate_key_name_nocase;
423         gint64 size;
424         time_t date;
425         mode_t mode; /* this is needed at least for notification in view_dir because it is preserved after the file/directory is deleted */
426         guint marks;
427         GList *sidecar_files;
428         FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
429         FileDataChangeInfo *change; /* for rename, move ... */
430         GdkPixbuf *thumb_pixbuf;
431
432         GdkPixbuf *pixbuf; /* full-size image, only complete images, NULL during loading
433                               all FileData with non-NULL pixbuf are referenced by image_cache */
434
435         gint ref;
436         gint version; /* increased when any field in this structure is changed */
437         gint disable_grouping;
438
439         gint user_orientation;
440         gint exif_orientation;
441         
442         ExifData *exif;
443         GHashTable *modified_xmp; // hash table which contains unwritten xmp metadata in format: key->list of string values
444 };
445
446 struct _LayoutWindow
447 {
448         FileData *dir_fd;
449
450         /* base */
451
452         GtkWidget *window;
453
454         GtkWidget *main_box;
455
456         GtkWidget *group_box;
457         GtkWidget *h_pane;
458         GtkWidget *v_pane;
459
460         /* menus, path selector */
461
462         GtkActionGroup *action_group;
463         GtkUIManager *ui_manager;
464
465         GtkWidget *path_entry;
466
467         /* image */
468
469         LayoutLocation image_location;
470
471         ImageWindow *image;
472
473         ImageWindow *split_images[MAX_SPLIT_IMAGES];
474         ImageSplitMode split_mode;
475         gint active_split_image;
476
477         GtkWidget *split_image_widget;
478         GtkSizeGroup *split_image_sizegroup;
479
480         /* tools window (float) */
481
482         GtkWidget *tools;
483         GtkWidget *tools_pane;
484
485         gint tools_float;
486         gint tools_hidden;
487
488         /* toolbar */
489
490         GtkWidget *toolbar;
491         gint toolbar_hidden;
492
493         GtkWidget *thumb_button;
494         gint thumbs_enabled;
495         gint marks_enabled;
496
497         GtkWidget *back_button;
498
499         /* dir view */
500
501         LayoutLocation dir_location;
502
503         ViewDir *vd;
504         GtkWidget *dir_view;
505
506         DirViewType dir_view_type;
507
508         /* file view */
509
510         LayoutLocation file_location;
511
512         ViewFile *vf;
513         FileViewType file_view_type;
514
515         GtkWidget *file_view;
516
517         SortType sort_method;
518         gint sort_ascend;
519
520         /* status bar */
521
522         GtkWidget *info_box;
523         GtkWidget *info_progress_bar;
524         GtkWidget *info_sort;
525         GtkWidget *info_color;
526         GtkWidget *info_status;
527         GtkWidget *info_details;
528         GtkWidget *info_zoom;
529
530         /* slide show */
531
532         SlideShowData *slideshow;
533
534         /* full screen */
535
536         FullScreenData *full_screen;
537
538         /* dividers */
539
540         gint div_h;
541         gint div_v;
542         gint div_float;
543
544         /* misc */
545
546         GtkWidget *utility_box;
547         GtkWidget *bar_sort;
548         GtkWidget *bar_exif;
549         GtkWidget *bar_info;
550
551         gint bar_sort_enabled;
552         gint bar_exif_enabled;
553         gint bar_info_enabled;
554
555         gint bar_exif_width;
556         gint bar_exif_advanced;
557         gint bar_info_width;
558 };
559
560 struct _ViewDir
561 {
562         DirViewType type;
563         gpointer info;
564
565         GtkWidget *widget;
566         GtkWidget *view;
567
568         FileData *dir_fd;
569
570         FileData *click_fd;
571
572         FileData *drop_fd;
573         GList *drop_list;
574         gint drop_scroll_id;
575
576         /* func list */
577         void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
578         gpointer select_data;
579
580         void (*dnd_drop_update_func)(ViewDir *vd);
581         void (*dnd_drop_leave_func)(ViewDir *vd);
582
583         LayoutWindow *layout;
584
585         GtkWidget *popup;
586
587         PixmapFolders *pf;
588 };
589
590 struct _ViewDirInfoList
591 {
592         GList *list;
593 };
594
595 struct _ViewDirInfoTree
596 {
597         gint drop_expand_id;
598         gint busy_ref;
599 };
600
601
602 struct _ViewFile
603 {
604         FileViewType type;
605         gpointer info;
606
607         GtkWidget *widget;
608         GtkWidget *listview;
609         GtkWidget *scrolled;
610         GtkWidget *filter;
611         GtkWidget *filter_check[FILEDATA_MARKS_SIZE];
612
613         FileData *dir_fd;
614         GList *list;
615
616         SortType sort_method;
617         gint sort_ascend;
618
619         /* func list */
620         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
621         gpointer data_thumb_status;
622
623         void (*func_status)(ViewFile *vf, gpointer data);
624         gpointer data_status;
625
626         LayoutWindow *layout;
627
628         GtkWidget *popup;
629
630         /* thumbs updates*/
631         gint thumbs_running;
632         ThumbLoader *thumbs_loader;
633         FileData *thumbs_filedata;
634
635         /* marks */
636         gint marks_enabled;
637         gint active_mark;
638         gint clicked_mark;
639         
640         /* refresh */
641         gint refresh_idle_id;
642 };
643
644 struct _ViewFileInfoList
645 {
646         FileData *click_fd;
647         FileData *select_fd;
648
649         gint thumbs_enabled;
650
651         gint select_idle_id;
652 };
653
654 struct _IconData;
655
656 struct _ViewFileInfoIcon
657 {
658         /* table stuff */
659         gint columns;
660         gint rows;
661
662         GList *selection;
663         struct _IconData *prev_selection;
664
665         GtkWidget *tip_window;
666         gint tip_delay_id;
667         struct _IconData *tip_id;
668
669         struct _IconData *click_id;
670
671         struct _IconData *focus_id;
672         gint focus_row;
673         gint focus_column;
674
675         gint show_text;
676 };
677
678 struct _SlideShowData
679 {
680         ImageWindow *imd;
681
682         GList *filelist;
683         CollectionData *cd;
684         FileData *dir_fd;
685         LayoutWindow *layout;
686
687         GList *list;
688         GList *list_done;
689
690         FileData *slide_fd;
691
692         guint slide_count;
693         gint timeout_id;
694
695         gint from_selection;
696
697         void (*stop_func)(SlideShowData *, gpointer);
698         gpointer stop_data;
699
700         gint paused;
701 };
702
703 struct _FullScreenData
704 {
705         GtkWidget *window;
706         ImageWindow *imd;
707
708         GtkWidget *normal_window;
709         ImageWindow *normal_imd;
710
711         gint hide_mouse_id;
712         gint busy_mouse_id;
713         gint cursor_state;
714
715         gint saver_block_id;
716
717         void (*stop_func)(FullScreenData *, gpointer);
718         gpointer stop_data;
719 };
720
721 struct _PixmapFolders
722 {
723         GdkPixbuf *close;
724         GdkPixbuf *open;
725         GdkPixbuf *deny;
726         GdkPixbuf *parent;
727 };
728
729 struct _SecureSaveInfo {
730         FILE *fp; /**< file stream pointer */
731         gchar *file_name; /**< final file name */
732         gchar *tmp_file_name; /**< temporary file name */
733         gint err; /**< set to non-zero value in case of error */
734         gint secure_save; /**< use secure save for this file, internal use only */
735         gint preserve_perms; /**< whether to preserve perms, TRUE by default */
736         gint preserve_mtime; /**< whether to preserve mtime, FALSE by default */
737         gint unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
738 };
739
740
741 #endif
742 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */