a4879873c1be695a15a5b866be338d2e3a81ef5b
[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 = GQVIEW_EDITOR_GENERIC_SLOTS,
18         CMD_MOVE,
19         CMD_RENAME,
20         CMD_DELETE,
21         CMD_FOLDER,
22         GQVIEW_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
145 struct _ImageLoader
146 {
147         GdkPixbuf *pixbuf;
148         FileData *fd;
149         gchar *path;
150
151         gint bytes_read;
152         gint bytes_total;
153
154         guint buffer_size;
155
156         gint requested_width;
157         gint requested_height;
158         gint shrunk;
159
160         gint done;
161         gint idle_id;
162         gint idle_priority;
163
164         GdkPixbufLoader *loader;
165         gint load_fd;
166
167         void (*func_area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
168         void (*func_error)(ImageLoader *, gpointer);
169         void (*func_done)(ImageLoader *, gpointer);
170         void (*func_percent)(ImageLoader *, gdouble, gpointer);
171
172         gpointer data_area_ready;
173         gpointer data_error;
174         gpointer data_done;
175         gpointer data_percent;
176
177         gint idle_done_id;
178 };
179
180 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
181
182 struct _ThumbLoader
183 {
184         gint standard_loader;
185
186         GdkPixbuf *pixbuf;      /* contains final (scaled) image when done */
187         ImageLoader *il;
188         gchar *path;
189
190         gint cache_enable;
191         gint cache_hit;
192         gdouble percent_done;
193
194         gint max_w;
195         gint max_h;
196
197         ThumbLoaderFunc func_done;
198         ThumbLoaderFunc func_error;
199         ThumbLoaderFunc func_progress;
200
201         gpointer data;
202
203         gint idle_done_id;
204 };
205
206 struct _CollectInfo
207 {
208         FileData *fd;
209         GdkPixbuf *pixbuf;
210         gint flag_mask;
211 };
212
213 struct _CollectionData
214 {
215         gchar *path;
216         gchar *name;
217         GList *list;
218         SortType sort_method;
219
220         ThumbLoader *thumb_loader;
221         CollectInfo *thumb_info;
222
223         void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
224         gpointer info_updated_data;
225
226         gint ref;
227
228         /* geometry */
229         gint window_read;
230         gint window_x;
231         gint window_y;
232         gint window_w;
233         gint window_h;
234
235         /* contents changed since save flag */
236         gint changed;
237 };
238
239 struct _CollectTable
240 {
241         GtkWidget *scrolled;
242         GtkWidget *listview;
243         gint columns;
244         gint rows;
245
246         CollectionData *cd;
247
248         GList *selection;
249         CollectInfo *prev_selection;
250
251         CollectInfo *click_info;
252
253         GtkWidget *tip_window;
254         gint tip_delay_id;
255         CollectInfo *tip_info;
256
257         GdkWindow *marker_window;
258         CollectInfo *marker_info;
259
260         GtkWidget *status_label;
261         GtkWidget *extra_label;
262
263         gint focus_row;
264         gint focus_column;
265         CollectInfo *focus_info;
266
267         GtkWidget *popup;
268         CollectInfo *drop_info;
269         GList *drop_list;
270
271         gint sync_idle_id;
272         gint drop_idle_id;
273
274         gint show_text;
275 };
276
277 struct _CollectWindow
278 {
279         GtkWidget *window;
280         CollectTable *table;
281         GtkWidget *status_box;
282         GList *list;
283
284         GtkWidget *close_dialog;
285
286         CollectionData *cd;
287 };
288
289 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
290                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
291 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
292                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
293
294 struct _ImageWindow
295 {
296         GtkWidget *widget;      /* use this to add it and show it */
297         GtkWidget *pr;
298         GtkWidget *frame;
299
300         FileData *image_fd;
301
302         gint64 size;            /* file size (bytes) */
303         time_t mtime;           /* file modified time stamp */
304         gint unknown;           /* failed to load image */
305
306         ImageLoader *il;
307
308         gint has_frame;
309
310         /* top level (not necessarily parent) window */
311         gint top_window_sync;   /* resize top_window when image dimensions change */
312         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
313         gchar *title;           /* window title to display left of file name */
314         gchar *title_right;     /* window title to display right of file name */
315         gint title_show_zoom;   /* option to include zoom in window title */
316
317         gint completed;
318         ImageState state;       /* mask of IMAGE_STATE_* flags about current image */
319
320         void (*func_update)(ImageWindow *imd, gpointer data);
321         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
322         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
323         ImageTileRequestFunc func_tile_request;
324         ImageTileDisposeFunc func_tile_dispose;
325
326         gpointer data_update;
327         gpointer data_complete;
328         gpointer data_state;
329         gpointer data_tile;
330
331         /* button, scroll functions */
332         void (*func_button)(ImageWindow *, gint button,
333                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
334         void (*func_drag)(ImageWindow *, gint button,
335                             guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy,gpointer);
336         void (*func_scroll)(ImageWindow *, GdkScrollDirection direction,
337                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
338
339         gpointer data_button;
340         gpointer data_drag;
341         gpointer data_scroll;
342
343         /* scroll notification (for scroll bar implementation) */
344         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
345
346         gpointer data_scroll_notify;
347
348         /* collection info */
349         CollectionData *collection;
350         CollectInfo *collection_info;
351
352         /* color profiles */
353         gint color_profile_enable;
354         gint color_profile_input;
355         gint color_profile_screen;
356         gint color_profile_use_image;
357         gpointer cm;
358
359         AlterType delay_alter_type;
360
361         ImageLoader *read_ahead_il;
362         GdkPixbuf *read_ahead_pixbuf;
363         FileData *read_ahead_fd;
364
365         GdkPixbuf *prev_pixbuf;
366         FileData *prev_fd;
367         gint prev_color_row;
368
369         gint auto_refresh_id;
370         gint auto_refresh_interval;
371
372         gint delay_flip;
373 };
374
375 #define FILEDATA_MARKS_SIZE 6
376
377 struct _FileDataChangeInfo {
378         FileDataChangeType type;
379         gchar *source;
380         gchar *dest;
381 };
382
383 struct _FileData {
384         gint magick;
385         gint type;
386         gchar *original_path; /* key to file_data_pool hash table */
387         gchar *path;
388         const gchar *name;
389         const gchar *extension;
390         gint64 size;
391         time_t date;
392         gboolean marks[FILEDATA_MARKS_SIZE];
393         GList *sidecar_files;
394         FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
395         FileDataChangeInfo *change; /* for rename, move ... */
396         GdkPixbuf *pixbuf;
397         gint ref;
398 };
399
400 struct _Histogram {
401         gulong histmap[256*4];
402         gint histogram_chan;
403         gint histogram_logmode;
404 };
405
406
407 struct _LayoutWindow
408 {
409         gchar *path;
410
411         /* base */
412
413         GtkWidget *window;
414
415         GtkWidget *main_box;
416
417         GtkWidget *group_box;
418         GtkWidget *h_pane;
419         GtkWidget *v_pane;
420
421         /* menus, path selector */
422
423         GtkActionGroup *action_group;
424         GtkUIManager *ui_manager;
425
426         GtkWidget *path_entry;
427
428         /* image */
429
430         LayoutLocation image_location;
431
432         ImageWindow *image;
433
434         ImageWindow *split_images[MAX_SPLIT_IMAGES];
435         ImageSplitMode split_mode;
436         gint active_split_image;
437
438         GtkWidget *split_image_widget;
439         
440         gint connect_zoom, connect_scroll;
441         
442         /* tools window (float) */
443
444         GtkWidget *tools;
445         GtkWidget *tools_pane;
446
447         gint tools_float;
448         gint tools_hidden;
449
450         /* toolbar */
451
452         GtkWidget *toolbar;
453         gint toolbar_hidden;
454
455         GtkWidget *thumb_button;
456         gint thumbs_enabled;
457         gint marks_enabled;
458     
459         /* dir view */
460
461         LayoutLocation dir_location;
462
463         ViewDirList *vdl;
464         ViewDirTree *vdt;
465         GtkWidget *dir_view;
466
467         gint tree_view;
468
469         /* file view */
470
471         LayoutLocation file_location;
472
473         ViewFileList *vfl;
474         ViewFileIcon *vfi;
475         GtkWidget *file_view;
476
477         gint icon_view;
478         SortType sort_method;
479         gint sort_ascend;
480
481         /* status bar */
482
483         GtkWidget *info_box;
484         GtkWidget *info_progress_bar;
485         GtkWidget *info_sort;
486         GtkWidget *info_color;
487         GtkWidget *info_status;
488         GtkWidget *info_details;
489         GtkWidget *info_zoom;
490
491         /* slide show */
492
493         SlideShowData *slideshow;
494
495         /* full screen */
496
497         FullScreenData *full_screen;
498
499         /* dividers */
500
501         gint div_h;
502         gint div_v;
503         gint div_float;
504
505         /* directory update check */
506
507         gint last_time_id;
508         time_t last_time;
509
510         /* misc */
511
512         GtkWidget *utility_box;
513         GtkWidget *bar_sort;
514         GtkWidget *bar_exif;
515         GtkWidget *bar_info;
516
517         gint histogram_enabled;
518         Histogram *histogram;
519
520         gint bar_sort_enabled;
521         gint bar_exif_enabled;
522         gint bar_info_enabled;
523
524         gint bar_exif_size;
525         gint bar_exif_advanced;
526 };
527
528 struct _ViewDirList
529 {
530         GtkWidget *widget;
531         GtkWidget *listview;
532
533         gchar *path;
534         GList *list;
535
536         FileData *click_fd;
537
538         FileData *drop_fd;
539         GList *drop_list;
540
541         gint drop_scroll_id;
542
543         /* func list */
544         void (*select_func)(ViewDirList *vdl, const gchar *path, gpointer data);
545         gpointer select_data;
546
547         LayoutWindow *layout;
548
549         GtkWidget *popup;
550
551         PixmapFolders *pf;
552 };
553
554 struct _ViewDirTree
555 {
556         GtkWidget *widget;
557         GtkWidget *treeview;
558
559         gchar *path;
560
561         FileData *click_fd;
562
563         FileData *drop_fd;
564         GList *drop_list;
565
566         gint drop_scroll_id;
567         gint drop_expand_id;
568
569         /* func list */
570         void (*select_func)(ViewDirTree *vdt, const gchar *path, gpointer data);
571         gpointer select_data;
572
573         LayoutWindow *layout;
574
575         GtkWidget *popup;
576
577         PixmapFolders *pf;
578
579         gint busy_ref;
580 };
581
582 struct _ViewFileList
583 {
584         GtkWidget *widget;
585         GtkWidget *listview;
586
587         gchar *path;
588         GList *list;
589
590         SortType sort_method;
591         gint sort_ascend;
592
593         FileData *click_fd;
594         FileData *select_fd;
595
596         gint thumbs_enabled;
597         gint marks_enabled;
598         gint active_mark;
599     
600         /* thumb updates */
601         gint thumbs_running;
602         gint thumbs_count;
603         ThumbLoader *thumbs_loader;
604         FileData *thumbs_filedata;
605
606         /* func list */
607         void (*func_thumb_status)(ViewFileList *vfl, gdouble val, const gchar *text, gpointer data);
608         gpointer data_thumb_status;
609
610         void (*func_status)(ViewFileList *vfl, gpointer data);
611         gpointer data_status;
612
613         gint select_idle_id;
614         LayoutWindow *layout;
615
616         GtkWidget *popup;
617 };
618
619 struct _IconData;
620
621 struct _ViewFileIcon
622 {
623         GtkWidget *widget;
624         GtkWidget *listview;
625
626         gchar *path;
627         GList *list;
628
629         /* table stuff */
630
631         gint columns;
632         gint rows;
633
634         GList *selection;
635         struct _IconData *prev_selection;
636
637         GtkWidget *tip_window;
638         gint tip_delay_id;
639         struct _IconData *tip_id;
640
641         struct _IconData *click_id;
642
643         struct _IconData *focus_id;
644         gint focus_row;
645         gint focus_column;
646
647         SortType sort_method;
648         gint sort_ascend;
649
650         gint show_text;
651
652         gint sync_idle_id;
653
654         /* thumbs */
655         
656         gint thumbs_running;
657         GList *thumbs_list;
658         gint thumbs_count;
659         ThumbLoader *thumbs_loader;
660         FileData *thumbs_fd;
661
662         /* func list */
663         void (*func_thumb_status)(ViewFileIcon *vfi, gdouble val, const gchar *text, gpointer data);
664         gpointer data_thumb_status;
665
666         void (*func_status)(ViewFileIcon *vfi, gpointer data);
667         gpointer data_status;
668
669         LayoutWindow *layout;
670
671         GtkWidget *popup;
672 };
673
674 struct _SlideShowData
675 {
676         ImageWindow *imd;
677
678         GList *filelist;
679         CollectionData *cd;
680         gchar *layout_path;
681         LayoutWindow *layout;
682
683         GList *list;
684         GList *list_done;
685
686         FileData *slide_fd;
687
688         gint slide_count;
689         gint timeout_id;
690
691         gint from_selection;
692
693         void (*stop_func)(SlideShowData *, gpointer);
694         gpointer stop_data;
695
696         gint paused;
697 };
698
699 struct _FullScreenData
700 {
701         GtkWidget *window;
702         ImageWindow *imd;
703
704         GtkWidget *normal_window;
705         ImageWindow *normal_imd;
706
707         gint hide_mouse_id;
708         gint busy_mouse_id;
709         gint cursor_state;
710
711         gint saver_block_id;
712
713         void (*stop_func)(FullScreenData *, gpointer);
714         gpointer stop_data;
715 };
716
717 struct _PixmapFolders
718 {
719         GdkPixbuf *close;
720         GdkPixbuf *open;
721         GdkPixbuf *deny;
722         GdkPixbuf *parent;
723 };
724
725 struct _SecureSaveInfo {
726         FILE *fp; /**< file stream pointer */
727         gchar *file_name; /**< final file name */
728         gchar *tmp_file_name; /**< temporary file name */
729         gint err; /**< set to non-zero value in case of error */
730         gint secure_save; /**< use secure save for this file */
731 };
732
733
734 #endif
735
736