Use uft8_collate_key() to sort utf8 strings.
[geeqie.git] / src / typedefs.h
1 /*
2  * Geeqie
3  * (C) 2006 John Ellis
4  * Copyright (C) 2008 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #ifndef TYPEDEFS_H
15 #define TYPEDEFS_H
16
17 typedef enum {
18         MOUSE_BUTTON_LEFT       = 1,
19         MOUSE_BUTTON_MIDDLE     = 2,
20         MOUSE_BUTTON_RIGHT      = 3,
21         MOUSE_BUTTON_WHEEL_UP   = 4,
22         MOUSE_BUTTON_WHEEL_DOWN = 5
23 } MouseButton;
24
25 typedef enum {
26         DIRVIEW_LIST,
27         DIRVIEW_TREE
28 } DirViewType;
29
30 typedef enum {
31         FILEVIEW_LIST,
32         FILEVIEW_ICON
33 } FileViewType;
34
35 typedef enum {
36         CMD_COPY = GQ_EDITOR_GENERIC_SLOTS,
37         CMD_MOVE,
38         CMD_RENAME,
39         CMD_DELETE,
40         CMD_FOLDER,
41         GQ_EDITOR_SLOTS
42 } SpecialEditor;
43
44 typedef enum {
45         SORT_NONE,
46         SORT_NAME,
47         SORT_SIZE,
48         SORT_TIME,
49         SORT_PATH,
50         SORT_NUMBER
51 } SortType;
52
53 typedef enum {
54         ALTER_NONE,             /* do nothing */
55         ALTER_ROTATE_90,
56         ALTER_ROTATE_90_CC,     /* counterclockwise */
57         ALTER_ROTATE_180,
58         ALTER_MIRROR,
59         ALTER_FLIP,
60         ALTER_DESATURATE
61 } AlterType;
62
63 typedef enum {
64         LAYOUT_HIDE   = 0,
65         LAYOUT_LEFT   = 1 << 0,
66         LAYOUT_RIGHT  = 1 << 1,
67         LAYOUT_TOP    = 1 << 2,
68         LAYOUT_BOTTOM = 1 << 3
69 } LayoutLocation;
70
71
72 typedef enum {
73         IMAGE_STATE_NONE        = 0,
74         IMAGE_STATE_IMAGE       = 1 << 0,
75         IMAGE_STATE_LOADING     = 1 << 1,
76         IMAGE_STATE_ERROR       = 1 << 2,
77         IMAGE_STATE_COLOR_ADJ   = 1 << 3,
78         IMAGE_STATE_ROTATE_AUTO = 1 << 4,
79         IMAGE_STATE_ROTATE_USER = 1 << 5,
80         IMAGE_STATE_DELAY_FLIP  = 1 << 6
81 } ImageState;
82
83 typedef enum {
84         SPLIT_NONE = 0,
85         SPLIT_VERT,
86         SPLIT_HOR,
87         SPLIT_QUAD,
88 } ImageSplitMode;
89
90 typedef enum {
91         FILEDATA_CHANGE_DELETE,
92         FILEDATA_CHANGE_MOVE,
93         FILEDATA_CHANGE_RENAME,
94         FILEDATA_CHANGE_COPY,
95         FILEDATA_CHANGE_UNSPECIFIED
96 } FileDataChangeType;
97
98 typedef enum {
99         MTS_MODE_MINUS,
100         MTS_MODE_SET,
101         MTS_MODE_OR,
102         MTS_MODE_AND
103 } MarkToSelectionMode;
104
105 typedef enum {
106         STM_MODE_RESET,
107         STM_MODE_SET,
108         STM_MODE_TOGGLE
109 } SelectionToMarkMode;
110
111 typedef enum {
112         FORMAT_CLASS_UNKNOWN,
113         FORMAT_CLASS_IMAGE,
114         FORMAT_CLASS_RAWIMAGE,
115         FORMAT_CLASS_META,
116         FILE_FORMAT_CLASSES
117 } FileFormatClass;
118
119 typedef enum {
120         SS_ERR_NONE = 0,
121         SS_ERR_DISABLED, /**< secsave is disabled. */
122         SS_ERR_OUT_OF_MEM, /**< memory allocation failure */
123
124         /* see err field in SecureSaveInfo */
125         SS_ERR_OPEN_READ,
126         SS_ERR_OPEN_WRITE,
127         SS_ERR_STAT,
128         SS_ERR_ACCESS,
129         SS_ERR_MKSTEMP,
130         SS_ERR_RENAME,
131         SS_ERR_OTHER,
132 } SecureSaveErrno;
133
134
135 #define MAX_SPLIT_IMAGES 4
136
137 typedef struct _ImageLoader ImageLoader;
138 typedef struct _ThumbLoader ThumbLoader;
139
140 typedef struct _CollectInfo CollectInfo;
141 typedef struct _CollectionData CollectionData;
142 typedef struct _CollectTable CollectTable;
143 typedef struct _CollectWindow CollectWindow;
144
145 typedef struct _ImageWindow ImageWindow;
146
147 typedef struct _FileData FileData;
148 typedef struct _FileDataChangeInfo FileDataChangeInfo;
149
150 typedef struct _LayoutWindow LayoutWindow;
151
152 typedef struct _ViewDir ViewDir;
153 typedef struct _ViewDirInfoList ViewDirInfoList;
154 typedef struct _ViewDirInfoTree ViewDirInfoTree;
155
156 typedef struct _ViewFile ViewFile;
157 typedef struct _ViewFileInfoList ViewFileInfoList;
158 typedef struct _ViewFileInfoIcon ViewFileInfoIcon;
159
160 typedef struct _SlideShowData SlideShowData;
161 typedef struct _FullScreenData FullScreenData;
162
163 typedef struct _PixmapFolders PixmapFolders;
164 typedef struct _Histogram Histogram;
165
166 typedef struct _SecureSaveInfo SecureSaveInfo;
167
168 typedef struct _Editor Editor;
169 struct _Editor {
170         gchar *name;
171         gchar *command;
172 };
173
174 struct _ImageLoader
175 {
176         GdkPixbuf *pixbuf;
177         FileData *fd;
178         gchar *path;
179
180         gint bytes_read;
181         gint bytes_total;
182
183         gint requested_width;
184         gint requested_height;
185         gint shrunk;
186
187         gint done;
188         gint idle_id;
189         gint idle_priority;
190
191         GdkPixbufLoader *loader;
192         gint load_fd;
193
194         void (*func_area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
195         void (*func_error)(ImageLoader *, gpointer);
196         void (*func_done)(ImageLoader *, gpointer);
197         void (*func_percent)(ImageLoader *, gdouble, gpointer);
198
199         gpointer data_area_ready;
200         gpointer data_error;
201         gpointer data_done;
202         gpointer data_percent;
203
204         gint idle_done_id;
205
206         guchar *read_buffer;
207         gint read_buffer_size;
208         gint idle_read_loop_count;
209 };
210
211 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
212
213 struct _ThumbLoader
214 {
215         gint standard_loader;
216
217         GdkPixbuf *pixbuf;      /* contains final (scaled) image when done */
218         ImageLoader *il;
219         gchar *path;
220
221         gint cache_enable;
222         gint cache_hit;
223         gdouble percent_done;
224
225         gint max_w;
226         gint max_h;
227
228         ThumbLoaderFunc func_done;
229         ThumbLoaderFunc func_error;
230         ThumbLoaderFunc func_progress;
231
232         gpointer data;
233
234         gint idle_done_id;
235 };
236
237 struct _CollectInfo
238 {
239         FileData *fd;
240         GdkPixbuf *pixbuf;
241         guint flag_mask;
242 };
243
244 struct _CollectionData
245 {
246         gchar *path;
247         gchar *name;
248         GList *list;
249         SortType sort_method;
250
251         ThumbLoader *thumb_loader;
252         CollectInfo *thumb_info;
253
254         void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
255         gpointer info_updated_data;
256
257         gint ref;
258
259         /* geometry */
260         gint window_read;
261         gint window_x;
262         gint window_y;
263         gint window_w;
264         gint window_h;
265
266         /* contents changed since save flag */
267         gint changed;
268
269         GHashTable *existence;
270 };
271
272 struct _CollectTable
273 {
274         GtkWidget *scrolled;
275         GtkWidget *listview;
276         gint columns;
277         gint rows;
278
279         CollectionData *cd;
280
281         GList *selection;
282         CollectInfo *prev_selection;
283
284         CollectInfo *click_info;
285
286         GtkWidget *tip_window;
287         gint tip_delay_id;
288         CollectInfo *tip_info;
289
290         GdkWindow *marker_window;
291         CollectInfo *marker_info;
292
293         GtkWidget *status_label;
294         GtkWidget *extra_label;
295
296         gint focus_row;
297         gint focus_column;
298         CollectInfo *focus_info;
299
300         GtkWidget *popup;
301         CollectInfo *drop_info;
302         GList *drop_list;
303
304         gint sync_idle_id;
305         gint drop_idle_id;
306
307         gint show_text;
308 };
309
310 struct _CollectWindow
311 {
312         GtkWidget *window;
313         CollectTable *table;
314         GtkWidget *status_box;
315         GList *list;
316
317         GtkWidget *close_dialog;
318
319         CollectionData *cd;
320 };
321
322 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
323                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
324 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
325                                       gint width, gint height, GdkPixbuf *pixbuf, gpointer);
326
327 struct _ImageWindow
328 {
329         GtkWidget *widget;      /* use this to add it and show it */
330         GtkWidget *pr;
331         GtkWidget *frame;
332
333         FileData *image_fd;
334
335         gint64 size;            /* file size (bytes) */
336         time_t mtime;           /* file modified time stamp */
337         gint unknown;           /* failed to load image */
338
339         ImageLoader *il;
340
341         gint has_frame;
342
343         /* top level (not necessarily parent) window */
344         gint top_window_sync;   /* resize top_window when image dimensions change */
345         GtkWidget *top_window;  /* window that gets title, and window to resize when 'fitting' */
346         gchar *title;           /* window title to display left of file name */
347         gchar *title_right;     /* window title to display right of file name */
348         gint title_show_zoom;   /* option to include zoom in window title */
349
350         gint completed;
351         ImageState state;       /* mask of IMAGE_STATE_* flags about current image */
352
353         void (*func_update)(ImageWindow *imd, gpointer data);
354         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
355         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
356         ImageTileRequestFunc func_tile_request;
357         ImageTileDisposeFunc func_tile_dispose;
358
359         gpointer data_update;
360         gpointer data_complete;
361         gpointer data_state;
362         gpointer data_tile;
363
364         /* button, scroll functions */
365         void (*func_button)(ImageWindow *, gint button,
366                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
367         void (*func_drag)(ImageWindow *, gint button,
368                             guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy,gpointer);
369         void (*func_scroll)(ImageWindow *, GdkScrollDirection direction,
370                             guint32 time, gdouble x, gdouble y, guint state, gpointer);
371
372         gpointer data_button;
373         gpointer data_drag;
374         gpointer data_scroll;
375
376         /* scroll notification (for scroll bar implementation) */
377         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
378
379         gpointer data_scroll_notify;
380
381         /* collection info */
382         CollectionData *collection;
383         CollectInfo *collection_info;
384
385         /* color profiles */
386         gint color_profile_enable;
387         gint color_profile_input;
388         gint color_profile_screen;
389         gint color_profile_use_image;
390         gint color_profile_from_image;
391         gpointer cm;
392
393         AlterType delay_alter_type;
394
395         ImageLoader *read_ahead_il;
396         GdkPixbuf *read_ahead_pixbuf;
397         FileData *read_ahead_fd;
398
399         GdkPixbuf *prev_pixbuf;
400         FileData *prev_fd;
401         gint prev_color_row;
402
403         gint auto_refresh_id;
404         gint auto_refresh_interval;
405
406         gint delay_flip;
407         gint orientation;
408         gint desaturate;
409
410         gint overlay_show_zoom; /* set to true if overlay is showing zoom ratio */
411 };
412
413 #define FILEDATA_MARKS_SIZE 6
414
415 struct _FileDataChangeInfo {
416         FileDataChangeType type;
417         gchar *source;
418         gchar *dest;
419 };
420
421 struct _FileData {
422         gint magick;
423         gint type;
424         gchar *original_path; /* key to file_data_pool hash table */
425         gchar *path;
426         const gchar *name;
427         const gchar *extension;
428         gchar *collate_key_name;
429         gchar *collate_key_name_nocase;
430         gint64 size;
431         time_t date;
432         gboolean marks[FILEDATA_MARKS_SIZE];
433         GList *sidecar_files;
434         FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
435         FileDataChangeInfo *change; /* for rename, move ... */
436         GdkPixbuf *pixbuf;
437         gint ref;
438         gint version; /* increased when any field in this structure is changed */
439         gint user_orientation;
440         gint exif_orientation;
441 };
442
443 struct _LayoutWindow
444 {
445         FileData *dir_fd;
446
447         /* base */
448
449         GtkWidget *window;
450
451         GtkWidget *main_box;
452
453         GtkWidget *group_box;
454         GtkWidget *h_pane;
455         GtkWidget *v_pane;
456
457         /* menus, path selector */
458
459         GtkActionGroup *action_group;
460         GtkUIManager *ui_manager;
461
462         GtkWidget *path_entry;
463
464         /* image */
465
466         LayoutLocation image_location;
467
468         ImageWindow *image;
469
470         ImageWindow *split_images[MAX_SPLIT_IMAGES];
471         ImageSplitMode split_mode;
472         gint active_split_image;
473
474         GtkWidget *split_image_widget;
475
476         gint connect_zoom, connect_scroll;
477
478         /* tools window (float) */
479
480         GtkWidget *tools;
481         GtkWidget *tools_pane;
482
483         gint tools_float;
484         gint tools_hidden;
485
486         /* toolbar */
487
488         GtkWidget *toolbar;
489         gint toolbar_hidden;
490
491         GtkWidget *thumb_button;
492         gint thumbs_enabled;
493         gint marks_enabled;
494
495         /* dir view */
496
497         LayoutLocation dir_location;
498
499         ViewDir *vd;
500         GtkWidget *dir_view;
501
502         DirViewType dir_view_type;
503
504         /* file view */
505
506         LayoutLocation file_location;
507
508         ViewFile *vf;
509         FileViewType file_view_type;
510
511         GtkWidget *file_view;
512
513         SortType sort_method;
514         gint sort_ascend;
515
516         /* status bar */
517
518         GtkWidget *info_box;
519         GtkWidget *info_progress_bar;
520         GtkWidget *info_sort;
521         GtkWidget *info_color;
522         GtkWidget *info_status;
523         GtkWidget *info_details;
524         GtkWidget *info_zoom;
525
526         /* slide show */
527
528         SlideShowData *slideshow;
529
530         /* full screen */
531
532         FullScreenData *full_screen;
533
534         /* dividers */
535
536         gint div_h;
537         gint div_v;
538         gint div_float;
539
540         /* directory update check */
541
542         gint last_time_id;
543         gint last_version;
544
545         /* misc */
546
547         GtkWidget *utility_box;
548         GtkWidget *bar_sort;
549         GtkWidget *bar_exif;
550         GtkWidget *bar_info;
551
552         gint bar_sort_enabled;
553         gint bar_exif_enabled;
554         gint bar_info_enabled;
555
556         gint bar_exif_width;
557         gint bar_exif_advanced;
558         gint bar_info_width;
559 };
560
561 struct _ViewDir
562 {
563         DirViewType type;
564         gpointer info;
565
566         GtkWidget *widget;
567         GtkWidget *view;
568
569         FileData *dir_fd;
570
571         FileData *click_fd;
572
573         FileData *drop_fd;
574         GList *drop_list;
575         gint drop_scroll_id;
576
577         /* func list */
578         void (*select_func)(ViewDir *vd, const gchar *path, gpointer data);
579         gpointer select_data;
580
581         void (*dnd_drop_update_func)(ViewDir *vd);
582         void (*dnd_drop_leave_func)(ViewDir *vd);
583
584         LayoutWindow *layout;
585
586         GtkWidget *popup;
587
588         PixmapFolders *pf;
589 };
590
591 struct _ViewDirInfoList
592 {
593         GList *list;
594 };
595
596 struct _ViewDirInfoTree
597 {
598         gint drop_expand_id;
599         gint busy_ref;
600 };
601
602
603 struct _ViewFile
604 {
605         FileViewType type;
606         gpointer info;
607
608         GtkWidget *widget;
609         GtkWidget *listview;
610
611         FileData *dir_fd;
612         GList *list;
613
614         SortType sort_method;
615         gint sort_ascend;
616
617         /* func list */
618         void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
619         gpointer data_thumb_status;
620
621         void (*func_status)(ViewFile *vf, gpointer data);
622         gpointer data_status;
623
624         LayoutWindow *layout;
625
626         GtkWidget *popup;
627
628         /* thumbs updates*/
629         gint thumbs_running;
630         gint thumbs_count;
631         ThumbLoader *thumbs_loader;
632         FileData *thumbs_filedata;
633
634         /* marks */
635         gint marks_enabled;
636         gint active_mark;
637         gint clicked_mark;
638         
639         /* refresh */
640         gint refresh_idle_id; /* used only in vflist for now */
641 };
642
643 struct _ViewFileInfoList
644 {
645         FileData *click_fd;
646         FileData *select_fd;
647
648         gint thumbs_enabled;
649
650         gint select_idle_id;
651 };
652
653 struct _IconData;
654
655 struct _ViewFileInfoIcon
656 {
657         /* table stuff */
658         gint columns;
659         gint rows;
660
661         GList *selection;
662         struct _IconData *prev_selection;
663
664         GtkWidget *tip_window;
665         gint tip_delay_id;
666         struct _IconData *tip_id;
667
668         struct _IconData *click_id;
669
670         struct _IconData *focus_id;
671         gint focus_row;
672         gint focus_column;
673
674         gint show_text;
675
676         gint sync_idle_id;
677 };
678
679 struct _SlideShowData
680 {
681         ImageWindow *imd;
682
683         GList *filelist;
684         CollectionData *cd;
685         FileData *dir_fd;
686         LayoutWindow *layout;
687
688         GList *list;
689         GList *list_done;
690
691         FileData *slide_fd;
692
693         guint slide_count;
694         gint timeout_id;
695
696         gint from_selection;
697
698         void (*stop_func)(SlideShowData *, gpointer);
699         gpointer stop_data;
700
701         gint paused;
702 };
703
704 struct _FullScreenData
705 {
706         GtkWidget *window;
707         ImageWindow *imd;
708
709         GtkWidget *normal_window;
710         ImageWindow *normal_imd;
711
712         gint hide_mouse_id;
713         gint busy_mouse_id;
714         gint cursor_state;
715
716         gint saver_block_id;
717
718         void (*stop_func)(FullScreenData *, gpointer);
719         gpointer stop_data;
720 };
721
722 struct _PixmapFolders
723 {
724         GdkPixbuf *close;
725         GdkPixbuf *open;
726         GdkPixbuf *deny;
727         GdkPixbuf *parent;
728 };
729
730 struct _SecureSaveInfo {
731         FILE *fp; /**< file stream pointer */
732         gchar *file_name; /**< final file name */
733         gchar *tmp_file_name; /**< temporary file name */
734         gint err; /**< set to non-zero value in case of error */
735         gint secure_save; /**< use secure save for this file, internal use only */
736         gint preserve_perms; /**< whether to preserve perms, TRUE by default */
737         gint preserve_mtime; /**< whether to preserve mtime, FALSE by default */
738         gint unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
739 };
740
741
742 #endif