reload changed images
[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
153 #define MAX_SPLIT_IMAGES 4
154
155 typedef struct _ImageLoader ImageLoader;
156 typedef struct _ThumbLoader ThumbLoader;
157
158 typedef struct _CollectInfo CollectInfo;
159 typedef struct _CollectionData CollectionData;
160 typedef struct _CollectTable CollectTable;
161 typedef struct _CollectWindow CollectWindow;
162
163 typedef struct _ImageWindow ImageWindow;
164
165 typedef struct _FileData FileData;
166 typedef struct _FileDataChangeInfo FileDataChangeInfo;
167
168 typedef struct _LayoutWindow LayoutWindow;
169
170 typedef struct _ViewDir ViewDir;
171 typedef struct _ViewDirInfoList ViewDirInfoList;
172 typedef struct _ViewDirInfoTree ViewDirInfoTree;
173
174 typedef struct _ViewFile ViewFile;
175 typedef struct _ViewFileInfoList ViewFileInfoList;
176 typedef struct _ViewFileInfoIcon ViewFileInfoIcon;
177
178 typedef struct _SlideShowData SlideShowData;
179 typedef struct _FullScreenData FullScreenData;
180
181 typedef struct _PixmapFolders PixmapFolders;
182 typedef struct _Histogram Histogram;
183
184 typedef struct _SecureSaveInfo SecureSaveInfo;
185
186 typedef struct _ExifData ExifData;
187
188 typedef struct _Editor Editor;
189 struct _Editor {
190         gchar *name;
191         gchar *command;
192 };
193
194 struct _ImageLoader
195 {
196         GdkPixbuf *pixbuf;
197         FileData *fd;
198         gchar *path;
199
200         gint bytes_read;
201         gint bytes_total;
202
203         gint requested_width;
204         gint requested_height;
205         gint shrunk;
206
207         gint done;
208         gint idle_id;
209         gint idle_priority;
210
211         GdkPixbufLoader *loader;
212         gint load_fd;
213
214         void (*func_area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
215         void (*func_error)(ImageLoader *, gpointer);
216         void (*func_done)(ImageLoader *, gpointer);
217         void (*func_percent)(ImageLoader *, gdouble, gpointer);
218
219         gpointer data_area_ready;
220         gpointer data_error;
221         gpointer data_done;
222         gpointer data_percent;
223
224         gint idle_done_id;
225
226         guchar *read_buffer;
227         gint read_buffer_size;
228         gint idle_read_loop_count;
229 };
230
231 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
232
233 struct _ThumbLoader
234 {
235         gint standard_loader;
236
237         ImageLoader *il;
238         FileData *fd;           /* fd->pixbuf contains final (scaled) image when done */
239
240         gint cache_enable;
241         gint cache_hit;
242         gdouble percent_done;
243
244         gint max_w;
245         gint max_h;
246
247         ThumbLoaderFunc func_done;
248         ThumbLoaderFunc func_error;
249         ThumbLoaderFunc func_progress;
250
251         gpointer data;
252
253         gint idle_done_id;
254 };
255
256 struct _CollectInfo
257 {
258         FileData *fd;
259         GdkPixbuf *pixbuf;
260         guint flag_mask;
261 };
262
263 struct _CollectionData
264 {
265         gchar *path;
266         gchar *name;
267         GList *list;
268         SortType sort_method;
269
270         ThumbLoader *thumb_loader;
271         CollectInfo *thumb_info;
272
273         void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
274         gpointer info_updated_data;
275
276         gint ref;
277
278         /* geometry */
279         gint window_read;
280         gint window_x;
281         gint window_y;
282         gint window_w;
283         gint window_h;
284
285         /* contents changed since save flag */
286         gint changed;
287
288         GHashTable *existence;
289 };
290
291 struct _CollectTable
292 {
293         GtkWidget *scrolled;
294         GtkWidget *listview;
295         gint columns;
296         gint rows;
297
298         CollectionData *cd;
299
300         GList *selection;
301         CollectInfo *prev_selection;
302
303         CollectInfo *click_info;
304
305         GtkWidget *tip_window;
306         gint tip_delay_id;
307         CollectInfo *tip_info;
308
309         GdkWindow *marker_window;
310         CollectInfo *marker_info;
311
312         GtkWidget *status_label;
313         GtkWidget *extra_label;
314
315         gint focus_row;
316         gint focus_column;
317         CollectInfo *focus_info;
318
319         GtkWidget *popup;
320         CollectInfo *drop_info;
321         GList *drop_list;
322
323         gint sync_idle_id;
324         gint drop_idle_id;
325
326         gint show_text;
327 };
328
329 struct _CollectWindow
330 {
331         GtkWidget *window;
332         CollectTable *table;
333         GtkWidget *status_box;
334         GList *list;
335
336         GtkWidget *close_dialog;
337
338         CollectionData *cd;
339 };
340
341 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
342                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
343 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
344                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
345
346 struct _ImageWindow
347 {
348         GtkWidget *widget;      /* use this to add it and show it */
349         GtkWidget *pr;
350         GtkWidget *frame;
351
352         FileData *image_fd;
353
354         gint unknown;           /* failed to load image */
355
356         ImageLoader *il;        /* FIXME - image loader should probably go to FileData, but it must first support
357                                    sending callbacks to multiple ImageWindows in parallel */
358
359         gint has_frame;
360
361         /* top level (not necessarily parent) window */
362         gint top_window_sync;   /* resize top_window when image dimensions change */
363         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
364         gchar *title;           /* window title to display left of file name */
365         gchar *title_right;     /* window title to display right of file name */
366         gint title_show_zoom;   /* option to include zoom in window title */
367
368         gint completed;
369         ImageState state;       /* mask of IMAGE_STATE_* flags about current image */
370
371         void (*func_update)(ImageWindow *imd, gpointer data);
372         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
373         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
374         ImageTileRequestFunc func_tile_request;
375         ImageTileDisposeFunc func_tile_dispose;
376
377         gpointer data_update;
378         gpointer data_complete;
379         gpointer data_state;
380         gpointer data_tile;
381
382         /* button, scroll functions */
383         void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer);
384         void (*func_drag)(ImageWindow *, GdkEventButton *event, gdouble dx, gdouble dy, gpointer);
385         void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer);
386
387         gpointer data_button;
388         gpointer data_drag;
389         gpointer data_scroll;
390
391         /* scroll notification (for scroll bar implementation) */
392         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
393
394         gpointer data_scroll_notify;
395
396         /* collection info */
397         CollectionData *collection;
398         CollectInfo *collection_info;
399
400         /* color profiles */
401         gint color_profile_enable;
402         gint color_profile_input;
403         gint color_profile_screen;
404         gint color_profile_use_image;
405         gint color_profile_from_image;
406         gpointer cm;
407
408         AlterType delay_alter_type;
409
410         FileData *read_ahead_fd;
411         ImageLoader *read_ahead_il;
412
413         gint prev_color_row;
414
415         gint auto_refresh;
416
417         gint delay_flip;
418         gint orientation;
419         gint desaturate;
420
421         gint overlay_show_zoom; /* set to true if overlay is showing zoom ratio */
422 };
423
424 #define FILEDATA_MARKS_SIZE 6
425
426 struct _FileDataChangeInfo {
427         FileDataChangeType type;
428         gchar *source;
429         gchar *dest;
430 };
431
432 struct _FileData {
433         gint magick;
434         gint type;
435         gchar *original_path; /* key to file_data_pool hash table */
436         gchar *path;
437         const gchar *name;
438         const gchar *extension;
439         gchar *collate_key_name;
440         gchar *collate_key_name_nocase;
441         gint64 size;
442         time_t date;
443         guint marks;
444         GList *sidecar_files;
445         FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
446         FileDataChangeInfo *change; /* for rename, move ... */
447         GdkPixbuf *thumb_pixbuf;
448
449         GdkPixbuf *pixbuf; /* full-size image, only complete images, NULL during loading
450                               all FileData with non-NULL pixbuf are referenced by image_cache */
451
452         gint ref;
453         gint version; /* increased when any field in this structure is changed */
454         gint disable_grouping;
455
456         gint user_orientation;
457         gint exif_orientation;
458         
459         ExifData *exif;
460 };
461
462 struct _LayoutWindow
463 {
464         FileData *dir_fd;
465
466         /* base */
467
468         GtkWidget *window;
469
470         GtkWidget *main_box;
471
472         GtkWidget *group_box;
473         GtkWidget *h_pane;
474         GtkWidget *v_pane;
475
476         /* menus, path selector */
477
478         GtkActionGroup *action_group;
479         GtkUIManager *ui_manager;
480
481         GtkWidget *path_entry;
482
483         /* image */
484
485         LayoutLocation image_location;
486
487         ImageWindow *image;
488
489         ImageWindow *split_images[MAX_SPLIT_IMAGES];
490         ImageSplitMode split_mode;
491         gint active_split_image;
492
493         GtkWidget *split_image_widget;
494         GtkSizeGroup *split_image_sizegroup;
495
496         gint connect_zoom, connect_scroll;
497
498         /* tools window (float) */
499
500         GtkWidget *tools;
501         GtkWidget *tools_pane;
502
503         gint tools_float;
504         gint tools_hidden;
505
506         /* toolbar */
507
508         GtkWidget *toolbar;
509         gint toolbar_hidden;
510
511         GtkWidget *thumb_button;
512         gint thumbs_enabled;
513         gint marks_enabled;
514
515         /* dir view */
516
517         LayoutLocation dir_location;
518
519         ViewDir *vd;
520         GtkWidget *dir_view;
521
522         DirViewType dir_view_type;
523
524         /* file view */
525
526         LayoutLocation file_location;
527
528         ViewFile *vf;
529         FileViewType file_view_type;
530
531         GtkWidget *file_view;
532
533         SortType sort_method;
534         gint sort_ascend;
535
536         /* status bar */
537
538         GtkWidget *info_box;
539         GtkWidget *info_progress_bar;
540         GtkWidget *info_sort;
541         GtkWidget *info_color;
542         GtkWidget *info_status;
543         GtkWidget *info_details;
544         GtkWidget *info_zoom;
545
546         /* slide show */
547
548         SlideShowData *slideshow;
549
550         /* full screen */
551
552         FullScreenData *full_screen;
553
554         /* dividers */
555
556         gint div_h;
557         gint div_v;
558         gint div_float;
559
560         /* misc */
561
562         GtkWidget *utility_box;
563         GtkWidget *bar_sort;
564         GtkWidget *bar_exif;
565         GtkWidget *bar_info;
566
567         gint bar_sort_enabled;
568         gint bar_exif_enabled;
569         gint bar_info_enabled;
570
571         gint bar_exif_width;
572         gint bar_exif_advanced;
573         gint bar_info_width;
574 };
575
576 struct _ViewDir
577 {
578         DirViewType type;
579         gpointer info;
580
581         GtkWidget *widget;
582         GtkWidget *view;
583
584         FileData *dir_fd;
585
586         FileData *click_fd;
587
588         FileData *drop_fd;
589         GList *drop_list;
590         gint drop_scroll_id;
591
592         /* func list */
593         void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
594         gpointer select_data;
595
596         void (*dnd_drop_update_func)(ViewDir *vd);
597         void (*dnd_drop_leave_func)(ViewDir *vd);
598
599         LayoutWindow *layout;
600
601         GtkWidget *popup;
602
603         PixmapFolders *pf;
604 };
605
606 struct _ViewDirInfoList
607 {
608         GList *list;
609 };
610
611 struct _ViewDirInfoTree
612 {
613         gint drop_expand_id;
614         gint busy_ref;
615 };
616
617
618 struct _ViewFile
619 {
620         FileViewType type;
621         gpointer info;
622
623         GtkWidget *widget;
624         GtkWidget *listview;
625
626         FileData *dir_fd;
627         GList *list;
628
629         SortType sort_method;
630         gint sort_ascend;
631
632         /* func list */
633         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
634         gpointer data_thumb_status;
635
636         void (*func_status)(ViewFile *vf, gpointer data);
637         gpointer data_status;
638
639         LayoutWindow *layout;
640
641         GtkWidget *popup;
642
643         /* thumbs updates*/
644         gint thumbs_running;
645         ThumbLoader *thumbs_loader;
646         FileData *thumbs_filedata;
647
648         /* marks */
649         gint marks_enabled;
650         gint active_mark;
651         gint clicked_mark;
652         
653         /* refresh */
654         gint refresh_idle_id;
655 };
656
657 struct _ViewFileInfoList
658 {
659         FileData *click_fd;
660         FileData *select_fd;
661
662         gint thumbs_enabled;
663
664         gint select_idle_id;
665 };
666
667 struct _IconData;
668
669 struct _ViewFileInfoIcon
670 {
671         /* table stuff */
672         gint columns;
673         gint rows;
674
675         GList *selection;
676         struct _IconData *prev_selection;
677
678         GtkWidget *tip_window;
679         gint tip_delay_id;
680         struct _IconData *tip_id;
681
682         struct _IconData *click_id;
683
684         struct _IconData *focus_id;
685         gint focus_row;
686         gint focus_column;
687
688         gint show_text;
689 };
690
691 struct _SlideShowData
692 {
693         ImageWindow *imd;
694
695         GList *filelist;
696         CollectionData *cd;
697         FileData *dir_fd;
698         LayoutWindow *layout;
699
700         GList *list;
701         GList *list_done;
702
703         FileData *slide_fd;
704
705         guint slide_count;
706         gint timeout_id;
707
708         gint from_selection;
709
710         void (*stop_func)(SlideShowData *, gpointer);
711         gpointer stop_data;
712
713         gint paused;
714 };
715
716 struct _FullScreenData
717 {
718         GtkWidget *window;
719         ImageWindow *imd;
720
721         GtkWidget *normal_window;
722         ImageWindow *normal_imd;
723
724         gint hide_mouse_id;
725         gint busy_mouse_id;
726         gint cursor_state;
727
728         gint saver_block_id;
729
730         void (*stop_func)(FullScreenData *, gpointer);
731         gpointer stop_data;
732 };
733
734 struct _PixmapFolders
735 {
736         GdkPixbuf *close;
737         GdkPixbuf *open;
738         GdkPixbuf *deny;
739         GdkPixbuf *parent;
740 };
741
742 struct _SecureSaveInfo {
743         FILE *fp; /**< file stream pointer */
744         gchar *file_name; /**< final file name */
745         gchar *tmp_file_name; /**< temporary file name */
746         gint err; /**< set to non-zero value in case of error */
747         gint secure_save; /**< use secure save for this file, internal use only */
748         gint preserve_perms; /**< whether to preserve perms, TRUE by default */
749         gint preserve_mtime; /**< whether to preserve mtime, FALSE by default */
750         gint unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
751 };
752
753
754 #endif