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