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