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,
32 MOUSE_BUTTON_LEFT = 1,
33 MOUSE_BUTTON_MIDDLE = 2,
34 MOUSE_BUTTON_RIGHT = 3,
35 MOUSE_BUTTON_WHEEL_UP = 4,
36 MOUSE_BUTTON_WHEEL_DOWN = 5,
37 MOUSE_BUTTON_BACK = 8,
38 MOUSE_BUTTON_FORWARD = 9
45 // Keep this up to date!
46 DIRVIEW_LAST = DIRVIEW_TREE
53 // Keep this up to date!
54 FILEVIEW_LAST = FILEVIEW_ICON
57 #define CMD_COPY "geeqie-copy-command.desktop"
58 #define CMD_MOVE "geeqie-move-command.desktop"
59 #define CMD_RENAME "geeqie-rename-command.desktop"
60 #define CMD_DELETE "geeqie-delete-command.desktop"
61 #define CMD_FOLDER "geeqie-folder-command.desktop"
76 ALTER_NONE, /* do nothing */
78 ALTER_ROTATE_90_CC, /* counterclockwise */
87 LAYOUT_RIGHT = 1 << 1,
89 LAYOUT_BOTTOM = 1 << 3
95 IMAGE_STATE_IMAGE = 1 << 0,
96 IMAGE_STATE_LOADING = 1 << 1,
97 IMAGE_STATE_ERROR = 1 << 2,
98 IMAGE_STATE_COLOR_ADJ = 1 << 3,
99 IMAGE_STATE_ROTATE_AUTO = 1 << 4,
100 IMAGE_STATE_ROTATE_USER = 1 << 5,
101 IMAGE_STATE_DELAY_FLIP = 1 << 6
112 FILEDATA_CHANGE_DELETE,
113 FILEDATA_CHANGE_MOVE,
114 FILEDATA_CHANGE_RENAME,
115 FILEDATA_CHANGE_COPY,
116 FILEDATA_CHANGE_UNSPECIFIED,
117 FILEDATA_CHANGE_WRITE_METADATA
118 } FileDataChangeType;
125 } MarkToSelectionMode;
131 } SelectionToMarkMode;
134 FORMAT_CLASS_UNKNOWN,
136 FORMAT_CLASS_RAWIMAGE,
144 SS_ERR_DISABLED, /**< secsave is disabled. */
145 SS_ERR_OUT_OF_MEM, /**< memory allocation failure */
147 /* see err field in SecureSaveInfo */
158 NOTIFY_PRIORITY_HIGH = 0,
159 NOTIFY_PRIORITY_MEDIUM,
164 NOTIFY_MARKS = 1 << 1, /* changed marks */
165 NOTIFY_PIXBUF = 1 << 2, /* image was read into fd->pixbuf */
166 NOTIFY_HISTMAP = 1 << 3, /* histmap was read into fd->histmap */
167 NOTIFY_ORIENTATION = 1 << 4, /* image was rotated */
168 NOTIFY_METADATA = 1 << 5, /* changed image metadata, not yet written */
169 NOTIFY_GROUPING = 1 << 6, /* change in fd->sidecar_files or fd->parent */
170 NOTIFY_REREAD = 1 << 7, /* changed file size, date, etc., file name remains unchanged */
171 NOTIFY_CHANGE = 1 << 8 /* generic change described by fd->change */
176 CHANGE_WARN_DEST_EXISTS = 1 << 0,
177 CHANGE_WARN_NO_WRITE_PERM = 1 << 1,
178 CHANGE_WARN_SAME = 1 << 2,
179 CHANGE_WARN_CHANGED_EXT = 1 << 3,
180 CHANGE_WARN_UNSAVED_META = 1 << 4,
181 CHANGE_WARN_NO_WRITE_PERM_DEST_DIR = 1 << 5,
182 CHANGE_ERROR_MASK = (~0U) << 8, /* the values below are fatal errors */
183 CHANGE_NO_READ_PERM = 1 << 8,
184 CHANGE_NO_WRITE_PERM_DIR = 1 << 9,
185 CHANGE_NO_DEST_DIR = 1 << 10,
186 CHANGE_DUPLICATE_DEST = 1 << 11,
187 CHANGE_NO_WRITE_PERM_DEST = 1 << 12,
188 CHANGE_DEST_EXISTS = 1 << 13,
189 CHANGE_NO_SRC = 1 << 14,
190 CHANGE_GENERIC_ERROR = 1 << 16
194 METADATA_PLAIN = 0, /* format that can be edited and written back */
195 METADATA_FORMATTED = 1 /* for display only */
199 STARTUP_PATH_CURRENT = 0,
211 PR_STEREO_NONE = 0, /* do nothing */
212 PR_STEREO_DUAL = 1 << 0, /* independent stereo buffers, for example nvidia opengl */
213 PR_STEREO_FIXED = 1 << 1, /* custom position */
214 PR_STEREO_HORIZ = 1 << 2, /* side by side */
215 PR_STEREO_VERT = 1 << 3, /* above below */
216 PR_STEREO_RIGHT = 1 << 4, /* render right buffer */
217 PR_STEREO_ANAGLYPH_RC = 1 << 5, /* anaglyph red-cyan */
218 PR_STEREO_ANAGLYPH_GM = 1 << 6, /* anaglyph green-magenta */
219 PR_STEREO_ANAGLYPH_YB = 1 << 7, /* anaglyph yellow-blue */
220 PR_STEREO_ANAGLYPH_GRAY_RC = 1 << 8, /* anaglyph gray red-cyan*/
221 PR_STEREO_ANAGLYPH_GRAY_GM = 1 << 9, /* anaglyph gray green-magenta */
222 PR_STEREO_ANAGLYPH_GRAY_YB = 1 << 10, /* anaglyph gray yellow-blue */
223 PR_STEREO_ANAGLYPH_DB_RC = 1 << 11, /* anaglyph dubois red-cyan */
224 PR_STEREO_ANAGLYPH_DB_GM = 1 << 12, /* anaglyph dubois green-magenta */
225 PR_STEREO_ANAGLYPH_DB_YB = 1 << 13, /* anaglyph dubois yellow-blue */
226 PR_STEREO_ANAGLYPH = PR_STEREO_ANAGLYPH_RC |
227 PR_STEREO_ANAGLYPH_GM |
228 PR_STEREO_ANAGLYPH_YB |
229 PR_STEREO_ANAGLYPH_GRAY_RC |
230 PR_STEREO_ANAGLYPH_GRAY_GM |
231 PR_STEREO_ANAGLYPH_GRAY_YB |
232 PR_STEREO_ANAGLYPH_DB_RC |
233 PR_STEREO_ANAGLYPH_DB_GM |
234 PR_STEREO_ANAGLYPH_DB_YB, /* anaglyph mask */
236 PR_STEREO_MIRROR_LEFT = 1 << 14, /* mirror */
237 PR_STEREO_FLIP_LEFT = 1 << 15, /* flip */
239 PR_STEREO_MIRROR_RIGHT = 1 << 16, /* mirror */
240 PR_STEREO_FLIP_RIGHT = 1 << 17, /* flip */
242 PR_STEREO_MIRROR = PR_STEREO_MIRROR_LEFT | PR_STEREO_MIRROR_RIGHT, /* mirror mask*/
243 PR_STEREO_FLIP = PR_STEREO_FLIP_LEFT | PR_STEREO_FLIP_RIGHT, /* flip mask*/
244 PR_STEREO_SWAP = 1 << 18, /* swap left and right buffers */
245 PR_STEREO_TEMP_DISABLE = 1 << 19, /* temporarily disable stereo mode if source image is not stereo */
246 PR_STEREO_HALF = 1 << 20
247 } PixbufRendererStereoMode;
250 STEREO_PIXBUF_DEFAULT = 0,
251 STEREO_PIXBUF_SBS = 1,
252 STEREO_PIXBUF_CROSS = 2,
253 STEREO_PIXBUF_NONE = 3
256 #define MAX_SPLIT_IMAGES 4
260 SELECTION_SELECTED = 1 << 0,
261 SELECTION_PRELIGHT = 1 << 1,
262 SELECTION_FOCUS = 1 << 2
265 typedef struct _ImageLoader ImageLoader;
266 typedef struct _ThumbLoader ThumbLoader;
268 typedef struct _AnimationData AnimationData;
270 typedef struct _CollectInfo CollectInfo;
271 typedef struct _CollectionData CollectionData;
272 typedef struct _CollectTable CollectTable;
273 typedef struct _CollectWindow CollectWindow;
275 typedef struct _ImageWindow ImageWindow;
277 typedef struct _FileData FileData;
278 typedef struct _FileDataChangeInfo FileDataChangeInfo;
280 typedef struct _LayoutWindow LayoutWindow;
281 typedef struct _LayoutOptions LayoutOptions;
283 typedef struct _ViewDir ViewDir;
284 typedef struct _ViewDirInfoList ViewDirInfoList;
285 typedef struct _ViewDirInfoTree ViewDirInfoTree;
287 typedef struct _ViewFile ViewFile;
288 typedef struct _ViewFileInfoList ViewFileInfoList;
289 typedef struct _ViewFileInfoIcon ViewFileInfoIcon;
291 typedef struct _SlideShowData SlideShowData;
292 typedef struct _FullScreenData FullScreenData;
294 typedef struct _PixmapFolders PixmapFolders;
295 typedef struct _Histogram Histogram;
296 typedef struct _HistMap HistMap;
298 typedef struct _SecureSaveInfo SecureSaveInfo;
300 typedef struct _ExifData ExifData;
302 typedef struct _EditorDescription EditorDescription;
304 typedef struct _CommandLine CommandLine;
307 gint histogram_channel; /* drawing mode for histogram */
308 gint histogram_mode; /* logarithmical or not */
309 guint vgrid; /* number of vertical divisions, 0 for none */
310 guint hgrid; /* number of horizontal divisions, 0 for none */
316 } grid_color; /* grid color */
324 typedef void (* ThumbLoaderFunc)(ThumbLoader *tl, gpointer data);
326 typedef void (* FileUtilDoneFunc)(gboolean success, const gchar *done_path, gpointer data);
330 gboolean standard_loader;
333 FileData *fd; /* fd->pixbuf contains final (scaled) image when done */
335 gboolean cache_enable;
337 gdouble percent_done;
342 ThumbLoaderFunc func_done;
343 ThumbLoaderFunc func_error;
344 ThumbLoaderFunc func_progress;
348 guint idle_done_id; /* event source id */
351 struct _AnimationData
354 GdkPixbufAnimation *gpa;
355 GdkPixbufAnimationIter *iter;
369 struct _CollectionData
374 SortType sort_method;
376 ThumbLoader *thumb_loader;
377 CollectInfo *thumb_info;
379 void (*info_updated_func)(CollectionData *, CollectInfo *, gpointer);
380 gpointer info_updated_data;
391 /* contents changed since save flag */
394 GHashTable *existence;
407 CollectInfo *prev_selection;
409 CollectInfo *click_info;
411 GtkWidget *tip_window;
412 guint tip_delay_id; /* event source id */
413 CollectInfo *tip_info;
415 GdkWindow *marker_window;
416 CollectInfo *marker_info;
418 GtkWidget *status_label;
419 GtkWidget *extra_label;
423 CollectInfo *focus_info;
426 CollectInfo *drop_info;
429 guint sync_idle_id; /* event source id */
430 guint drop_idle_id; /* event source id */
434 /* file list for edit menu */
435 GList *editmenu_fd_list;
438 struct _CollectWindow
442 GtkWidget *status_box;
444 GtkWidget *close_dialog;
449 typedef gint (* ImageTileRequestFunc)(ImageWindow *imd, gint x, gint y,
450 gint width, gint height, GdkPixbuf *pixbuf, gpointer);
451 typedef void (* ImageTileDisposeFunc)(ImageWindow *imd, gint x, gint y,
452 gint width, gint height, GdkPixbuf *pixbuf, gpointer);
456 GtkWidget *widget; /* use this to add it and show it */
462 gboolean unknown; /* failed to load image */
464 ImageLoader *il; /* FIXME - image loader should probably go to FileData, but it must first support
465 sending callbacks to multiple ImageWindows in parallel */
467 gint has_frame; /* not boolean, see image_new() */
469 /* top level (not necessarily parent) window */
470 gboolean top_window_sync; /* resize top_window when image dimensions change */
471 GtkWidget *top_window; /* window that gets title, and window to resize when 'fitting' */
472 gchar *title; /* window title to display left of file name */
473 gchar *title_right; /* window title to display right of file name */
474 gboolean title_show_zoom; /* option to include zoom in window title */
477 ImageState state; /* mask of IMAGE_STATE_* flags about current image */
479 void (*func_update)(ImageWindow *imd, gpointer data);
480 void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
481 void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
482 ImageTileRequestFunc func_tile_request;
483 ImageTileDisposeFunc func_tile_dispose;
485 gpointer data_update;
486 gpointer data_complete;
490 /* button, scroll functions */
491 void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer);
492 void (*func_drag)(ImageWindow *, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer);
493 void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer);
494 void (*func_focus_in)(ImageWindow *, gpointer);
496 gpointer data_button;
498 gpointer data_scroll;
499 gpointer data_focus_in;
501 /* scroll notification (for scroll bar implementation) */
502 void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
504 gpointer data_scroll_notify;
506 /* collection info */
507 CollectionData *collection;
508 CollectInfo *collection_info;
511 gboolean color_profile_enable;
512 gint color_profile_input;
513 gboolean color_profile_use_image;
514 gint color_profile_from_image;
517 AlterType delay_alter_type;
519 FileData *read_ahead_fd;
520 ImageLoader *read_ahead_il;
524 gboolean auto_refresh;
531 gboolean mouse_wheel_mode;
534 #define FILEDATA_MARKS_SIZE 10
536 struct _FileDataChangeInfo {
537 FileDataChangeType type;
541 gboolean regroup_when_finished;
547 gchar *original_path; /* key to file_data_pool hash table */
550 const gchar *extension;
551 gchar *extended_extension;
552 FileFormatClass format_class;
553 gchar *collate_key_name;
554 gchar *collate_key_name_nocase;
558 mode_t mode; /* this is needed at least for notification in view_dir because it is preserved after the file/directory is deleted */
559 gint sidecar_priority;
561 guint marks; /* each bit represents one mark */
562 guint valid_marks; /* zero bit means that the corresponding mark needs to be reread */
565 GList *sidecar_files;
566 FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */
567 FileDataChangeInfo *change; /* for rename, move ... */
568 GdkPixbuf *thumb_pixbuf;
570 GdkPixbuf *pixbuf; /* full-size image, only complete images, NULL during loading
571 all FileData with non-NULL pixbuf are referenced by image_cache */
577 gint version; /* increased when any field in this structure is changed */
578 gboolean disable_grouping;
580 gint user_orientation;
581 gint exif_orientation;
585 GHashTable *modified_xmp; // hash table which contains unwritten xmp metadata in format: key->list of string values
586 GList *cached_metadata;
589 SelectionType selected; // Used by view_file_icon.
592 struct _LayoutOptions
599 DirViewType dir_view_type;
600 FileViewType file_view_type;
602 gboolean show_thumbnails;
604 gboolean show_directory_date;
605 gboolean show_info_pixel;
636 gint histogram_channel;
647 gboolean tools_float;
648 gboolean tools_hidden;
649 gboolean toolbar_hidden;
654 gboolean tools_float;
655 gboolean tools_hidden;
662 StartUpPath startup_path;
664 gboolean exit_on_close;
671 LayoutOptions options;
681 GtkWidget *group_box;
685 /* menus, path selector */
687 GtkActionGroup *action_group;
688 GtkActionGroup *action_group_editors;
690 GtkUIManager *ui_manager;
691 guint toolbar_merge_id[TOOLBAR_COUNT];
692 GList *toolbar_actions[TOOLBAR_COUNT];
694 GtkWidget *path_entry;
698 LayoutLocation image_location;
702 ImageWindow *split_images[MAX_SPLIT_IMAGES];
703 ImageSplitMode split_mode;
704 gint active_split_image;
706 GtkWidget *split_image_widget;
707 GtkSizeGroup *split_image_sizegroup;
709 /* tools window (float) */
712 GtkWidget *tools_pane;
715 // gint tools_hidden;
717 GtkWidget *menu_bar; /* referenced by lw, exist during whole lw lifetime */
720 GtkWidget *toolbar[TOOLBAR_COUNT]; /* referenced by lw, exist during whole lw lifetime */
721 // gint toolbar_hidden;
723 // GtkWidget *thumb_button;
724 // gint thumbs_enabled;
725 // gint marks_enabled;
727 GtkWidget *back_button;
731 LayoutLocation dir_location;
736 // DirViewType dir_view_type;
740 LayoutLocation file_location;
743 // FileViewType file_view_type;
745 GtkWidget *file_view;
747 SortType sort_method;
748 gboolean sort_ascend;
753 GtkWidget *info_progress_bar;
754 GtkWidget *info_sort;
755 GtkWidget *info_status;
756 GtkWidget *info_details;
757 GtkWidget *info_zoom;
758 GtkWidget *info_pixel;
762 SlideShowData *slideshow;
766 FullScreenData *full_screen;
776 GtkWidget *utility_box; /* referenced by lw, exist during whole lw lifetime */
777 GtkWidget *utility_paned; /* between image and bar */
781 gboolean bar_sort_enabled; /* Set during start-up, and checked when the editors have loaded */
786 GtkWidget *exif_window;
788 AnimationData *animation;
790 GtkWidget *log_window;
807 guint drop_scroll_id; /* event source id */
810 void (*select_func)(ViewDir *vd, FileData *fd, gpointer data);
811 gpointer select_data;
813 void (*dnd_drop_update_func)(ViewDir *vd);
814 void (*dnd_drop_leave_func)(ViewDir *vd);
816 LayoutWindow *layout;
823 struct _ViewDirInfoList
828 struct _ViewDirInfoTree
830 guint drop_expand_id; /* event source id */
838 // TODO(xsdg): Turn this into a union (see VFLIST and VFICON from view_file.h).
845 GtkWidget *filter_check[FILEDATA_MARKS_SIZE];
850 SortType sort_method;
851 gboolean sort_ascend;
854 void (*func_thumb_status)(ViewFile *vf, gdouble val, const gchar *text, gpointer data);
855 gpointer data_thumb_status;
857 void (*func_status)(ViewFile *vf, gpointer data);
858 gpointer data_status;
860 LayoutWindow *layout;
865 gboolean thumbs_running;
866 ThumbLoader *thumbs_loader;
867 FileData *thumbs_filedata;
870 gboolean marks_enabled;
875 guint refresh_idle_id; /* event source id */
876 time_t time_refresh_set; /* time when refresh_idle_id was set */
878 /* file list for edit menu */
879 GList *editmenu_fd_list;
882 struct _ViewFileInfoList
887 gboolean thumbs_enabled;
889 guint select_idle_id; /* event source id */
892 struct _ViewFileInfoIcon
899 FileData *prev_selection;
901 GtkWidget *tip_window;
902 guint tip_delay_id; /* event source id */
914 struct _SlideShowData
916 LayoutWindow *lw; /* use this window to display the slideshow */
917 ImageWindow *imd; /* use this window only if lw is not available,
918 FIXME: it is probably required only by img-view.c and should be dropped with it */
930 guint timeout_id; /* event source id */
932 gboolean from_selection;
934 void (*stop_func)(SlideShowData *, gpointer);
940 struct _FullScreenData
945 GtkWidget *normal_window;
946 ImageWindow *normal_imd;
948 guint hide_mouse_id; /* event source id */
949 guint busy_mouse_id; /* event source id */
953 guint saver_block_id; /* event source id */
955 void (*stop_func)(FullScreenData *, gpointer);
958 gboolean same_region; /* the returned region will overlap the current location of widget. */
961 struct _PixmapFolders
969 struct _SecureSaveInfo {
970 FILE *fp; /**< file stream pointer */
971 gchar *file_name; /**< final file name */
972 gchar *tmp_file_name; /**< temporary file name */
973 gint err; /**< set to non-zero value in case of error */
974 gboolean secure_save; /**< use secure save for this file, internal use only */
975 gboolean preserve_perms; /**< whether to preserve perms, TRUE by default */
976 gboolean preserve_mtime; /**< whether to preserve mtime, FALSE by default */
977 gboolean unlink_on_error; /**< whether to remove temporary file on save failure, TRUE by default */
984 gboolean startup_blank;
985 gboolean startup_full_screen;
986 gboolean startup_in_slideshow;
987 gboolean startup_command_line_collection;
990 gboolean log_window_show;
994 GList *collection_list;
1002 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */