a6ebb6b3a3d82d43faa079eb87ea1e1a35fb64b6
[geeqie.git] / src / typedefs.h
1 /*
2  * Geeqie
3  * (C) 2006 John Ellis
4  *
5  * Author: John Ellis
6  *
7  * This software is released under the GNU General Public License (GNU GPL).
8  * Please read the included file COPYING for more information.
9  * This software comes with no warranty of any kind, use at your own risk!
10  */
11
12
13 #ifndef TYPEDEFS_H
14 #define TYPEDEFS_H
15
16 typedef enum {
17         DIRVIEW_LIST,
18         DIRVIEW_TREE
19 } DirViewType;
20
21 typedef enum {
22         CMD_COPY = GQ_EDITOR_GENERIC_SLOTS,
23         CMD_MOVE,
24         CMD_RENAME,
25         CMD_DELETE,
26         CMD_FOLDER,
27         GQ_EDITOR_SLOTS
28 } SpecialEditor;
29
30 typedef enum {
31         SORT_NONE,
32         SORT_NAME,
33         SORT_SIZE,
34         SORT_TIME,
35         SORT_PATH,
36         SORT_NUMBER
37 } SortType;
38
39 typedef enum {
40         ALTER_NONE,             /* do nothing */
41         ALTER_ROTATE_90,
42         ALTER_ROTATE_90_CC,     /* counterclockwise */
43         ALTER_ROTATE_180,
44         ALTER_MIRROR,
45         ALTER_FLIP,
46         ALTER_DESATURATE
47 } AlterType;
48
49 typedef enum {
50         LAYOUT_HIDE   = 0,
51         LAYOUT_LEFT   = 1 << 0,
52         LAYOUT_RIGHT  = 1 << 1,
53         LAYOUT_TOP    = 1 << 2,
54         LAYOUT_BOTTOM = 1 << 3
55 } LayoutLocation;
56
57
58 typedef enum {
59         IMAGE_STATE_NONE        = 0,
60         IMAGE_STATE_IMAGE       = 1 << 0,
61         IMAGE_STATE_LOADING     = 1 << 1,
62         IMAGE_STATE_ERROR       = 1 << 2,
63         IMAGE_STATE_COLOR_ADJ   = 1 << 3,
64         IMAGE_STATE_ROTATE_AUTO = 1 << 4,
65         IMAGE_STATE_ROTATE_USER = 1 << 5,
66         IMAGE_STATE_DELAY_FLIP  = 1 << 6
67 } ImageState;
68
69 typedef enum {
70         SPLIT_NONE = 0,
71         SPLIT_VERT,
72         SPLIT_HOR,
73         SPLIT_QUAD,
74 } ImageSplitMode;
75
76 typedef enum {
77         FILEDATA_CHANGE_DELETE,
78         FILEDATA_CHANGE_MOVE,
79         FILEDATA_CHANGE_RENAME,
80         FILEDATA_CHANGE_COPY
81 } FileDataChangeType;
82
83 typedef enum {
84         MTS_MODE_MINUS,
85         MTS_MODE_SET,
86         MTS_MODE_OR,
87         MTS_MODE_AND
88 } MarkToSelectionMode;
89
90 typedef enum {
91         STM_MODE_RESET,
92         STM_MODE_SET,
93         STM_MODE_TOGGLE
94 } SelectionToMarkMode;
95
96 typedef enum {
97         FORMAT_CLASS_UNKNOWN,
98         FORMAT_CLASS_IMAGE,
99         FORMAT_CLASS_RAWIMAGE,
100         FORMAT_CLASS_META,
101         FILE_FORMAT_CLASSES
102 } FileFormatClass;
103
104 typedef enum {
105         SS_ERR_NONE = 0,
106         SS_ERR_DISABLED, /**< secsave is disabled. */
107         SS_ERR_OUT_OF_MEM, /**< memory allocation failure */
108
109         /* see err field in SecureSaveInfo */
110         SS_ERR_OPEN_READ,
111         SS_ERR_OPEN_WRITE,
112         SS_ERR_STAT,
113         SS_ERR_ACCESS,
114         SS_ERR_MKSTEMP,
115         SS_ERR_RENAME,
116         SS_ERR_OTHER,
117 } SecureSaveErrno;
118
119
120 #define MAX_SPLIT_IMAGES 4
121
122 typedef struct _ImageLoader ImageLoader;
123 typedef struct _ThumbLoader ThumbLoader;
124
125 typedef struct _CollectInfo CollectInfo;
126 typedef struct _CollectionData CollectionData;
127 typedef struct _CollectTable CollectTable;
128 typedef struct _CollectWindow CollectWindow;
129
130 typedef struct _ImageWindow ImageWindow;
131
132 typedef struct _FileData FileData;
133 typedef struct _FileDataChangeInfo FileDataChangeInfo;
134
135 typedef struct _LayoutWindow LayoutWindow;
136 typedef struct _ViewDir ViewDir;
137 typedef struct _ViewDirInfoList ViewDirInfoList;
138 typedef struct _ViewDirInfoTree ViewDirInfoTree;
139 typedef struct _ViewFileList ViewFileList;
140 typedef struct _ViewFileIcon ViewFileIcon;
141
142 typedef struct _SlideShowData SlideShowData;
143 typedef struct _FullScreenData FullScreenData;
144
145 typedef struct _PixmapFolders PixmapFolders;
146 typedef struct _Histogram Histogram;
147
148 typedef struct _SecureSaveInfo SecureSaveInfo;
149
150 typedef struct _ConfOptions ConfOptions;
151
152 struct _ImageLoader
153 {
154         GdkPixbuf *pixbuf;
155         FileData *fd;
156         gchar *path;
157
158         gint bytes_read;
159         gint bytes_total;
160
161         gint requested_width;
162         gint requested_height;
163         gint shrunk;
164
165         gint done;
166         gint idle_id;
167         gint idle_priority;
168
169         GdkPixbufLoader *loader;
170         gint load_fd;
171
172         void (*func_area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
173         void (*func_error)(ImageLoader *, gpointer);
174         void (*func_done)(ImageLoader *, gpointer);
175         void (*func_percent)(ImageLoader *, gdouble, gpointer);
176
177         gpointer data_area_ready;
178         gpointer data_error;
179         gpointer data_done;
180         gpointer data_percent;
181
182         gint idle_done_id;
183
184         guchar *read_buffer;
185         gint read_buffer_size;
186         gint idle_read_loop_count;
187 };
188
189 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
190
191 struct _ThumbLoader
192 {
193         gint standard_loader;
194
195         GdkPixbuf *pixbuf;      /* contains final (scaled) image when done */
196         ImageLoader *il;
197         gchar *path;
198
199         gint cache_enable;
200         gint cache_hit;
201         gdouble percent_done;
202
203         gint max_w;
204         gint max_h;
205
206         ThumbLoaderFunc func_done;
207         ThumbLoaderFunc func_error;
208         ThumbLoaderFunc func_progress;
209
210         gpointer data;
211
212         gint idle_done_id;
213 };
214
215 struct _CollectInfo
216 {
217         FileData *fd;
218         GdkPixbuf *pixbuf;
219         gint flag_mask;
220 };
221
222 struct _CollectionData
223 {
224         gchar *path;
225         gchar *name;
226         GList *list;
227         SortType sort_method;
228
229         ThumbLoader *thumb_loader;
230         CollectInfo *thumb_info;
231
232         void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
233         gpointer info_updated_data;
234
235         gint ref;
236
237         /* geometry */
238         gint window_read;
239         gint window_x;
240         gint window_y;
241         gint window_w;
242         gint window_h;
243
244         /* contents changed since save flag */
245         gint changed;
246
247         GHashTable *existence;
248 };
249
250 struct _CollectTable
251 {
252         GtkWidget *scrolled;
253         GtkWidget *listview;
254         gint columns;
255         gint rows;
256
257         CollectionData *cd;
258
259         GList *selection;
260         CollectInfo *prev_selection;
261
262         CollectInfo *click_info;
263
264         GtkWidget *tip_window;
265         gint tip_delay_id;
266         CollectInfo *tip_info;
267
268         GdkWindow *marker_window;
269         CollectInfo *marker_info;
270
271         GtkWidget *status_label;
272         GtkWidget *extra_label;
273
274         gint focus_row;
275         gint focus_column;
276         CollectInfo *focus_info;
277
278         GtkWidget *popup;
279         CollectInfo *drop_info;
280         GList *drop_list;
281
282         gint sync_idle_id;
283         gint drop_idle_id;
284
285         gint show_text;
286 };
287
288 struct _CollectWindow
289 {
290         GtkWidget *window;
291         CollectTable *table;
292         GtkWidget *status_box;
293         GList *list;
294
295         GtkWidget *close_dialog;
296
297         CollectionData *cd;
298 };
299
300 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
301                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
302 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
303                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
304
305 struct _ImageWindow
306 {
307         GtkWidget *widget;      /* use this to add it and show it */
308         GtkWidget *pr;
309         GtkWidget *frame;
310
311         FileData *image_fd;
312
313         gint64 size;            /* file size (bytes) */
314         time_t mtime;           /* file modified time stamp */
315         gint unknown;           /* failed to load image */
316
317         ImageLoader *il;
318
319         gint has_frame;
320
321         /* top level (not necessarily parent) window */
322         gint top_window_sync;   /* resize top_window when image dimensions change */
323         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
324         gchar *title;           /* window title to display left of file name */
325         gchar *title_right;     /* window title to display right of file name */
326         gint title_show_zoom;   /* option to include zoom in window title */
327
328         gint completed;
329         ImageState state;       /* mask of IMAGE_STATE_* flags about current image */
330
331         void (*func_update)(ImageWindow *imd, gpointer data);
332         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
333         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
334         ImageTileRequestFunc func_tile_request;
335         ImageTileDisposeFunc func_tile_dispose;
336
337         gpointer data_update;
338         gpointer data_complete;
339         gpointer data_state;
340         gpointer data_tile;
341
342         /* button, scroll functions */
343         void (*func_button)(ImageWindow *, gint button,
344                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
345         void (*func_drag)(ImageWindow *, gint button,
346                             guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy,gpointer);
347         void (*func_scroll)(ImageWindow *, GdkScrollDirection direction,
348                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
349
350         gpointer data_button;
351         gpointer data_drag;
352         gpointer data_scroll;
353
354         /* scroll notification (for scroll bar implementation) */
355         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
356
357         gpointer data_scroll_notify;
358
359         /* collection info */
360         CollectionData *collection;
361         CollectInfo *collection_info;
362
363         /* color profiles */
364         gint color_profile_enable;
365         gint color_profile_input;
366         gint color_profile_screen;
367         gint color_profile_use_image;
368         gint color_profile_from_image;
369         gpointer cm;
370
371         AlterType delay_alter_type;
372
373         ImageLoader *read_ahead_il;
374         GdkPixbuf *read_ahead_pixbuf;
375         FileData *read_ahead_fd;
376
377         GdkPixbuf *prev_pixbuf;
378         FileData *prev_fd;
379         gint prev_color_row;
380
381         gint auto_refresh_id;
382         gint auto_refresh_interval;
383
384         gint delay_flip;
385         gint orientation;
386         gint desaturate;
387
388         gint overlay_show_zoom; /* set to true if overlay is showing zoom ratio */
389 };
390
391 #define FILEDATA_MARKS_SIZE 6
392
393 struct _FileDataChangeInfo {
394         FileDataChangeType type;
395         gchar *source;
396         gchar *dest;
397 };
398
399 struct _FileData {
400         gint magick;
401         gint type;
402         gchar *original_path; /* key to file_data_pool hash table */
403         gchar *path;
404         const gchar *name;
405         const gchar *extension;
406         gint64 size;
407         time_t date;
408         gboolean marks[FILEDATA_MARKS_SIZE];
409         GList *sidecar_files;
410         FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
411         FileDataChangeInfo *change; /* for rename, move ... */
412         GdkPixbuf *pixbuf;
413         gint ref;
414         gint user_orientation;
415         gint exif_orientation;
416 };
417
418 struct _LayoutWindow
419 {
420         gchar *path;
421
422         /* base */
423
424         GtkWidget *window;
425
426         GtkWidget *main_box;
427
428         GtkWidget *group_box;
429         GtkWidget *h_pane;
430         GtkWidget *v_pane;
431
432         /* menus, path selector */
433
434         GtkActionGroup *action_group;
435         GtkUIManager *ui_manager;
436
437         GtkWidget *path_entry;
438
439         /* image */
440
441         LayoutLocation image_location;
442
443         ImageWindow *image;
444
445         ImageWindow *split_images[MAX_SPLIT_IMAGES];
446         ImageSplitMode split_mode;
447         gint active_split_image;
448
449         GtkWidget *split_image_widget;
450
451         gint connect_zoom, connect_scroll;
452
453         /* tools window (float) */
454
455         GtkWidget *tools;
456         GtkWidget *tools_pane;
457
458         gint tools_float;
459         gint tools_hidden;
460
461         /* toolbar */
462
463         GtkWidget *toolbar;
464         gint toolbar_hidden;
465
466         GtkWidget *thumb_button;
467         gint thumbs_enabled;
468         gint marks_enabled;
469
470         /* dir view */
471
472         LayoutLocation dir_location;
473
474         ViewDir *vd;
475         GtkWidget *dir_view;
476
477         DirViewType dir_view_type;
478
479         /* file view */
480
481         LayoutLocation file_location;
482
483         ViewFileList *vfl;
484         ViewFileIcon *vfi;
485         GtkWidget *file_view;
486
487         gint icon_view;
488         SortType sort_method;
489         gint sort_ascend;
490
491         /* status bar */
492
493         GtkWidget *info_box;
494         GtkWidget *info_progress_bar;
495         GtkWidget *info_sort;
496         GtkWidget *info_color;
497         GtkWidget *info_status;
498         GtkWidget *info_details;
499         GtkWidget *info_zoom;
500
501         /* slide show */
502
503         SlideShowData *slideshow;
504
505         /* full screen */
506
507         FullScreenData *full_screen;
508
509         /* dividers */
510
511         gint div_h;
512         gint div_v;
513         gint div_float;
514
515         /* directory update check */
516
517         gint last_time_id;
518         time_t last_time;
519
520         /* misc */
521
522         GtkWidget *utility_box;
523         GtkWidget *bar_sort;
524         GtkWidget *bar_exif;
525         GtkWidget *bar_info;
526
527         gint histogram_enabled;
528         Histogram *histogram;
529
530         gint bar_sort_enabled;
531         gint bar_exif_enabled;
532         gint bar_info_enabled;
533
534         gint bar_exif_size;
535         gint bar_exif_advanced;
536 };
537
538 struct _ViewDir
539 {
540         DirViewType type;
541         gpointer info;
542
543         GtkWidget *widget;
544         GtkWidget *view;
545
546         gchar *path;
547
548         FileData *click_fd;
549
550         FileData *drop_fd;
551         GList *drop_list;
552         gint drop_scroll_id;
553
554         /* func list */
555         void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
556         gpointer select_data;
557
558         void (*dnd_drop_update_func)(ViewDir *vd);
559         void (*dnd_drop_leave_func)(ViewDir *vd);
560
561         LayoutWindow *layout;
562
563         GtkWidget *popup;
564
565         PixmapFolders *pf;
566 };
567
568 struct _ViewDirInfoList
569 {
570         GList *list;
571 };
572
573 struct _ViewDirInfoTree
574 {
575         gint drop_expand_id;
576         gint busy_ref;
577 };
578
579 struct _ViewFileList
580 {
581         GtkWidget *widget;
582         GtkWidget *listview;
583
584         gchar *path;
585         GList *list;
586
587         SortType sort_method;
588         gint sort_ascend;
589
590         FileData *click_fd;
591         FileData *select_fd;
592
593         gint thumbs_enabled;
594         gint marks_enabled;
595         gint active_mark;
596
597         /* thumb updates */
598         gint thumbs_running;
599         gint thumbs_count;
600         ThumbLoader *thumbs_loader;
601         FileData *thumbs_filedata;
602
603         /* func list */
604         void (*func_thumb_status)(ViewFileList *vfl, gdouble val, const gchar *text, gpointer data);
605         gpointer data_thumb_status;
606
607         void (*func_status)(ViewFileList *vfl, gpointer data);
608         gpointer data_status;
609
610         gint select_idle_id;
611         LayoutWindow *layout;
612
613         GtkWidget *popup;
614 };
615
616 struct _IconData;
617
618 struct _ViewFileIcon
619 {
620         GtkWidget *widget;
621         GtkWidget *listview;
622
623         gchar *path;
624         GList *list;
625
626         /* table stuff */
627
628         gint columns;
629         gint rows;
630
631         GList *selection;
632         struct _IconData *prev_selection;
633
634         GtkWidget *tip_window;
635         gint tip_delay_id;
636         struct _IconData *tip_id;
637
638         struct _IconData *click_id;
639
640         struct _IconData *focus_id;
641         gint focus_row;
642         gint focus_column;
643
644         SortType sort_method;
645         gint sort_ascend;
646
647         gint show_text;
648
649         gint sync_idle_id;
650
651         /* thumbs */
652
653         gint thumbs_running;
654         GList *thumbs_list;
655         gint thumbs_count;
656         ThumbLoader *thumbs_loader;
657         FileData *thumbs_fd;
658
659         /* func list */
660         void (*func_thumb_status)(ViewFileIcon *vfi, gdouble val, const gchar *text, gpointer data);
661         gpointer data_thumb_status;
662
663         void (*func_status)(ViewFileIcon *vfi, gpointer data);
664         gpointer data_status;
665
666         LayoutWindow *layout;
667
668         GtkWidget *popup;
669 };
670
671 struct _SlideShowData
672 {
673         ImageWindow *imd;
674
675         GList *filelist;
676         CollectionData *cd;
677         gchar *layout_path;
678         LayoutWindow *layout;
679
680         GList *list;
681         GList *list_done;
682
683         FileData *slide_fd;
684
685         gint slide_count;
686         gint timeout_id;
687
688         gint from_selection;
689
690         void (*stop_func)(SlideShowData *, gpointer);
691         gpointer stop_data;
692
693         gint paused;
694 };
695
696 struct _FullScreenData
697 {
698         GtkWidget *window;
699         ImageWindow *imd;
700
701         GtkWidget *normal_window;
702         ImageWindow *normal_imd;
703
704         gint hide_mouse_id;
705         gint busy_mouse_id;
706         gint cursor_state;
707
708         gint saver_block_id;
709
710         void (*stop_func)(FullScreenData *, gpointer);
711         gpointer stop_data;
712 };
713
714 struct _PixmapFolders
715 {
716         GdkPixbuf *close;
717         GdkPixbuf *open;
718         GdkPixbuf *deny;
719         GdkPixbuf *parent;
720 };
721
722 struct _SecureSaveInfo {
723         FILE *fp; /**< file stream pointer */
724         gchar *file_name; /**< final file name */
725         gchar *tmp_file_name; /**< temporary file name */
726         gint err; /**< set to non-zero value in case of error */
727         gint secure_save; /**< use secure save for this file, internal use only */
728         gint preserve_perms; /**< whether to preserve perms, TRUE by default */
729         gint preserve_mtime; /**< whether to preserve mtime, FALSE by default */
730         gint unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
731 };
732
733 struct _ConfOptions
734 {
735
736         /* ui */
737         gint progressive_key_scrolling;
738         gint place_dialogs_under_mouse;
739         gint mousewheel_scrolls;
740         gint show_icon_names;
741
742         /* various */
743         gint startup_path_enable;
744         gchar *startup_path;
745         gint enable_metadata_dirs;
746
747         gint tree_descend_subdirs;
748
749         gint lazy_image_sync;
750         gint update_on_time_change;
751
752         gint duplicates_similarity_threshold;
753
754         gint open_recent_list_maxsize;
755
756         /* file ops */
757         struct {
758                 gint enable_in_place_rename;
759
760                 gint confirm_delete;
761                 gint enable_delete_key;
762                 gint safe_delete_enable;
763                 gchar *safe_delete_path;
764                 gint safe_delete_folder_maxsize;
765         } file_ops;
766
767         /* image */
768         struct {
769                 gint exif_rotate_enable;
770                 gint scroll_reset_method;
771                 gint fit_window_to_image;
772                 gint limit_window_size;
773                 gint max_window_size;
774                 gint limit_autofit_size;
775                 gint max_autofit_size;
776
777                 gint tile_cache_max;    /* in megabytes */
778                 gint dither_quality;
779                 gint enable_read_ahead;
780
781                 gint zoom_mode;
782                 gint zoom_2pass;
783                 gint zoom_to_fit_allow_expand;
784                 gint zoom_quality;
785                 gint zoom_increment;    /* 10 is 1.0, 5 is 0.05, 20 is 2.0, etc. */
786
787                 gint use_custom_border_color;
788                 GdkColor border_color;
789
790                 gint read_buffer_size; /* bytes to read from file per read() */
791                 gint idle_read_loop_count; /* the number of bytes to read per idle call (define x image.read_buffer_size) */
792         } image;
793
794         /* thumbnails */
795         struct {
796                 gint max_width;
797                 gint max_height;
798                 gint enable_caching;
799                 gint cache_into_dirs;
800                 gint fast;
801                 gint use_xvpics;
802                 gint spec_standard;
803                 gint quality;
804         } thumbnails;
805
806         /* file filtering */
807         struct {
808                 gint show_hidden_files;
809                 gint show_dot_directory;
810                 gint disable;
811         } file_filter;
812
813         /* collections */
814         struct {
815                 gint rectangular_selection;
816         } collections;
817
818         /* editors */
819         gchar *editor_name[GQ_EDITOR_SLOTS];
820         gchar *editor_command[GQ_EDITOR_SLOTS];
821
822         /* file sorting */
823         struct {
824                 SortType method;
825                 gint ascending;
826                 gint case_sensitive; /* file sorting method (case) */
827         } file_sort;
828
829         /* slideshow */
830         struct {
831                 gint delay;     /* in tenths of a second */
832                 gint random;
833                 gint repeat;
834         } slideshow;
835
836         /* fullscreen */
837         struct  {
838                 gint screen;
839                 gint clean_flip;
840                 gint disable_saver;
841                 gint above;
842                 gint show_info;
843                 gchar *info;
844         } fullscreen;
845
846         /* layout */
847         struct {
848                 gchar *order;
849                 gint style;
850
851                 gint view_as_icons;
852                 DirViewType dir_view_type;
853
854                 gint show_thumbnails;
855                 gint show_marks;
856
857                 struct {
858                         gint w;
859                         gint h;
860                         gint x;
861                         gint y;
862                         gint maximized;
863                         gint hdivider_pos;
864                         gint vdivider_pos;
865                 } main_window;
866
867                 struct {
868                         gint w;
869                         gint h;
870                         gint x;
871                         gint y;
872                         gint vdivider_pos;
873                 } float_window;
874
875                 gint save_window_positions;
876
877                 gint tools_float;
878                 gint tools_hidden;
879                 gint tools_restore_state;
880
881                 gint toolbar_hidden;
882
883         } layout;
884
885         /* color profiles */
886         struct {
887                 gint enabled;
888                 gint input_type;
889                 gchar *input_file[COLOR_PROFILE_INPUTS];
890                 gchar *input_name[COLOR_PROFILE_INPUTS];
891                 gint screen_type;
892                 gchar *screen_file;
893                 gint use_image;
894
895         } color_profile;
896
897 };
898
899 #endif
900
901