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