2 * Copyright (C) 2006 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 ZOOM_RESET_ORIGINAL = 0,
27 ZOOM_RESET_FIT_WINDOW = 1,
37 MOUSE_BUTTON_LEFT = 1,
38 MOUSE_BUTTON_MIDDLE = 2,
39 MOUSE_BUTTON_RIGHT = 3,
40 MOUSE_BUTTON_WHEEL_UP = 4,
41 MOUSE_BUTTON_WHEEL_DOWN = 5,
50 // Keep this up to date!
51 DIRVIEW_LAST = DIRVIEW_TREE
58 // Keep this up to date!
59 FILEVIEW_LAST = FILEVIEW_ICON
62 #define CMD_COPY "geeqie-copy-command.desktop"
63 #define CMD_MOVE "geeqie-move-command.desktop"
64 #define CMD_RENAME "geeqie-rename-command.desktop"
65 #define CMD_DELETE "geeqie-delete-command.desktop"
66 #define CMD_FOLDER "geeqie-folder-command.desktop"
77 SORT_EXIFTIMEDIGITIZED,
83 ALTER_NONE, /* do nothing */
85 ALTER_ROTATE_90_CC, /* counterclockwise */
94 LAYOUT_RIGHT = 1 << 1,
96 LAYOUT_BOTTOM = 1 << 3
101 IMAGE_STATE_NONE = 0,
102 IMAGE_STATE_IMAGE = 1 << 0,
103 IMAGE_STATE_LOADING = 1 << 1,
104 IMAGE_STATE_ERROR = 1 << 2,
105 IMAGE_STATE_COLOR_ADJ = 1 << 3,
106 IMAGE_STATE_ROTATE_AUTO = 1 << 4,
107 IMAGE_STATE_ROTATE_USER = 1 << 5,
108 IMAGE_STATE_DELAY_FLIP = 1 << 6
119 FILEDATA_CHANGE_DELETE,
120 FILEDATA_CHANGE_MOVE,
121 FILEDATA_CHANGE_RENAME,
122 FILEDATA_CHANGE_COPY,
123 FILEDATA_CHANGE_UNSPECIFIED,
124 FILEDATA_CHANGE_WRITE_METADATA
125 } FileDataChangeType;
132 } MarkToSelectionMode;
138 } SelectionToMarkMode;
141 FORMAT_CLASS_UNKNOWN,
143 FORMAT_CLASS_RAWIMAGE,
146 FORMAT_CLASS_COLLECTION,
147 FORMAT_CLASS_DOCUMENT,
151 extern gchar *format_class_list[];
155 SS_ERR_DISABLED, /**< secsave is disabled. */
156 SS_ERR_OUT_OF_MEM, /**< memory allocation failure */
158 /* see err field in SecureSaveInfo */
169 NOTIFY_PRIORITY_HIGH = 0,
170 NOTIFY_PRIORITY_MEDIUM,
175 NOTIFY_MARKS = 1 << 1, /* changed marks */
176 NOTIFY_PIXBUF = 1 << 2, /* image was read into fd->pixbuf */
177 NOTIFY_HISTMAP = 1 << 3, /* histmap was read into fd->histmap */
178 NOTIFY_ORIENTATION = 1 << 4, /* image was rotated */
179 NOTIFY_METADATA = 1 << 5, /* changed image metadata, not yet written */
180 NOTIFY_GROUPING = 1 << 6, /* change in fd->sidecar_files or fd->parent */
181 NOTIFY_REREAD = 1 << 7, /* changed file size, date, etc., file name remains unchanged */
182 NOTIFY_CHANGE = 1 << 8 /* generic change described by fd->change */
187 CHANGE_WARN_DEST_EXISTS = 1 << 0,
188 CHANGE_WARN_NO_WRITE_PERM = 1 << 1,
189 CHANGE_WARN_SAME = 1 << 2,
190 CHANGE_WARN_CHANGED_EXT = 1 << 3,
191 CHANGE_WARN_UNSAVED_META = 1 << 4,
192 CHANGE_WARN_NO_WRITE_PERM_DEST_DIR = 1 << 5,
193 CHANGE_ERROR_MASK = (~0U) << 8, /* the values below are fatal errors */
194 CHANGE_NO_READ_PERM = 1 << 8,
195 CHANGE_NO_WRITE_PERM_DIR = 1 << 9,
196 CHANGE_NO_DEST_DIR = 1 << 10,
197 CHANGE_DUPLICATE_DEST = 1 << 11,
198 CHANGE_NO_WRITE_PERM_DEST = 1 << 12,
199 CHANGE_DEST_EXISTS = 1 << 13,
200 CHANGE_NO_SRC = 1 << 14,
201 CHANGE_GENERIC_ERROR = 1 << 16
205 METADATA_PLAIN = 0, /* format that can be edited and written back */
206 METADATA_FORMATTED = 1 /* for display only */
210 STARTUP_PATH_CURRENT = 0,
222 PR_STEREO_NONE = 0, /* do nothing */
223 PR_STEREO_DUAL = 1 << 0, /* independent stereo buffers, for example nvidia opengl */
224 PR_STEREO_FIXED = 1 << 1, /* custom position */
225 PR_STEREO_HORIZ = 1 << 2, /* side by side */
226 PR_STEREO_VERT = 1 << 3, /* above below */
227 PR_STEREO_RIGHT = 1 << 4, /* render right buffer */
228 PR_STEREO_ANAGLYPH_RC = 1 << 5, /* anaglyph red-cyan */
229 PR_STEREO_ANAGLYPH_GM = 1 << 6, /* anaglyph green-magenta */
230 PR_STEREO_ANAGLYPH_YB = 1 << 7, /* anaglyph yellow-blue */
231 PR_STEREO_ANAGLYPH_GRAY_RC = 1 << 8, /* anaglyph gray red-cyan*/
232 PR_STEREO_ANAGLYPH_GRAY_GM = 1 << 9, /* anaglyph gray green-magenta */
233 PR_STEREO_ANAGLYPH_GRAY_YB = 1 << 10, /* anaglyph gray yellow-blue */
234 PR_STEREO_ANAGLYPH_DB_RC = 1 << 11, /* anaglyph dubois red-cyan */
235 PR_STEREO_ANAGLYPH_DB_GM = 1 << 12, /* anaglyph dubois green-magenta */
236 PR_STEREO_ANAGLYPH_DB_YB = 1 << 13, /* anaglyph dubois yellow-blue */
237 PR_STEREO_ANAGLYPH = PR_STEREO_ANAGLYPH_RC |
238 PR_STEREO_ANAGLYPH_GM |
239 PR_STEREO_ANAGLYPH_YB |
240 PR_STEREO_ANAGLYPH_GRAY_RC |
241 PR_STEREO_ANAGLYPH_GRAY_GM |
242 PR_STEREO_ANAGLYPH_GRAY_YB |
243 PR_STEREO_ANAGLYPH_DB_RC |
244 PR_STEREO_ANAGLYPH_DB_GM |
245 PR_STEREO_ANAGLYPH_DB_YB, /* anaglyph mask */
247 PR_STEREO_MIRROR_LEFT = 1 << 14, /* mirror */
248 PR_STEREO_FLIP_LEFT = 1 << 15, /* flip */
250 PR_STEREO_MIRROR_RIGHT = 1 << 16, /* mirror */
251 PR_STEREO_FLIP_RIGHT = 1 << 17, /* flip */
253 PR_STEREO_MIRROR = PR_STEREO_MIRROR_LEFT | PR_STEREO_MIRROR_RIGHT, /* mirror mask*/
254 PR_STEREO_FLIP = PR_STEREO_FLIP_LEFT | PR_STEREO_FLIP_RIGHT, /* flip mask*/
255 PR_STEREO_SWAP = 1 << 18, /* swap left and right buffers */
256 PR_STEREO_TEMP_DISABLE = 1 << 19, /* temporarily disable stereo mode if source image is not stereo */
257 PR_STEREO_HALF = 1 << 20
258 } PixbufRendererStereoMode;
261 STEREO_PIXBUF_DEFAULT = 0,
262 STEREO_PIXBUF_SBS = 1,
263 STEREO_PIXBUF_CROSS = 2,
264 STEREO_PIXBUF_NONE = 3
267 #define MAX_SPLIT_IMAGES 4
271 SELECTION_SELECTED = 1 << 0,
272 SELECTION_PRELIGHT = 1 << 1,
273 SELECTION_FOCUS = 1 << 2
276 typedef struct _ImageLoader ImageLoader;
277 typedef struct _ThumbLoader ThumbLoader;
279 typedef struct _AnimationData AnimationData;
281 typedef struct _CollectInfo CollectInfo;
282 typedef struct _CollectionData CollectionData;
283 typedef struct _CollectTable CollectTable;
284 typedef struct _CollectWindow CollectWindow;
286 typedef struct _ImageWindow ImageWindow;
288 typedef struct _FileData FileData;
289 typedef struct _FileDataChangeInfo FileDataChangeInfo;
291 typedef struct _LayoutWindow LayoutWindow;
292 typedef struct _LayoutOptions LayoutOptions;
294 typedef struct _ViewDir ViewDir;
295 typedef struct _ViewDirInfoList ViewDirInfoList;
296 typedef struct _ViewDirInfoTree ViewDirInfoTree;
298 typedef struct _ViewFile ViewFile;
299 typedef struct _ViewFileInfoList ViewFileInfoList;
300 typedef struct _ViewFileInfoIcon ViewFileInfoIcon;
302 typedef struct _SlideShowData SlideShowData;
303 typedef struct _FullScreenData FullScreenData;
305 typedef struct _PixmapFolders PixmapFolders;
306 typedef struct _Histogram Histogram;
307 typedef struct _HistMap HistMap;
309 typedef struct _SecureSaveInfo SecureSaveInfo;
311 typedef struct _ExifData ExifData;
313 typedef struct _EditorDescription EditorDescription;
315 typedef struct _CommandLine CommandLine;
318 gint histogram_channel; /* drawing mode for histogram */
319 gint histogram_mode; /* logarithmical or not */
320 guint vgrid; /* number of vertical divisions, 0 for none */
321 guint hgrid; /* number of horizontal divisions, 0 for none */
327 } grid_color; /* grid color */
335 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
337 typedef void (* FileUtilDoneFunc)(gboolean success, const gchar *done_path, gpointer data);
341 gboolean standard_loader;
344 FileData *fd; /* fd->pixbuf contains final (scaled) image when done */
346 gboolean cache_enable;
348 gdouble percent_done;
353 ThumbLoaderFunc func_done;
354 ThumbLoaderFunc func_error;
355 ThumbLoaderFunc func_progress;
359 guint idle_done_id; /* event source id */
362 struct _AnimationData
366 GdkPixbufAnimation *gpa;
367 GdkPixbufAnimationIter *iter;
372 GCancellable *cancellable;
374 GFileInputStream *gfstream;
384 struct _CollectionData
389 SortType sort_method;
391 ThumbLoader *thumb_loader;
392 CollectInfo *thumb_info;
394 void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
395 gpointer info_updated_data;
406 /* contents changed since save flag */
409 GHashTable *existence;
422 CollectInfo *prev_selection;
424 CollectInfo *click_info;
426 GtkWidget *tip_window;
427 guint tip_delay_id; /* event source id */
428 CollectInfo *tip_info;
430 GdkWindow *marker_window;
431 CollectInfo *marker_info;
433 GtkWidget *status_label;
434 GtkWidget *extra_label;
438 CollectInfo *focus_info;
441 CollectInfo *drop_info;
444 guint sync_idle_id; /* event source id */
445 guint drop_idle_id; /* event source id */
450 /* file list for edit menu */
451 GList *editmenu_fd_list;
454 struct _CollectWindow
458 GtkWidget *status_box;
460 GtkWidget *close_dialog;
465 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
466 gint width, gint height, GdkPixbuf *pixbuf, gpointer);
467 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
468 gint width, gint height, GdkPixbuf *pixbuf, gpointer);
472 GtkWidget *widget; /* use this to add it and show it */
478 gboolean unknown; /* failed to load image */
480 ImageLoader *il; /* FIXME - image loader should probably go to FileData, but it must first support
481 sending callbacks to multiple ImageWindows in parallel */
483 gint has_frame; /* not boolean, see image_new() */
485 /* top level (not necessarily parent) window */
486 gboolean top_window_sync; /* resize top_window when image dimensions change */
487 GtkWidget *top_window; /* window that gets title, and window to resize when 'fitting' */
488 gchar *title; /* window title to display left of file name */
489 gchar *title_right; /* window title to display right of file name */
490 gboolean title_show_zoom; /* option to include zoom in window title */
493 ImageState state; /* mask of IMAGE_STATE_* flags about current image */
495 void (*func_update)(ImageWindow *imd, gpointer data);
496 void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
497 void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
498 ImageTileRequestFunc func_tile_request;
499 ImageTileDisposeFunc func_tile_dispose;
501 gpointer data_update;
502 gpointer data_complete;
506 /* button, scroll functions */
507 void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer);
508 void (*func_drag)(ImageWindow *, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer);
509 void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer);
510 void (*func_focus_in)(ImageWindow *, gpointer);
512 gpointer data_button;
514 gpointer data_scroll;
515 gpointer data_focus_in;
517 /* scroll notification (for scroll bar implementation) */
518 void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
520 gpointer data_scroll_notify;
522 /* collection info */
523 CollectionData *collection;
524 CollectInfo *collection_info;
527 gboolean color_profile_enable;
528 gint color_profile_input;
529 gboolean color_profile_use_image;
530 gint color_profile_from_image;
533 AlterType delay_alter_type;
535 FileData *read_ahead_fd;
536 ImageLoader *read_ahead_il;
540 gboolean auto_refresh;
545 gboolean overunderexposed;
548 gboolean mouse_wheel_mode;
551 #define FILEDATA_MARKS_SIZE 10
553 struct _FileDataChangeInfo {
554 FileDataChangeType type;
558 gboolean regroup_when_finished;
564 gchar *original_path; /* key to file_data_pool hash table */
567 const gchar *extension;
568 gchar *extended_extension;
569 FileFormatClass format_class;
570 gchar *collate_key_name;
571 gchar *collate_key_name_nocase;
575 mode_t mode; /* this is needed at least for notification in view_dir because it is preserved after the file/directory is deleted */
576 gint sidecar_priority;
578 guint marks; /* each bit represents one mark */
579 guint valid_marks; /* zero bit means that the corresponding mark needs to be reread */
582 GList *sidecar_files;
583 FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
584 FileDataChangeInfo *change; /* for rename, move ... */
585 GdkPixbuf *thumb_pixbuf;
587 GdkPixbuf *pixbuf; /* full-size image, only complete images, NULL during loading
588 all FileData with non-NULL pixbuf are referenced by image_cache */
594 gint version; /* increased when any field in this structure is changed */
595 gboolean disable_grouping;
597 gint user_orientation;
598 gint exif_orientation;
602 time_t exifdate_digitized;
603 GHashTable *modified_xmp; // hash table which contains unwritten xmp metadata in format: key->list of string values
604 GList *cached_metadata;
606 gboolean metadata_in_idle_loaded;
612 SelectionType selected; // Used by view_file_icon.
618 struct _LayoutOptions
625 DirViewType dir_view_type;
626 FileViewType file_view_type;
628 gboolean show_thumbnails;
630 gboolean show_file_filter;
631 gboolean show_directory_date;
632 gboolean show_info_pixel;
663 gint histogram_channel;
674 gboolean tools_float;
675 gboolean tools_hidden;
676 gboolean toolbar_hidden;
681 gboolean tools_float;
682 gboolean tools_hidden;
689 StartUpPath startup_path;
691 gboolean exit_on_close;
698 LayoutOptions options;
708 GtkWidget *group_box;
712 /* menus, path selector */
714 GtkActionGroup *action_group;
715 GtkActionGroup *action_group_editors;
717 GtkUIManager *ui_manager;
718 guint toolbar_merge_id[TOOLBAR_COUNT];
719 GList *toolbar_actions[TOOLBAR_COUNT];
721 GtkWidget *path_entry;
725 LayoutLocation image_location;
729 ImageWindow *split_images[MAX_SPLIT_IMAGES];
730 ImageSplitMode split_mode;
731 gint active_split_image;
733 GtkWidget *split_image_widget;
734 GtkSizeGroup *split_image_sizegroup;
736 /* tools window (float) */
739 GtkWidget *tools_pane;
742 // gint tools_hidden;
743 GtkWidget *menu_tool_bar; /*Combined menu and toolbar box */
744 GtkWidget *menu_bar; /* referenced by lw, exist during whole lw lifetime */
747 GtkWidget *toolbar[TOOLBAR_COUNT]; /* referenced by lw, exist during whole lw lifetime */
748 // gint toolbar_hidden;
750 // GtkWidget *thumb_button;
751 // gint thumbs_enabled;
752 // gint marks_enabled;
754 GtkWidget *back_button;
758 LayoutLocation dir_location;
763 // DirViewType dir_view_type;
767 LayoutLocation file_location;
770 // FileViewType file_view_type;
772 GtkWidget *file_view;
774 SortType sort_method;
775 gboolean sort_ascend;
780 GtkWidget *info_progress_bar;
781 GtkWidget *info_sort;
782 GtkWidget *info_status;
783 GtkWidget *info_details;
784 GtkWidget *info_zoom;
785 GtkWidget *info_pixel;
789 SlideShowData *slideshow;
793 FullScreenData *full_screen;
803 GtkWidget *utility_box; /* referenced by lw, exist during whole lw lifetime */
804 GtkWidget *utility_paned; /* between image and bar */
808 gboolean bar_sort_enabled; /* Set during start-up, and checked when the editors have loaded */
813 GtkWidget *exif_window;
815 AnimationData *animation;
817 GtkWidget *log_window;
834 guint drop_scroll_id; /* event source id */
837 void (*select_func)(ViewDir *vd, FileData *fd, gpointer data);
838 gpointer select_data;
840 void (*dnd_drop_update_func)(ViewDir *vd);
841 void (*dnd_drop_leave_func)(ViewDir *vd);
843 LayoutWindow *layout;
850 struct _ViewDirInfoList
855 struct _ViewDirInfoTree
857 guint drop_expand_id; /* event source id */
865 // TODO(xsdg): Turn this into a union (see VFLIST and VFICON from view_file.h).
872 GtkWidget *filter_check[FILEDATA_MARKS_SIZE];
884 SortType sort_method;
885 gboolean sort_ascend;
888 void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
889 gpointer data_thumb_status;
891 void (*func_status)(ViewFile *vf, gpointer data);
892 gpointer data_status;
894 LayoutWindow *layout;
899 gboolean thumbs_running;
900 ThumbLoader *thumbs_loader;
901 FileData *thumbs_filedata;
904 gboolean marks_enabled;
909 guint refresh_idle_id; /* event source id */
910 time_t time_refresh_set; /* time when refresh_idle_id was set */
912 /* file list for edit menu */
913 GList *editmenu_fd_list;
915 guint read_metadata_in_idle_id;
918 struct _ViewFileInfoList
923 gboolean thumbs_enabled;
925 guint select_idle_id; /* event source id */
928 struct _ViewFileInfoIcon
935 FileData *prev_selection;
937 GtkWidget *tip_window;
938 guint tip_delay_id; /* event source id */
950 struct _SlideShowData
952 LayoutWindow *lw; /* use this window to display the slideshow */
953 ImageWindow *imd; /* use this window only if lw is not available,
954 FIXME: it is probably required only by img-view.c and should be dropped with it */
966 guint timeout_id; /* event source id */
968 gboolean from_selection;
970 void (*stop_func)(SlideShowData *, gpointer);
976 struct _FullScreenData
981 GtkWidget *normal_window;
982 ImageWindow *normal_imd;
984 guint hide_mouse_id; /* event source id */
985 guint busy_mouse_id; /* event source id */
989 guint saver_block_id; /* event source id */
991 void (*stop_func)(FullScreenData *, gpointer);
994 gboolean same_region; /* the returned region will overlap the current location of widget. */
997 struct _PixmapFolders
1006 struct _SecureSaveInfo {
1007 FILE *fp; /**< file stream pointer */
1008 gchar *file_name; /**< final file name */
1009 gchar *tmp_file_name; /**< temporary file name */
1010 gint err; /**< set to non-zero value in case of error */
1011 gboolean secure_save; /**< use secure save for this file, internal use only */
1012 gboolean preserve_perms; /**< whether to preserve perms, TRUE by default */
1013 gboolean preserve_mtime; /**< whether to preserve mtime, FALSE by default */
1014 gboolean unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
1021 gboolean startup_blank;
1022 gboolean startup_full_screen;
1023 gboolean startup_in_slideshow;
1024 gboolean startup_command_line_collection;
1025 gboolean tools_hide;
1026 gboolean tools_show;
1027 gboolean log_window_show;
1031 GList *collection_list;
1035 SecureSaveInfo *ssi;
1039 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */