Sat Dec 2 16:44:48 2006 John Ellis <johne@verizon.net>
[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
402         /* dividers */
403
404         gint div_h;
405         gint div_v;
406         gint div_float;
407
408         /* directory update check */
409
410         gint last_time_id;
411         time_t last_time;
412
413         /* misc */
414
415         GtkWidget *utility_box;
416         GtkWidget *bar_sort;
417         GtkWidget *bar_exif;
418         GtkWidget *bar_info;
419
420         gint bar_sort_enabled;
421         gint bar_exif_enabled;
422         gint bar_info_enabled;
423
424         gint bar_exif_size;
425         gint bar_exif_advanced;
426 };
427
428 struct _ViewDirList
429 {
430         GtkWidget *widget;
431         GtkWidget *listview;
432
433         gchar *path;
434         GList *list;
435
436         FileData *click_fd;
437
438         FileData *drop_fd;
439         GList *drop_list;
440
441         gint drop_scroll_id;
442
443         /* func list */
444         void (*select_func)(ViewDirList *vdl, const gchar *path, gpointer data);
445         gpointer select_data;
446
447         LayoutWindow *layout;
448
449         GtkWidget *popup;
450
451         PixmapFolders *pf;
452 };
453
454 struct _ViewDirTree
455 {
456         GtkWidget *widget;
457         GtkWidget *treeview;
458
459         gchar *path;
460
461         FileData *click_fd;
462
463         FileData *drop_fd;
464         GList *drop_list;
465
466         gint drop_scroll_id;
467         gint drop_expand_id;
468
469         /* func list */
470         void (*select_func)(ViewDirTree *vdt, const gchar *path, gpointer data);
471         gpointer select_data;
472
473         LayoutWindow *layout;
474
475         GtkWidget *popup;
476
477         PixmapFolders *pf;
478
479         gint busy_ref;
480 };
481
482 struct _ViewFileList
483 {
484         GtkWidget *widget;
485         GtkWidget *listview;
486
487         gchar *path;
488         GList *list;
489
490         SortType sort_method;
491         gint sort_ascend;
492
493         FileData *click_fd;
494         FileData *select_fd;
495
496         gint thumbs_enabled;
497
498         /* thumb updates */
499         gint thumbs_running;
500         gint thumbs_count;
501         ThumbLoader *thumbs_loader;
502         FileData *thumbs_filedata;
503
504         /* func list */
505         void (*func_thumb_status)(ViewFileList *vfl, gdouble val, const gchar *text, gpointer data);
506         gpointer data_thumb_status;
507
508         void (*func_status)(ViewFileList *vfl, gpointer data);
509         gpointer data_status;
510
511         gint select_idle_id;
512         LayoutWindow *layout;
513
514         GtkWidget *popup;
515 };
516
517 struct _ViewFileIcon
518 {
519         GtkWidget *widget;
520         GtkWidget *listview;
521
522         gchar *path;
523         GList *list;
524
525         /* table stuff */
526
527         gint columns;
528         gint rows;
529
530         GList *selection;
531         FileData *prev_selection;
532
533         GtkWidget *tip_window;
534         gint tip_delay_id;
535         FileData *tip_fd;
536
537         FileData *click_fd;
538
539         FileData *focus_fd;
540         gint focus_row;
541         gint focus_column;
542
543         SortType sort_method;
544         gint sort_ascend;
545
546         gint show_text;
547
548         gint sync_idle_id;
549
550         /* thumbs */
551         
552         gint thumbs_running;
553         GList *thumbs_list;
554         gint thumbs_count;
555         ThumbLoader *thumbs_loader;
556         FileData *thumbs_fd;
557
558         /* func list */
559         void (*func_thumb_status)(ViewFileIcon *vfi, gdouble val, const gchar *text, gpointer data);
560         gpointer data_thumb_status;
561
562         void (*func_status)(ViewFileIcon *vfi, gpointer data);
563         gpointer data_status;
564
565         LayoutWindow *layout;
566
567         GtkWidget *popup;
568 };
569
570 struct _SlideShowData
571 {
572         ImageWindow *imd;
573
574         GList *path_list;
575         CollectionData *cd;
576         gchar *layout_path;
577         LayoutWindow *layout;
578
579         GList *list;
580         GList *list_done;
581
582         gchar *slide_path;
583
584         gint slide_count;
585         gint timeout_id;
586
587         gint from_selection;
588
589         void (*stop_func)(SlideShowData *, gpointer);
590         gpointer stop_data;
591
592         gint paused;
593 };
594
595 struct _FullScreenData
596 {
597         GtkWidget *window;
598         ImageWindow *imd;
599
600         GtkWidget *normal_window;
601         ImageWindow *normal_imd;
602
603         gint hide_mouse_id;
604         gint busy_mouse_id;
605         gint cursor_state;
606
607         gint saver_block_id;
608
609         void (*stop_func)(FullScreenData *, gpointer);
610         gpointer stop_data;
611 };
612
613 struct _PixmapFolders
614 {
615         GdkPixbuf *close;
616         GdkPixbuf *open;
617         GdkPixbuf *deny;
618         GdkPixbuf *parent;
619 };
620
621
622 #endif
623
624