Silence GTK deprecation warning in unused function
[geeqie.git] / src / image.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
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.
11  *
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.
16  *
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.
20  */
21
22 #ifndef IMAGE_H
23 #define IMAGE_H
24
25 #include <gdk-pixbuf/gdk-pixbuf.h>
26 #include <gdk/gdk.h>
27 #include <glib.h>
28 #include <gtk/gtk.h>
29
30 #include "typedefs.h"
31
32 struct CollectInfo;
33 struct CollectionData;
34 struct FileData;
35 struct ImageLoader;
36
37 enum ImageState {
38         IMAGE_STATE_NONE        = 0,
39         IMAGE_STATE_IMAGE       = 1 << 0,
40         IMAGE_STATE_LOADING     = 1 << 1,
41         IMAGE_STATE_ERROR       = 1 << 2,
42         IMAGE_STATE_COLOR_ADJ   = 1 << 3,
43         IMAGE_STATE_ROTATE_AUTO = 1 << 4,
44         IMAGE_STATE_ROTATE_USER = 1 << 5,
45         IMAGE_STATE_DELAY_FLIP  = 1 << 6
46 };
47
48 struct ImageWindow
49 {
50         GtkWidget *widget;      /**< use this to add it and show it */
51         GtkWidget *pr;
52         GtkWidget *frame;
53
54         FileData *image_fd;
55
56         gboolean unknown;               /**< failed to load image */
57
58         ImageLoader *il;        /**< @FIXME image loader should probably go to FileData, but it must first support
59                                    sending callbacks to multiple ImageWindows in parallel */
60
61         gint has_frame;  /**< not boolean, see image_new() */
62
63         /* top level (not necessarily parent) window */
64         gboolean top_window_sync;       /**< resize top_window when image dimensions change */
65         GtkWidget *top_window;  /**< window that gets title, and window to resize when 'fitting' */
66         gchar *title;           /**< window title to display left of file name */
67         gchar *title_right;     /**< window title to display right of file name */
68         gboolean title_show_zoom;       /**< option to include zoom in window title */
69
70         gboolean completed;
71         ImageState state;       /**< mask of IMAGE_STATE_* flags about current image */
72
73         void (*func_update)(ImageWindow *imd, gpointer data);
74         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
75         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
76
77         using TileRequestFunc = gint (*)(ImageWindow *, gint, gint, gint, gint, GdkPixbuf *, gpointer);
78         TileRequestFunc func_tile_request;
79
80         using TileDisposeFunc = void (*)(ImageWindow *, gint, gint, gint, gint, GdkPixbuf *, gpointer);
81         TileDisposeFunc func_tile_dispose;
82
83         gpointer data_update;
84         gpointer data_complete;
85         gpointer data_state;
86         gpointer data_tile;
87
88         /* button, scroll functions */
89         void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer);
90         void (*func_drag)(ImageWindow *, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer);
91         void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer);
92         void (*func_focus_in)(ImageWindow *, gpointer);
93
94         gpointer data_button;
95         gpointer data_drag;
96         gpointer data_scroll;
97         gpointer data_focus_in;
98
99         /**
100          * @headerfile func_scroll_notify
101          * scroll notification (for scroll bar implementation)
102          */
103         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
104
105         gpointer data_scroll_notify;
106
107         /* collection info */
108         CollectionData *collection;
109         CollectInfo *collection_info;
110
111         /* color profiles */
112         gboolean color_profile_enable;
113         gint color_profile_input;
114         gboolean color_profile_use_image;
115         gint color_profile_from_image;
116         gpointer cm;
117
118         AlterType delay_alter_type;
119
120         FileData *read_ahead_fd;
121         ImageLoader *read_ahead_il;
122
123         gint prev_color_row;
124
125         gboolean auto_refresh;
126
127         gboolean delay_flip;
128         gint orientation;
129         gboolean desaturate;
130         gboolean overunderexposed;
131         gint user_stereo;
132
133         gboolean mouse_wheel_mode;
134 };
135
136 void image_set_frame(ImageWindow *imd, gboolean frame);
137 ImageWindow *image_new(gboolean frame);
138
139 /* additional setup */
140 void image_attach_window(ImageWindow *imd, GtkWidget *window,
141                          const gchar *title, const gchar *title_right, gboolean show_zoom);
142 void image_set_update_func(ImageWindow *imd,
143                            void (*func)(ImageWindow *imd, gpointer data),
144                            gpointer data);
145 void image_set_button_func(ImageWindow *imd,
146         void (*func)(ImageWindow *, GdkEventButton *event, gpointer),
147         gpointer data);
148 void image_set_drag_func(ImageWindow *imd,
149         void (*func)(ImageWindow *, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer),
150         gpointer data);
151 void image_set_scroll_func(ImageWindow *imd,
152         void (*func)(ImageWindow *, GdkEventScroll *event, gpointer),
153         gpointer data);
154 void image_set_focus_in_func(ImageWindow *imd,
155         void (*func)(ImageWindow *, gpointer),
156         gpointer data);
157 void image_set_complete_func(ImageWindow *imd,
158                              void (*func)(ImageWindow *imd, gint preload, gpointer data),
159                              gpointer data);
160 void image_set_state_func(ImageWindow *imd,
161                           void (*func)(ImageWindow *imd, ImageState state, gpointer data),
162                           gpointer data);
163
164 void image_select(ImageWindow *imd, gboolean select);
165 void image_set_selectable(ImageWindow *imd, gboolean selectable);
166
167 void image_grab_focus(ImageWindow *imd);
168 /* path, name */
169 const gchar *image_get_path(ImageWindow *imd);
170 const gchar *image_get_name(ImageWindow *imd);
171 FileData *image_get_fd(ImageWindow *imd);
172
173 /**
174  * @headerfile image_set_fd
175  * merely changes path string, does not change the image!
176  */
177 void image_set_fd(ImageWindow *imd, FileData *fd);
178
179 /* load a new image */
180 void image_change_fd(ImageWindow *imd, FileData *fd, gdouble zoom);
181 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboolean lazy);
182 void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectInfo *info, gdouble zoom);
183 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info);
184 void image_copy_from_image(ImageWindow *imd, ImageWindow *source);
185 void image_move_from_image(ImageWindow *imd, ImageWindow *source);
186
187 gboolean image_get_image_size(ImageWindow *imd, gint *width, gint *height);
188 GdkPixbuf *image_get_pixbuf(ImageWindow *imd);
189
190 /* manipulation */
191 void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height);
192 void image_reload(ImageWindow *imd);
193 void image_scroll(ImageWindow *imd, gint x, gint y);
194 void image_scroll_to_point(ImageWindow *imd, gint x, gint y,
195                            gdouble x_align, gdouble y_align);
196 void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y);
197 void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y);
198 void image_alter_orientation(ImageWindow *imd, FileData *fd, AlterType type);
199 void image_set_desaturate(ImageWindow *imd, gboolean desaturate);
200 gboolean image_get_desaturate(ImageWindow *imd);
201 void image_set_overunderexposed(ImageWindow *imd, gboolean overunderexposed);
202 void image_set_ignore_alpha(ImageWindow *imd, gboolean ignore_alpha);
203
204 /* zoom */
205 void image_zoom_adjust(ImageWindow *imd, gdouble increment);
206 void image_zoom_adjust_at_point(ImageWindow *imd, gdouble increment, gint x, gint y);
207 void image_zoom_set_limits(ImageWindow *imd, gdouble min, gdouble max);
208 void image_zoom_set(ImageWindow *imd, gdouble zoom);
209 void image_zoom_set_fill_geometry(ImageWindow *imd, gboolean vertical);
210 gdouble image_zoom_get(ImageWindow *imd);
211 gdouble image_zoom_get_real(ImageWindow *imd);
212 gchar *image_zoom_get_as_text(ImageWindow *imd);
213 gdouble image_zoom_get_default(ImageWindow *imd);
214
215 /* stereo */
216 void image_stereo_set(ImageWindow *imd, gint stereo_mode);
217
218 StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd);
219 void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode);
220
221 /**
222  * @headerfile image_prebuffer_set
223  * read ahead, pass NULL to cancel
224  */
225 void image_prebuffer_set(ImageWindow *imd, FileData *fd);
226
227 /**
228  * @headerfile image_auto_refresh_enable
229  * auto refresh
230  */
231 void image_auto_refresh_enable(ImageWindow *imd, gboolean enable);
232
233 /**
234  * @headerfile image_top_window_set_sync
235  * allow top window to be resized ?
236  */
237 void image_top_window_set_sync(ImageWindow *imd, gboolean allow_sync);
238
239 /* background of image */
240 void image_background_set_color(ImageWindow *imd, GdkRGBA *color);
241 void image_background_set_color_from_options(ImageWindow *imd, gboolean fullscreen);
242
243 /* color profiles */
244 void image_color_profile_set(ImageWindow *imd,
245                              gint input_type,
246                              gboolean use_image);
247 gboolean image_color_profile_get(ImageWindow *imd,
248                              gint *input_type,
249                              gboolean *use_image);
250 void image_color_profile_set_use(ImageWindow *imd, gboolean enable);
251 gboolean image_color_profile_get_use(ImageWindow *imd);
252 gboolean image_color_profile_get_status(ImageWindow *imd, gchar **image_profile, gchar **screen_profile);
253
254 /**
255  * @headerfile image_set_delay_flip
256  * set delayed page flipping
257  */
258 void image_set_delay_flip(ImageWindow *imd, gint delay);
259
260 /**
261  * @headerfile image_to_root_window
262  * wallpaper util
263  */
264 void image_to_root_window(ImageWindow *imd, gboolean scaled);
265
266
267
268 void image_set_image_as_tiles(ImageWindow *imd, gint width, gint height,
269                               gint tile_width, gint tile_height, gint cache_size,
270                               ImageWindow::TileRequestFunc func_tile_request,
271                               ImageWindow::TileDisposeFunc func_tile_dispose,
272                               gpointer data,
273                               gdouble zoom);
274
275 /**
276  * @headerfile image_options_sync
277  * reset default options
278  */
279 void image_options_sync();
280
281 void image_get_rectangle(gint *x1, gint *y1, gint *x2, gint *y2);
282 void image_update_title(ImageWindow *imd);
283 #endif
284 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */