Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
[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 *pr;
223         GtkWidget *frame;
224
225         gchar *image_path;
226         const gchar *image_name;
227
228         gint64 size;            /* file size (bytes) */
229         time_t mtime;           /* file modified time stamp */
230         gint unknown;           /* failed to load image */
231
232         ImageLoader *il;
233
234         gint has_frame;
235
236         /* top level (not necessarily parent) window */
237         gint top_window_sync;   /* resize top_window when image dimensions change */
238         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
239         gchar *title;           /* window title to display left of file name */
240         gchar *title_right;     /* window title to display right of file name */
241         gint title_show_zoom;   /* option to include zoom in window title */
242
243         gint completed;
244
245         void (*func_update)(ImageWindow *, gpointer);
246         void (*func_complete)(ImageWindow *, gint preload, gpointer);
247         void (*func_new)(ImageWindow *, gpointer);
248         ImageTileRequestFunc func_tile_request;
249         ImageTileDisposeFunc func_tile_dispose;
250
251         gpointer data_update;
252         gpointer data_complete;
253         gpointer data_new;
254         gpointer data_tile;
255
256         /* button, scroll functions */
257         void (*func_button)(ImageWindow *, gint button,
258                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
259         void (*func_scroll)(ImageWindow *, GdkScrollDirection direction,
260                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
261
262         gpointer data_button;
263         gpointer data_scroll;
264
265         /* scroll notification (for scroll bar implementation) */
266         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
267
268         gpointer data_scroll_notify;
269
270         /* collection info */
271         CollectionData *collection;
272         CollectInfo *collection_info;
273
274         AlterType delay_alter_type;
275
276         ImageLoader *read_ahead_il;
277         GdkPixbuf *read_ahead_pixbuf;
278         gchar *read_ahead_path;
279
280         GdkPixbuf *prev_pixbuf;
281         gchar *prev_path;
282
283         gint auto_refresh_id;
284         gint auto_refresh_interval;
285
286         gint delay_flip;
287 };
288
289 struct _FileData {
290         gchar *path;
291         const gchar *name;
292         gint64 size;
293         time_t date;
294
295         GdkPixbuf *pixbuf;
296 };
297
298 struct _LayoutWindow
299 {
300         gchar *path;
301
302         /* base */
303
304         GtkWidget *window;
305
306         GtkWidget *main_box;
307
308         GtkWidget *group_box;
309         GtkWidget *h_pane;
310         GtkWidget *v_pane;
311
312         /* menus, path selector */
313
314         GtkActionGroup *action_group;
315         GtkUIManager *ui_manager;
316
317         GtkWidget *path_entry;
318
319         /* image */
320
321         LayoutLocation image_location;
322
323         ImageWindow *image;
324
325         /* tools window (float) */
326
327         GtkWidget *tools;
328         GtkWidget *tools_pane;
329
330         gint tools_float;
331         gint tools_hidden;
332
333         /* toolbar */
334
335         GtkWidget *toolbar;
336         gint toolbar_hidden;
337
338         GtkWidget *thumb_button;
339         gint thumbs_enabled;
340
341         /* dir view */
342
343         LayoutLocation dir_location;
344
345         ViewDirList *vdl;
346         ViewDirTree *vdt;
347         GtkWidget *dir_view;
348
349         gint tree_view;
350
351         /* file view */
352
353         LayoutLocation file_location;
354
355         ViewFileList *vfl;
356         ViewFileIcon *vfi;
357         GtkWidget *file_view;
358
359         gint icon_view;
360         SortType sort_method;
361         gint sort_ascend;
362
363         /* status bar */
364
365         GtkWidget *info_box;
366         GtkWidget *info_progress_bar;
367         GtkWidget *info_sort;
368         GtkWidget *info_status;
369         GtkWidget *info_details;
370         GtkWidget *info_zoom;
371
372         /* slide show */
373
374         SlideShowData *slideshow;
375
376         /* full screen */
377
378         FullScreenData *full_screen;
379         gint full_screen_overlay_id;
380         gint full_screen_overlay_on;
381
382         /* dividers */
383
384         gint div_h;
385         gint div_v;
386         gint div_float;
387
388         /* directory update check */
389
390         gint last_time_id;
391         time_t last_time;
392
393         /* misc */
394
395         GtkWidget *utility_box;
396         GtkWidget *bar_sort;
397         GtkWidget *bar_exif;
398         GtkWidget *bar_info;
399
400         gint bar_sort_enabled;
401         gint bar_exif_enabled;
402         gint bar_info_enabled;
403
404         gint bar_exif_size;
405         gint bar_exif_advanced;
406 };
407
408 struct _ViewDirList
409 {
410         GtkWidget *widget;
411         GtkWidget *listview;
412
413         gchar *path;
414         GList *list;
415
416         FileData *click_fd;
417
418         FileData *drop_fd;
419         GList *drop_list;
420
421         gint drop_scroll_id;
422
423         /* func list */
424         void (*select_func)(ViewDirList *vdl, const gchar *path, gpointer data);
425         gpointer select_data;
426
427         LayoutWindow *layout;
428
429         GtkWidget *popup;
430
431         PixmapFolders *pf;
432 };
433
434 struct _ViewDirTree
435 {
436         GtkWidget *widget;
437         GtkWidget *treeview;
438
439         gchar *path;
440
441         FileData *click_fd;
442
443         FileData *drop_fd;
444         GList *drop_list;
445
446         gint drop_scroll_id;
447         gint drop_expand_id;
448
449         /* func list */
450         void (*select_func)(ViewDirTree *vdt, const gchar *path, gpointer data);
451         gpointer select_data;
452
453         LayoutWindow *layout;
454
455         GtkWidget *popup;
456
457         PixmapFolders *pf;
458
459         gint busy_ref;
460 };
461
462 struct _ViewFileList
463 {
464         GtkWidget *widget;
465         GtkWidget *listview;
466
467         gchar *path;
468         GList *list;
469
470         SortType sort_method;
471         gint sort_ascend;
472
473         FileData *click_fd;
474         FileData *select_fd;
475
476         gint thumbs_enabled;
477
478         /* thumb updates */
479         gint thumbs_running;
480         gint thumbs_count;
481         ThumbLoader *thumbs_loader;
482         FileData *thumbs_filedata;
483
484         /* func list */
485         void (*func_thumb_status)(ViewFileList *vfl, gdouble val, const gchar *text, gpointer data);
486         gpointer data_thumb_status;
487
488         void (*func_status)(ViewFileList *vfl, gpointer data);
489         gpointer data_status;
490
491         gint select_idle_id;
492         LayoutWindow *layout;
493
494         GtkWidget *popup;
495 };
496
497 struct _ViewFileIcon
498 {
499         GtkWidget *widget;
500         GtkWidget *listview;
501
502         gchar *path;
503         GList *list;
504
505         /* table stuff */
506
507         gint columns;
508         gint rows;
509
510         GList *selection;
511         FileData *prev_selection;
512
513         GtkWidget *tip_window;
514         gint tip_delay_id;
515         FileData *tip_fd;
516
517         FileData *click_fd;
518
519         FileData *focus_fd;
520         gint focus_row;
521         gint focus_column;
522
523         SortType sort_method;
524         gint sort_ascend;
525
526         gint show_text;
527
528         gint sync_idle_id;
529
530         /* thumbs */
531         
532         gint thumbs_running;
533         GList *thumbs_list;
534         gint thumbs_count;
535         ThumbLoader *thumbs_loader;
536         FileData *thumbs_fd;
537
538         /* func list */
539         void (*func_thumb_status)(ViewFileIcon *vfi, gdouble val, const gchar *text, gpointer data);
540         gpointer data_thumb_status;
541
542         void (*func_status)(ViewFileIcon *vfi, gpointer data);
543         gpointer data_status;
544
545         LayoutWindow *layout;
546
547         GtkWidget *popup;
548 };
549
550 struct _SlideShowData
551 {
552         ImageWindow *imd;
553
554         GList *path_list;
555         CollectionData *cd;
556         gchar *layout_path;
557         LayoutWindow *layout;
558
559         GList *list;
560         GList *list_done;
561
562         gchar *slide_path;
563
564         gint slide_count;
565         gint timeout_id;
566
567         gint from_selection;
568
569         void (*stop_func)(SlideShowData *, gpointer);
570         gpointer stop_data;
571
572         gint paused;
573 };
574
575 struct _FullScreenData
576 {
577         GtkWidget *window;
578         ImageWindow *imd;
579
580         GtkWidget *normal_window;
581         ImageWindow *normal_imd;
582
583         gint hide_mouse_id;
584         gint busy_mouse_id;
585         gint cursor_state;
586
587         gint saver_block_id;
588
589         void (*stop_func)(FullScreenData *, gpointer);
590         gpointer stop_data;
591 };
592
593 struct _PixmapFolders
594 {
595         GdkPixbuf *close;
596         GdkPixbuf *open;
597         GdkPixbuf *deny;
598         GdkPixbuf *parent;
599 };
600
601
602 #endif
603
604