Use a specific enum for image.zoom_mode values (ZoomMode) and
[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         gint64 size;            /* file size (bytes) */
355         time_t mtime;           /* file modified time stamp */
356         gint unknown;           /* failed to load image */
357
358         ImageLoader *il;        /* FIXME - image loader should probably go to FileData, but it must first support
359                                    sending callbacks to multiple ImageWindows in parallel */
360
361         gint has_frame;
362
363         /* top level (not necessarily parent) window */
364         gint top_window_sync;   /* resize top_window when image dimensions change */
365         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
366         gchar *title;           /* window title to display left of file name */
367         gchar *title_right;     /* window title to display right of file name */
368         gint title_show_zoom;   /* option to include zoom in window title */
369
370         gint completed;
371         ImageState state;       /* mask of IMAGE_STATE_* flags about current image */
372
373         void (*func_update)(ImageWindow *imd, gpointer data);
374         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
375         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
376         ImageTileRequestFunc func_tile_request;
377         ImageTileDisposeFunc func_tile_dispose;
378
379         gpointer data_update;
380         gpointer data_complete;
381         gpointer data_state;
382         gpointer data_tile;
383
384         /* button, scroll functions */
385         void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer);
386         void (*func_drag)(ImageWindow *, GdkEventButton *event, gdouble dx, gdouble dy, gpointer);
387         void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer);
388
389         gpointer data_button;
390         gpointer data_drag;
391         gpointer data_scroll;
392
393         /* scroll notification (for scroll bar implementation) */
394         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
395
396         gpointer data_scroll_notify;
397
398         /* collection info */
399         CollectionData *collection;
400         CollectInfo *collection_info;
401
402         /* color profiles */
403         gint color_profile_enable;
404         gint color_profile_input;
405         gint color_profile_screen;
406         gint color_profile_use_image;
407         gint color_profile_from_image;
408         gpointer cm;
409
410         AlterType delay_alter_type;
411
412         FileData *read_ahead_fd;
413         ImageLoader *read_ahead_il;
414
415         gint prev_color_row;
416
417         gint auto_refresh_id;
418         gint auto_refresh_interval;
419
420         gint delay_flip;
421         gint orientation;
422         gint desaturate;
423
424         gint overlay_show_zoom; /* set to true if overlay is showing zoom ratio */
425 };
426
427 #define FILEDATA_MARKS_SIZE 6
428
429 struct _FileDataChangeInfo {
430         FileDataChangeType type;
431         gchar *source;
432         gchar *dest;
433 };
434
435 struct _FileData {
436         gint magick;
437         gint type;
438         gchar *original_path; /* key to file_data_pool hash table */
439         gchar *path;
440         const gchar *name;
441         const gchar *extension;
442         gchar *collate_key_name;
443         gchar *collate_key_name_nocase;
444         gint64 size;
445         time_t date;
446         guint marks;
447         GList *sidecar_files;
448         FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
449         FileDataChangeInfo *change; /* for rename, move ... */
450         GdkPixbuf *thumb_pixbuf;
451
452         GdkPixbuf *pixbuf; /* full-size image, only complete images, NULL during loading
453                               all FileData with non-NULL pixbuf are referenced by image_cache */
454
455         gint ref;
456         gint version; /* increased when any field in this structure is changed */
457         gint disable_grouping;
458
459         gint user_orientation;
460         gint exif_orientation;
461         
462         ExifData *exif;
463 };
464
465 struct _LayoutWindow
466 {
467         FileData *dir_fd;
468
469         /* base */
470
471         GtkWidget *window;
472
473         GtkWidget *main_box;
474
475         GtkWidget *group_box;
476         GtkWidget *h_pane;
477         GtkWidget *v_pane;
478
479         /* menus, path selector */
480
481         GtkActionGroup *action_group;
482         GtkUIManager *ui_manager;
483
484         GtkWidget *path_entry;
485
486         /* image */
487
488         LayoutLocation image_location;
489
490         ImageWindow *image;
491
492         ImageWindow *split_images[MAX_SPLIT_IMAGES];
493         ImageSplitMode split_mode;
494         gint active_split_image;
495
496         GtkWidget *split_image_widget;
497         GtkSizeGroup *split_image_sizegroup;
498
499         gint connect_zoom, connect_scroll;
500
501         /* tools window (float) */
502
503         GtkWidget *tools;
504         GtkWidget *tools_pane;
505
506         gint tools_float;
507         gint tools_hidden;
508
509         /* toolbar */
510
511         GtkWidget *toolbar;
512         gint toolbar_hidden;
513
514         GtkWidget *thumb_button;
515         gint thumbs_enabled;
516         gint marks_enabled;
517
518         /* dir view */
519
520         LayoutLocation dir_location;
521
522         ViewDir *vd;
523         GtkWidget *dir_view;
524
525         DirViewType dir_view_type;
526
527         /* file view */
528
529         LayoutLocation file_location;
530
531         ViewFile *vf;
532         FileViewType file_view_type;
533
534         GtkWidget *file_view;
535
536         SortType sort_method;
537         gint sort_ascend;
538
539         /* status bar */
540
541         GtkWidget *info_box;
542         GtkWidget *info_progress_bar;
543         GtkWidget *info_sort;
544         GtkWidget *info_color;
545         GtkWidget *info_status;
546         GtkWidget *info_details;
547         GtkWidget *info_zoom;
548
549         /* slide show */
550
551         SlideShowData *slideshow;
552
553         /* full screen */
554
555         FullScreenData *full_screen;
556
557         /* dividers */
558
559         gint div_h;
560         gint div_v;
561         gint div_float;
562
563         /* misc */
564
565         GtkWidget *utility_box;
566         GtkWidget *bar_sort;
567         GtkWidget *bar_exif;
568         GtkWidget *bar_info;
569
570         gint bar_sort_enabled;
571         gint bar_exif_enabled;
572         gint bar_info_enabled;
573
574         gint bar_exif_width;
575         gint bar_exif_advanced;
576         gint bar_info_width;
577 };
578
579 struct _ViewDir
580 {
581         DirViewType type;
582         gpointer info;
583
584         GtkWidget *widget;
585         GtkWidget *view;
586
587         FileData *dir_fd;
588
589         FileData *click_fd;
590
591         FileData *drop_fd;
592         GList *drop_list;
593         gint drop_scroll_id;
594
595         /* func list */
596         void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
597         gpointer select_data;
598
599         void (*dnd_drop_update_func)(ViewDir *vd);
600         void (*dnd_drop_leave_func)(ViewDir *vd);
601
602         LayoutWindow *layout;
603
604         GtkWidget *popup;
605
606         PixmapFolders *pf;
607 };
608
609 struct _ViewDirInfoList
610 {
611         GList *list;
612 };
613
614 struct _ViewDirInfoTree
615 {
616         gint drop_expand_id;
617         gint busy_ref;
618 };
619
620
621 struct _ViewFile
622 {
623         FileViewType type;
624         gpointer info;
625
626         GtkWidget *widget;
627         GtkWidget *listview;
628
629         FileData *dir_fd;
630         GList *list;
631
632         SortType sort_method;
633         gint sort_ascend;
634
635         /* func list */
636         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
637         gpointer data_thumb_status;
638
639         void (*func_status)(ViewFile *vf, gpointer data);
640         gpointer data_status;
641
642         LayoutWindow *layout;
643
644         GtkWidget *popup;
645
646         /* thumbs updates*/
647         gint thumbs_running;
648         ThumbLoader *thumbs_loader;
649         FileData *thumbs_filedata;
650
651         /* marks */
652         gint marks_enabled;
653         gint active_mark;
654         gint clicked_mark;
655         
656         /* refresh */
657         gint refresh_idle_id;
658 };
659
660 struct _ViewFileInfoList
661 {
662         FileData *click_fd;
663         FileData *select_fd;
664
665         gint thumbs_enabled;
666
667         gint select_idle_id;
668 };
669
670 struct _IconData;
671
672 struct _ViewFileInfoIcon
673 {
674         /* table stuff */
675         gint columns;
676         gint rows;
677
678         GList *selection;
679         struct _IconData *prev_selection;
680
681         GtkWidget *tip_window;
682         gint tip_delay_id;
683         struct _IconData *tip_id;
684
685         struct _IconData *click_id;
686
687         struct _IconData *focus_id;
688         gint focus_row;
689         gint focus_column;
690
691         gint show_text;
692 };
693
694 struct _SlideShowData
695 {
696         ImageWindow *imd;
697
698         GList *filelist;
699         CollectionData *cd;
700         FileData *dir_fd;
701         LayoutWindow *layout;
702
703         GList *list;
704         GList *list_done;
705
706         FileData *slide_fd;
707
708         guint slide_count;
709         gint timeout_id;
710
711         gint from_selection;
712
713         void (*stop_func)(SlideShowData *, gpointer);
714         gpointer stop_data;
715
716         gint paused;
717 };
718
719 struct _FullScreenData
720 {
721         GtkWidget *window;
722         ImageWindow *imd;
723
724         GtkWidget *normal_window;
725         ImageWindow *normal_imd;
726
727         gint hide_mouse_id;
728         gint busy_mouse_id;
729         gint cursor_state;
730
731         gint saver_block_id;
732
733         void (*stop_func)(FullScreenData *, gpointer);
734         gpointer stop_data;
735 };
736
737 struct _PixmapFolders
738 {
739         GdkPixbuf *close;
740         GdkPixbuf *open;
741         GdkPixbuf *deny;
742         GdkPixbuf *parent;
743 };
744
745 struct _SecureSaveInfo {
746         FILE *fp; /**< file stream pointer */
747         gchar *file_name; /**< final file name */
748         gchar *tmp_file_name; /**< temporary file name */
749         gint err; /**< set to non-zero value in case of error */
750         gint secure_save; /**< use secure save for this file, internal use only */
751         gint preserve_perms; /**< whether to preserve perms, TRUE by default */
752         gint preserve_mtime; /**< whether to preserve mtime, FALSE by default */
753         gint unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
754 };
755
756
757 #endif