##### Note: GQview CVS on sourceforge is not always up to date, please use #####
[geeqie.git] / src / typedefs.h
1 /*
2  * GQview
3  * (C) 2004 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
17 typedef enum {
18         SORT_NONE,
19         SORT_NAME,
20         SORT_SIZE,
21         SORT_TIME,
22         SORT_PATH,
23         SORT_NUMBER
24 } SortType;
25
26 typedef enum {
27         ALTER_NONE,             /* do nothing */
28         ALTER_ROTATE_90,
29         ALTER_ROTATE_90_CC,     /* counterclockwise */
30         ALTER_ROTATE_180,
31         ALTER_MIRROR,
32         ALTER_FLIP
33 } AlterType;
34
35 typedef enum {
36         LAYOUT_HIDE   = 0,
37         LAYOUT_LEFT   = 1 << 0,
38         LAYOUT_RIGHT  = 1 << 1,
39         LAYOUT_TOP    = 1 << 2,
40         LAYOUT_BOTTOM = 1 << 3
41 } LayoutLocation;
42
43
44 typedef struct _ImageLoader ImageLoader;
45 typedef struct _ThumbLoader ThumbLoader;
46
47 typedef struct _CollectInfo CollectInfo;
48 typedef struct _CollectionData CollectionData;
49 typedef struct _CollectTable CollectTable;
50 typedef struct _CollectWindow CollectWindow;
51
52 typedef struct _ImageWindow ImageWindow;
53
54 typedef struct _FileData FileData;
55
56 typedef struct _LayoutWindow LayoutWindow;
57 typedef struct _ViewDirList ViewDirList;
58 typedef struct _ViewDirTree ViewDirTree;
59 typedef struct _ViewFileList ViewFileList;
60 typedef struct _ViewFileIcon ViewFileIcon;
61
62 typedef struct _SlideShowData SlideShowData;
63 typedef struct _FullScreenData FullScreenData;
64
65 typedef struct _PixmapFolders PixmapFolders;
66
67
68 struct _ImageLoader
69 {
70         GdkPixbuf *pixbuf;
71         gchar *path;
72
73         gint bytes_read;
74         gint bytes_total;
75
76         guint buffer_size;
77
78         gint requested_width;
79         gint requested_height;
80
81         gint done;
82         gint idle_id;
83         gint idle_priority;
84
85         GdkPixbufLoader *loader;
86         gint load_fd;
87
88         void (*func_area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
89         void (*func_error)(ImageLoader *, gpointer);
90         void (*func_done)(ImageLoader *, gpointer);
91         void (*func_percent)(ImageLoader *, gdouble, gpointer);
92
93         gpointer data_area_ready;
94         gpointer data_error;
95         gpointer data_done;
96         gpointer data_percent;
97
98         gint idle_done_id;
99 };
100
101 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
102
103 struct _ThumbLoader
104 {
105         gint standard_loader;
106
107         GdkPixbuf *pixbuf;      /* contains final (scaled) image when done */
108         ImageLoader *il;
109         gchar *path;
110
111         gint cache_enable;
112         gint cache_hit;
113         gdouble percent_done;
114
115         gint max_w;
116         gint max_h;
117
118         ThumbLoaderFunc func_done;
119         ThumbLoaderFunc func_error;
120         ThumbLoaderFunc func_progress;
121
122         gpointer data;
123
124         gint idle_done_id;
125 };
126
127 struct _CollectInfo
128 {
129         gchar *path;
130         gint64 size;
131         time_t date;
132
133         GdkPixbuf *pixbuf;
134         gint flag_mask;
135 };
136
137 struct _CollectionData
138 {
139         gchar *path;
140         gchar *name;
141         GList *list;
142         SortType sort_method;
143
144         ThumbLoader *thumb_loader;
145         CollectInfo *thumb_info;
146
147         void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
148         gpointer info_updated_data;
149
150         gint ref;
151
152         /* geometry */
153         gint window_read;
154         gint window_x;
155         gint window_y;
156         gint window_w;
157         gint window_h;
158
159         /* contents changed since save flag */
160         gint changed;
161 };
162
163 struct _CollectTable
164 {
165         GtkWidget *scrolled;
166         GtkWidget *listview;
167         gint columns;
168         gint rows;
169
170         CollectionData *cd;
171
172         GList *selection;
173         CollectInfo *prev_selection;
174
175         CollectInfo *click_info;
176
177         GtkWidget *tip_window;
178         gint tip_delay_id;
179         CollectInfo *tip_info;
180
181         GdkWindow *marker_window;
182         CollectInfo *marker_info;
183
184         GtkWidget *status_label;
185         GtkWidget *extra_label;
186
187         gint focus_row;
188         gint focus_column;
189         CollectInfo *focus_info;
190
191         GtkWidget *popup;
192         CollectInfo *drop_info;
193         GList *drop_list;
194
195         gint sync_idle_id;
196         gint drop_idle_id;
197
198         gint show_text;
199 };
200
201 struct _CollectWindow
202 {
203         GtkWidget *window;
204         CollectTable *table;
205         GtkWidget *status_box;
206         GList *list;
207
208         GtkWidget *close_dialog;
209
210         CollectionData *cd;
211 };
212
213 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
214                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
215 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
216                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
217
218 struct _ImageWindow
219 {
220         GtkWidget *widget;      /* use this to add it and show it */
221         GtkWidget *image;
222
223         gchar *image_path;
224         const gchar *image_name;
225
226         gint image_width;       /* image actual dimensions (pixels) */
227         gint image_height;
228         GdkPixbuf *pixbuf;
229         gint64 size;            /* file size (bytes) */
230         time_t mtime;           /* file modified time stamp */
231         gint unknown;           /* failed to load image */
232
233         gint window_width;      /* allocated size of window (drawing area) */
234         gint window_height;
235
236         gint x_offset;          /* offset of image start (non-zero when image < window) */
237         gint y_offset;
238
239         gint vis_width;         /* dimensions of visible part of image */
240         gint vis_height;
241
242         gint width;             /* size of scaled image (result) */
243         gint height;
244
245         gint x_scroll;          /* scroll offset of image (into width, height to start drawing) */
246         gint y_scroll;
247
248         gdouble zoom_min;
249         gdouble zoom_max;
250         gdouble zoom;           /* zoom we want (0 is auto) */
251         gdouble scale;          /* zoom we got (should never be 0) */
252
253         gint tile_width;
254         gint tile_height;
255         gint tile_cols;         /* count of tile columns */
256         GList *tiles;           /* list of buffer tiles */
257         GList *tile_cache;      /* list of pixmap/pixbuf tile allocations */
258         gint tile_cache_size;   /* allocated size of pixmaps/pixbufs */
259         GList *draw_queue;      /* list of areas to redraw */
260
261         gint source_tiles_enabled;
262         gint source_tiles_cache_size;
263
264         GList *source_tiles;    /* list of active source tiles */
265         gint source_tile_width;
266         gint source_tile_height;
267
268         GList *draw_queue_2pass;/* list when 2 pass is enabled */
269
270         ImageLoader *il;
271
272         gint draw_idle_id;
273         gint draw_idle_high;    /* current idle_id has high priority */
274
275         gint in_drag;
276         gint drag_last_x;
277         gint drag_last_y;
278         gint drag_moved;
279
280         gint has_frame;
281         gint top_window_sync;   /* resize top_window when image dimensions change */
282
283         /* top level (not necessarily parent) window */
284         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
285         gchar *title;           /* window title to display left of file name */
286         gchar *title_right;     /* window title to display right of file name */
287         gint title_show_zoom;   /* option to include zoom in window title */
288
289         gint completed;
290
291         void (*func_update)(ImageWindow *, gpointer);
292         void (*func_complete)(ImageWindow *, gint preload, gpointer);
293         void (*func_new)(ImageWindow *, gpointer);
294         ImageTileRequestFunc func_tile_request;
295         ImageTileDisposeFunc func_tile_dispose;
296
297         gpointer data_update;
298         gpointer data_complete;
299         gpointer data_new;
300         gpointer data_tile;
301
302         /* button, scroll functions */
303         void (*func_button)(ImageWindow *, gint button,
304                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
305         void (*func_scroll)(ImageWindow *, GdkScrollDirection direction,
306                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
307
308         gpointer data_button;
309         gpointer data_scroll;
310
311         /* scroll notification (for scroll bar implementation) */
312         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
313
314         gpointer data_scroll_notify;
315
316         /* collection info */
317         CollectionData *collection;
318         CollectInfo *collection_info;
319
320         AlterType delay_alter_type;
321
322         ImageLoader *read_ahead_il;
323         GdkPixbuf *read_ahead_pixbuf;
324         gchar *read_ahead_path;
325
326         GdkPixbuf *prev_pixbuf;
327         gchar *prev_path;
328
329         gint auto_refresh_id;
330         gint auto_refresh_interval;
331
332         gint delay_flip;
333
334         gint scroller_id;
335         gint scroller_overlay;
336         gint scroller_x;
337         gint scroller_y;
338         gint scroller_xpos;
339         gint scroller_ypos;
340         gint scroller_xinc;
341         gint scroller_yinc;
342
343         GList *overlay_list;
344 };
345
346 struct _FileData {
347         gchar *path;
348         const gchar *name;
349         gint64 size;
350         time_t date;
351
352         GdkPixbuf *pixbuf;
353 };
354
355 struct _LayoutWindow
356 {
357         gchar *path;
358
359         /* base */
360
361         GtkWidget *window;
362
363         GtkWidget *main_box;
364
365         GtkWidget *group_box;
366         GtkWidget *h_pane;
367         GtkWidget *v_pane;
368
369         GtkTooltips *tooltips;
370
371         /* menus, path selector */
372
373         GtkActionGroup *action_group;
374         GtkUIManager *ui_manager;
375
376         GtkWidget *path_entry;
377
378         /* image */
379
380         LayoutLocation image_location;
381
382         ImageWindow *image;
383
384         /* tools window (float) */
385
386         GtkWidget *tools;
387         GtkWidget *tools_pane;
388
389         gint tools_float;
390         gint tools_hidden;
391
392         /* toolbar */
393
394         GtkWidget *toolbar;
395         gint toolbar_hidden;
396
397         GtkWidget *thumb_button;
398         gint thumbs_enabled;
399
400         /* dir view */
401
402         LayoutLocation dir_location;
403
404         ViewDirList *vdl;
405         ViewDirTree *vdt;
406         GtkWidget *dir_view;
407
408         gint tree_view;
409
410         /* file view */
411
412         LayoutLocation file_location;
413
414         ViewFileList *vfl;
415         ViewFileIcon *vfi;
416         GtkWidget *file_view;
417
418         gint icon_view;
419         SortType sort_method;
420         gint sort_ascend;
421
422         /* status bar */
423
424         GtkWidget *info_box;
425         GtkWidget *info_progress_bar;
426         GtkWidget *info_sort;
427         GtkWidget *info_status;
428         GtkWidget *info_details;
429         GtkWidget *info_zoom;
430
431         /* slide show */
432
433         SlideShowData *slideshow;
434
435         /* full screen */
436
437         FullScreenData *full_screen;
438         gint full_screen_overlay_id;
439         gint full_screen_overlay_on;
440
441         /* dividers */
442
443         gint div_h;
444         gint div_v;
445         gint div_float;
446
447         /* directory update check */
448
449         gint last_time_id;
450         time_t last_time;
451
452         /* misc */
453
454         GtkWidget *utility_box;
455         GtkWidget *bar_sort;
456         GtkWidget *bar_exif;
457         GtkWidget *bar_info;
458
459         gint bar_sort_enabled;
460         gint bar_exif_enabled;
461         gint bar_info_enabled;
462
463         gint bar_exif_size;
464         gint bar_exif_advanced;
465 };
466
467 struct _ViewDirList
468 {
469         GtkWidget *widget;
470         GtkWidget *listview;
471
472         gchar *path;
473         GList *list;
474
475         FileData *click_fd;
476
477         FileData *drop_fd;
478         GList *drop_list;
479
480         gint drop_scroll_id;
481
482         /* func list */
483         void (*select_func)(ViewDirList *vdl, const gchar *path, gpointer data);
484         gpointer select_data;
485
486         LayoutWindow *layout;
487
488         GtkWidget *popup;
489
490         PixmapFolders *pf;
491 };
492
493 struct _ViewDirTree
494 {
495         GtkWidget *widget;
496         GtkWidget *treeview;
497
498         gchar *path;
499
500         FileData *click_fd;
501
502         FileData *drop_fd;
503         GList *drop_list;
504
505         gint drop_scroll_id;
506         gint drop_expand_id;
507
508         /* func list */
509         void (*select_func)(ViewDirTree *vdt, const gchar *path, gpointer data);
510         gpointer select_data;
511
512         LayoutWindow *layout;
513
514         GtkWidget *popup;
515
516         PixmapFolders *pf;
517
518         gint busy_ref;
519 };
520
521 struct _ViewFileList
522 {
523         GtkWidget *widget;
524         GtkWidget *listview;
525
526         gchar *path;
527         GList *list;
528
529         SortType sort_method;
530         gint sort_ascend;
531
532         FileData *click_fd;
533         FileData *select_fd;
534
535         gint thumbs_enabled;
536
537         /* thumb updates */
538         gint thumbs_running;
539         gint thumbs_count;
540         ThumbLoader *thumbs_loader;
541         FileData *thumbs_filedata;
542
543         /* func list */
544         void (*func_thumb_status)(ViewFileList *vfl, gdouble val, const gchar *text, gpointer data);
545         gpointer data_thumb_status;
546
547         void (*func_status)(ViewFileList *vfl, gpointer data);
548         gpointer data_status;
549
550         gint select_idle_id;
551         LayoutWindow *layout;
552
553         GtkWidget *popup;
554 };
555
556 struct _ViewFileIcon
557 {
558         GtkWidget *widget;
559         GtkWidget *listview;
560
561         gchar *path;
562         GList *list;
563
564         /* table stuff */
565
566         gint columns;
567         gint rows;
568
569         GList *selection;
570         FileData *prev_selection;
571
572         GtkWidget *tip_window;
573         gint tip_delay_id;
574         FileData *tip_fd;
575
576         FileData *click_fd;
577
578         FileData *focus_fd;
579         gint focus_row;
580         gint focus_column;
581
582         SortType sort_method;
583         gint sort_ascend;
584
585         gint show_text;
586
587         gint sync_idle_id;
588
589         /* thumbs */
590         
591         gint thumbs_running;
592         GList *thumbs_list;
593         gint thumbs_count;
594         ThumbLoader *thumbs_loader;
595         FileData *thumbs_fd;
596
597         /* func list */
598         void (*func_thumb_status)(ViewFileIcon *vfi, gdouble val, const gchar *text, gpointer data);
599         gpointer data_thumb_status;
600
601         void (*func_status)(ViewFileIcon *vfi, gpointer data);
602         gpointer data_status;
603
604         LayoutWindow *layout;
605
606         GtkWidget *popup;
607 };
608
609 struct _SlideShowData
610 {
611         ImageWindow *imd;
612
613         GList *path_list;
614         CollectionData *cd;
615         gchar *layout_path;
616         LayoutWindow *layout;
617
618         GList *list;
619         GList *list_done;
620
621         gchar *slide_path;
622
623         gint slide_count;
624         gint timeout_id;
625
626         gint from_selection;
627
628         void (*stop_func)(SlideShowData *, gpointer);
629         gpointer stop_data;
630
631         gint paused;
632 };
633
634 struct _FullScreenData
635 {
636         GtkWidget *window;
637         ImageWindow *imd;
638
639         GtkWidget *normal_window;
640         ImageWindow *normal_imd;
641
642         gint hide_mouse_id;
643         gint busy_mouse_id;
644         gint cursor_state;
645
646         gint saver_block_id;
647
648         void (*stop_func)(FullScreenData *, gpointer);
649         gpointer stop_data;
650 };
651
652 struct _PixmapFolders
653 {
654         GdkPixbuf *close;
655         GdkPixbuf *open;
656         GdkPixbuf *deny;
657         GdkPixbuf *parent;
658 };
659
660
661 #endif
662
663