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