use SHIFT for connected scroll and zoom
[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 };
444
445 struct _LayoutWindow
446 {
447         FileData *dir_fd;
448
449         /* base */
450
451         GtkWidget *window;
452
453         GtkWidget *main_box;
454
455         GtkWidget *group_box;
456         GtkWidget *h_pane;
457         GtkWidget *v_pane;
458
459         /* menus, path selector */
460
461         GtkActionGroup *action_group;
462         GtkUIManager *ui_manager;
463
464         GtkWidget *path_entry;
465
466         /* image */
467
468         LayoutLocation image_location;
469
470         ImageWindow *image;
471
472         ImageWindow *split_images[MAX_SPLIT_IMAGES];
473         ImageSplitMode split_mode;
474         gint active_split_image;
475
476         GtkWidget *split_image_widget;
477         GtkSizeGroup *split_image_sizegroup;
478
479         /* tools window (float) */
480
481         GtkWidget *tools;
482         GtkWidget *tools_pane;
483
484         gint tools_float;
485         gint tools_hidden;
486
487         /* toolbar */
488
489         GtkWidget *toolbar;
490         gint toolbar_hidden;
491
492         GtkWidget *thumb_button;
493         gint thumbs_enabled;
494         gint marks_enabled;
495
496         /* dir view */
497
498         LayoutLocation dir_location;
499
500         ViewDir *vd;
501         GtkWidget *dir_view;
502
503         DirViewType dir_view_type;
504
505         /* file view */
506
507         LayoutLocation file_location;
508
509         ViewFile *vf;
510         FileViewType file_view_type;
511
512         GtkWidget *file_view;
513
514         SortType sort_method;
515         gint sort_ascend;
516
517         /* status bar */
518
519         GtkWidget *info_box;
520         GtkWidget *info_progress_bar;
521         GtkWidget *info_sort;
522         GtkWidget *info_color;
523         GtkWidget *info_status;
524         GtkWidget *info_details;
525         GtkWidget *info_zoom;
526
527         /* slide show */
528
529         SlideShowData *slideshow;
530
531         /* full screen */
532
533         FullScreenData *full_screen;
534
535         /* dividers */
536
537         gint div_h;
538         gint div_v;
539         gint div_float;
540
541         /* misc */
542
543         GtkWidget *utility_box;
544         GtkWidget *bar_sort;
545         GtkWidget *bar_exif;
546         GtkWidget *bar_info;
547
548         gint bar_sort_enabled;
549         gint bar_exif_enabled;
550         gint bar_info_enabled;
551
552         gint bar_exif_width;
553         gint bar_exif_advanced;
554         gint bar_info_width;
555 };
556
557 struct _ViewDir
558 {
559         DirViewType type;
560         gpointer info;
561
562         GtkWidget *widget;
563         GtkWidget *view;
564
565         FileData *dir_fd;
566
567         FileData *click_fd;
568
569         FileData *drop_fd;
570         GList *drop_list;
571         gint drop_scroll_id;
572
573         /* func list */
574         void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
575         gpointer select_data;
576
577         void (*dnd_drop_update_func)(ViewDir *vd);
578         void (*dnd_drop_leave_func)(ViewDir *vd);
579
580         LayoutWindow *layout;
581
582         GtkWidget *popup;
583
584         PixmapFolders *pf;
585 };
586
587 struct _ViewDirInfoList
588 {
589         GList *list;
590 };
591
592 struct _ViewDirInfoTree
593 {
594         gint drop_expand_id;
595         gint busy_ref;
596 };
597
598
599 struct _ViewFile
600 {
601         FileViewType type;
602         gpointer info;
603
604         GtkWidget *widget;
605         GtkWidget *listview;
606         GtkWidget *scrolled;
607         GtkWidget *filter;
608         GtkWidget *filter_check[FILEDATA_MARKS_SIZE];
609
610         FileData *dir_fd;
611         GList *list;
612
613         SortType sort_method;
614         gint sort_ascend;
615
616         /* func list */
617         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
618         gpointer data_thumb_status;
619
620         void (*func_status)(ViewFile *vf, gpointer data);
621         gpointer data_status;
622
623         LayoutWindow *layout;
624
625         GtkWidget *popup;
626
627         /* thumbs updates*/
628         gint thumbs_running;
629         ThumbLoader *thumbs_loader;
630         FileData *thumbs_filedata;
631
632         /* marks */
633         gint marks_enabled;
634         gint active_mark;
635         gint clicked_mark;
636         
637         /* refresh */
638         gint refresh_idle_id;
639 };
640
641 struct _ViewFileInfoList
642 {
643         FileData *click_fd;
644         FileData *select_fd;
645
646         gint thumbs_enabled;
647
648         gint select_idle_id;
649 };
650
651 struct _IconData;
652
653 struct _ViewFileInfoIcon
654 {
655         /* table stuff */
656         gint columns;
657         gint rows;
658
659         GList *selection;
660         struct _IconData *prev_selection;
661
662         GtkWidget *tip_window;
663         gint tip_delay_id;
664         struct _IconData *tip_id;
665
666         struct _IconData *click_id;
667
668         struct _IconData *focus_id;
669         gint focus_row;
670         gint focus_column;
671
672         gint show_text;
673 };
674
675 struct _SlideShowData
676 {
677         ImageWindow *imd;
678
679         GList *filelist;
680         CollectionData *cd;
681         FileData *dir_fd;
682         LayoutWindow *layout;
683
684         GList *list;
685         GList *list_done;
686
687         FileData *slide_fd;
688
689         guint slide_count;
690         gint timeout_id;
691
692         gint from_selection;
693
694         void (*stop_func)(SlideShowData *, gpointer);
695         gpointer stop_data;
696
697         gint paused;
698 };
699
700 struct _FullScreenData
701 {
702         GtkWidget *window;
703         ImageWindow *imd;
704
705         GtkWidget *normal_window;
706         ImageWindow *normal_imd;
707
708         gint hide_mouse_id;
709         gint busy_mouse_id;
710         gint cursor_state;
711
712         gint saver_block_id;
713
714         void (*stop_func)(FullScreenData *, gpointer);
715         gpointer stop_data;
716 };
717
718 struct _PixmapFolders
719 {
720         GdkPixbuf *close;
721         GdkPixbuf *open;
722         GdkPixbuf *deny;
723         GdkPixbuf *parent;
724 };
725
726 struct _SecureSaveInfo {
727         FILE *fp; /**< file stream pointer */
728         gchar *file_name; /**< final file name */
729         gchar *tmp_file_name; /**< temporary file name */
730         gint err; /**< set to non-zero value in case of error */
731         gint secure_save; /**< use secure save for this file, internal use only */
732         gint preserve_perms; /**< whether to preserve perms, TRUE by default */
733         gint preserve_mtime; /**< whether to preserve mtime, FALSE by default */
734         gint unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
735 };
736
737
738 #endif