replaced vflist_maint functions by vflist_refresh - it allows to follow
[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         MOUSE_BUTTON_LEFT       = 1,
19         MOUSE_BUTTON_MIDDLE     = 2,
20         MOUSE_BUTTON_RIGHT      = 3,
21         MOUSE_BUTTON_WHEEL_UP   = 4,
22         MOUSE_BUTTON_WHEEL_DOWN = 5
23 } MouseButton;
24
25 typedef enum {
26         DIRVIEW_LIST,
27         DIRVIEW_TREE
28 } DirViewType;
29
30 typedef enum {
31         FILEVIEW_LIST,
32         FILEVIEW_ICON
33 } FileViewType;
34
35 typedef enum {
36         CMD_COPY = GQ_EDITOR_GENERIC_SLOTS,
37         CMD_MOVE,
38         CMD_RENAME,
39         CMD_DELETE,
40         CMD_FOLDER,
41         GQ_EDITOR_SLOTS
42 } SpecialEditor;
43
44 typedef enum {
45         SORT_NONE,
46         SORT_NAME,
47         SORT_SIZE,
48         SORT_TIME,
49         SORT_PATH,
50         SORT_NUMBER
51 } SortType;
52
53 typedef enum {
54         ALTER_NONE,             /* do nothing */
55         ALTER_ROTATE_90,
56         ALTER_ROTATE_90_CC,     /* counterclockwise */
57         ALTER_ROTATE_180,
58         ALTER_MIRROR,
59         ALTER_FLIP,
60         ALTER_DESATURATE
61 } AlterType;
62
63 typedef enum {
64         LAYOUT_HIDE   = 0,
65         LAYOUT_LEFT   = 1 << 0,
66         LAYOUT_RIGHT  = 1 << 1,
67         LAYOUT_TOP    = 1 << 2,
68         LAYOUT_BOTTOM = 1 << 3
69 } LayoutLocation;
70
71
72 typedef enum {
73         IMAGE_STATE_NONE        = 0,
74         IMAGE_STATE_IMAGE       = 1 << 0,
75         IMAGE_STATE_LOADING     = 1 << 1,
76         IMAGE_STATE_ERROR       = 1 << 2,
77         IMAGE_STATE_COLOR_ADJ   = 1 << 3,
78         IMAGE_STATE_ROTATE_AUTO = 1 << 4,
79         IMAGE_STATE_ROTATE_USER = 1 << 5,
80         IMAGE_STATE_DELAY_FLIP  = 1 << 6
81 } ImageState;
82
83 typedef enum {
84         SPLIT_NONE = 0,
85         SPLIT_VERT,
86         SPLIT_HOR,
87         SPLIT_QUAD,
88 } ImageSplitMode;
89
90 typedef enum {
91         FILEDATA_CHANGE_DELETE,
92         FILEDATA_CHANGE_MOVE,
93         FILEDATA_CHANGE_RENAME,
94         FILEDATA_CHANGE_COPY,
95         FILEDATA_CHANGE_UNSPECIFIED
96 } FileDataChangeType;
97
98 typedef enum {
99         MTS_MODE_MINUS,
100         MTS_MODE_SET,
101         MTS_MODE_OR,
102         MTS_MODE_AND
103 } MarkToSelectionMode;
104
105 typedef enum {
106         STM_MODE_RESET,
107         STM_MODE_SET,
108         STM_MODE_TOGGLE
109 } SelectionToMarkMode;
110
111 typedef enum {
112         FORMAT_CLASS_UNKNOWN,
113         FORMAT_CLASS_IMAGE,
114         FORMAT_CLASS_RAWIMAGE,
115         FORMAT_CLASS_META,
116         FILE_FORMAT_CLASSES
117 } FileFormatClass;
118
119 typedef enum {
120         SS_ERR_NONE = 0,
121         SS_ERR_DISABLED, /**< secsave is disabled. */
122         SS_ERR_OUT_OF_MEM, /**< memory allocation failure */
123
124         /* see err field in SecureSaveInfo */
125         SS_ERR_OPEN_READ,
126         SS_ERR_OPEN_WRITE,
127         SS_ERR_STAT,
128         SS_ERR_ACCESS,
129         SS_ERR_MKSTEMP,
130         SS_ERR_RENAME,
131         SS_ERR_OTHER,
132 } SecureSaveErrno;
133
134
135 #define MAX_SPLIT_IMAGES 4
136
137 typedef struct _ImageLoader ImageLoader;
138 typedef struct _ThumbLoader ThumbLoader;
139
140 typedef struct _CollectInfo CollectInfo;
141 typedef struct _CollectionData CollectionData;
142 typedef struct _CollectTable CollectTable;
143 typedef struct _CollectWindow CollectWindow;
144
145 typedef struct _ImageWindow ImageWindow;
146
147 typedef struct _FileData FileData;
148 typedef struct _FileDataChangeInfo FileDataChangeInfo;
149
150 typedef struct _LayoutWindow LayoutWindow;
151
152 typedef struct _ViewDir ViewDir;
153 typedef struct _ViewDirInfoList ViewDirInfoList;
154 typedef struct _ViewDirInfoTree ViewDirInfoTree;
155
156 typedef struct _ViewFile ViewFile;
157 typedef struct _ViewFileInfoList ViewFileInfoList;
158 typedef struct _ViewFileInfoIcon ViewFileInfoIcon;
159
160 typedef struct _SlideShowData SlideShowData;
161 typedef struct _FullScreenData FullScreenData;
162
163 typedef struct _PixmapFolders PixmapFolders;
164 typedef struct _Histogram Histogram;
165
166 typedef struct _SecureSaveInfo SecureSaveInfo;
167
168 typedef struct _Editor Editor;
169 struct _Editor {
170         gchar *name;
171         gchar *command;
172 };
173
174 struct _ImageLoader
175 {
176         GdkPixbuf *pixbuf;
177         FileData *fd;
178         gchar *path;
179
180         gint bytes_read;
181         gint bytes_total;
182
183         gint requested_width;
184         gint requested_height;
185         gint shrunk;
186
187         gint done;
188         gint idle_id;
189         gint idle_priority;
190
191         GdkPixbufLoader *loader;
192         gint load_fd;
193
194         void (*func_area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
195         void (*func_error)(ImageLoader *, gpointer);
196         void (*func_done)(ImageLoader *, gpointer);
197         void (*func_percent)(ImageLoader *, gdouble, gpointer);
198
199         gpointer data_area_ready;
200         gpointer data_error;
201         gpointer data_done;
202         gpointer data_percent;
203
204         gint idle_done_id;
205
206         guchar *read_buffer;
207         gint read_buffer_size;
208         gint idle_read_loop_count;
209 };
210
211 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
212
213 struct _ThumbLoader
214 {
215         gint standard_loader;
216
217         GdkPixbuf *pixbuf;      /* contains final (scaled) image when done */
218         ImageLoader *il;
219         gchar *path;
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         gint64 size;            /* file size (bytes) */
336         time_t mtime;           /* file modified time stamp */
337         gint unknown;           /* failed to load image */
338
339         ImageLoader *il;
340
341         gint has_frame;
342
343         /* top level (not necessarily parent) window */
344         gint top_window_sync;   /* resize top_window when image dimensions change */
345         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
346         gchar *title;           /* window title to display left of file name */
347         gchar *title_right;     /* window title to display right of file name */
348         gint title_show_zoom;   /* option to include zoom in window title */
349
350         gint completed;
351         ImageState state;       /* mask of IMAGE_STATE_* flags about current image */
352
353         void (*func_update)(ImageWindow *imd, gpointer data);
354         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
355         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
356         ImageTileRequestFunc func_tile_request;
357         ImageTileDisposeFunc func_tile_dispose;
358
359         gpointer data_update;
360         gpointer data_complete;
361         gpointer data_state;
362         gpointer data_tile;
363
364         /* button, scroll functions */
365         void (*func_button)(ImageWindow *, gint button,
366                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
367         void (*func_drag)(ImageWindow *, gint button,
368                             guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy,gpointer);
369         void (*func_scroll)(ImageWindow *, GdkScrollDirection direction,
370                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
371
372         gpointer data_button;
373         gpointer data_drag;
374         gpointer data_scroll;
375
376         /* scroll notification (for scroll bar implementation) */
377         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
378
379         gpointer data_scroll_notify;
380
381         /* collection info */
382         CollectionData *collection;
383         CollectInfo *collection_info;
384
385         /* color profiles */
386         gint color_profile_enable;
387         gint color_profile_input;
388         gint color_profile_screen;
389         gint color_profile_use_image;
390         gint color_profile_from_image;
391         gpointer cm;
392
393         AlterType delay_alter_type;
394
395         ImageLoader *read_ahead_il;
396         GdkPixbuf *read_ahead_pixbuf;
397         FileData *read_ahead_fd;
398
399         GdkPixbuf *prev_pixbuf;
400         FileData *prev_fd;
401         gint prev_color_row;
402
403         gint auto_refresh_id;
404         gint auto_refresh_interval;
405
406         gint delay_flip;
407         gint orientation;
408         gint desaturate;
409
410         gint overlay_show_zoom; /* set to true if overlay is showing zoom ratio */
411 };
412
413 #define FILEDATA_MARKS_SIZE 6
414
415 struct _FileDataChangeInfo {
416         FileDataChangeType type;
417         gchar *source;
418         gchar *dest;
419 };
420
421 struct _FileData {
422         gint magick;
423         gint type;
424         gchar *original_path; /* key to file_data_pool hash table */
425         gchar *path;
426         const gchar *name;
427         const gchar *extension;
428         gint64 size;
429         time_t date;
430         gboolean marks[FILEDATA_MARKS_SIZE];
431         GList *sidecar_files;
432         FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
433         FileDataChangeInfo *change; /* for rename, move ... */
434         GdkPixbuf *pixbuf;
435         gint ref;
436         gint version; /* increased when any field in this structure is changed */
437         gint user_orientation;
438         gint exif_orientation;
439 };
440
441 struct _LayoutWindow
442 {
443         gchar *path;
444
445         /* base */
446
447         GtkWidget *window;
448
449         GtkWidget *main_box;
450
451         GtkWidget *group_box;
452         GtkWidget *h_pane;
453         GtkWidget *v_pane;
454
455         /* menus, path selector */
456
457         GtkActionGroup *action_group;
458         GtkUIManager *ui_manager;
459
460         GtkWidget *path_entry;
461
462         /* image */
463
464         LayoutLocation image_location;
465
466         ImageWindow *image;
467
468         ImageWindow *split_images[MAX_SPLIT_IMAGES];
469         ImageSplitMode split_mode;
470         gint active_split_image;
471
472         GtkWidget *split_image_widget;
473
474         gint connect_zoom, connect_scroll;
475
476         /* tools window (float) */
477
478         GtkWidget *tools;
479         GtkWidget *tools_pane;
480
481         gint tools_float;
482         gint tools_hidden;
483
484         /* toolbar */
485
486         GtkWidget *toolbar;
487         gint toolbar_hidden;
488
489         GtkWidget *thumb_button;
490         gint thumbs_enabled;
491         gint marks_enabled;
492
493         /* dir view */
494
495         LayoutLocation dir_location;
496
497         ViewDir *vd;
498         GtkWidget *dir_view;
499
500         DirViewType dir_view_type;
501
502         /* file view */
503
504         LayoutLocation file_location;
505
506         ViewFile *vf;
507         FileViewType file_view_type;
508
509         GtkWidget *file_view;
510
511         SortType sort_method;
512         gint sort_ascend;
513
514         /* status bar */
515
516         GtkWidget *info_box;
517         GtkWidget *info_progress_bar;
518         GtkWidget *info_sort;
519         GtkWidget *info_color;
520         GtkWidget *info_status;
521         GtkWidget *info_details;
522         GtkWidget *info_zoom;
523
524         /* slide show */
525
526         SlideShowData *slideshow;
527
528         /* full screen */
529
530         FullScreenData *full_screen;
531
532         /* dividers */
533
534         gint div_h;
535         gint div_v;
536         gint div_float;
537
538         /* directory update check */
539
540         gint last_time_id;
541         time_t last_time;
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         gchar *path;
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
609         gchar *path;
610         GList *list;
611
612         SortType sort_method;
613         gint sort_ascend;
614
615         /* func list */
616         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
617         gpointer data_thumb_status;
618
619         void (*func_status)(ViewFile *vf, gpointer data);
620         gpointer data_status;
621
622         LayoutWindow *layout;
623
624         GtkWidget *popup;
625
626         /* thumbs updates*/
627         gint thumbs_running;
628         gint thumbs_count;
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; /* used only in vflist for now */
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         gint sync_idle_id;
675 };
676
677 struct _SlideShowData
678 {
679         ImageWindow *imd;
680
681         GList *filelist;
682         CollectionData *cd;
683         gchar *layout_path;
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