File: | src/eoc-scroll-view.c |
Warning: | line 1815, column 2 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | #ifdef HAVE_CONFIG_H1 |
2 | #include <config.h> |
3 | #endif |
4 | |
5 | #include <stdlib.h> |
6 | #include <math.h> |
7 | #include <gdk-pixbuf/gdk-pixbuf.h> |
8 | #include <cdk/cdkkeysyms.h> |
9 | #ifdef HAVE_RSVG1 |
10 | #include <librsvg/rsvg.h> |
11 | #endif |
12 | |
13 | #include "eoc-config-keys.h" |
14 | #include "eoc-enum-types.h" |
15 | #include "eoc-marshal.h" |
16 | #include "eoc-scroll-view.h" |
17 | #include "eoc-debug.h" |
18 | #include "zoom.h" |
19 | |
20 | #include <cdk/cdk.h> |
21 | |
22 | /* Maximum size of delayed repaint rectangles */ |
23 | #define PAINT_RECT_WIDTH128 128 |
24 | #define PAINT_RECT_HEIGHT128 128 |
25 | |
26 | /* Scroll step increment */ |
27 | #define SCROLL_STEP_SIZE32 32 |
28 | |
29 | /* Maximum zoom factor */ |
30 | #define MAX_ZOOM_FACTOR20 20 |
31 | #define MIN_ZOOM_FACTOR0.02 0.02 |
32 | |
33 | #define CHECK_MEDIUM8 8 |
34 | #define CHECK_BLACK"#000000" "#000000" |
35 | #define CHECK_DARK"#555555" "#555555" |
36 | #define CHECK_GRAY"#808080" "#808080" |
37 | #define CHECK_LIGHT"#cccccc" "#cccccc" |
38 | #define CHECK_WHITE"#ffffff" "#ffffff" |
39 | |
40 | /* Default increment for zooming. The current zoom factor is multiplied or |
41 | * divided by this amount on every zooming step. For consistency, you should |
42 | * use the same value elsewhere in the program. |
43 | */ |
44 | #define IMAGE_VIEW_ZOOM_MULTIPLIER1.05 1.05 |
45 | |
46 | /* States for automatically adjusting the zoom factor */ |
47 | typedef enum { |
48 | ZOOM_MODE_FIT, /* Image is fitted to scroll view even if the latter changes size */ |
49 | ZOOM_MODE_FREE /* The image remains at its current zoom factor even if the scrollview changes size */ |
50 | } ZoomMode; |
51 | |
52 | /* Signal IDs */ |
53 | enum { |
54 | SIGNAL_ZOOM_CHANGED, |
55 | SIGNAL_LAST |
56 | }; |
57 | |
58 | static guint view_signals [SIGNAL_LAST] = { 0 }; |
59 | |
60 | typedef enum { |
61 | EOC_SCROLL_VIEW_CURSOR_NORMAL, |
62 | EOC_SCROLL_VIEW_CURSOR_HIDDEN, |
63 | EOC_SCROLL_VIEW_CURSOR_DRAG |
64 | } EocScrollViewCursor; |
65 | |
66 | /* Drag 'n Drop */ |
67 | static CtkTargetEntry target_table[] = { |
68 | { "text/uri-list", 0, 0}, |
69 | }; |
70 | |
71 | enum { |
72 | PROP_0, |
73 | PROP_ANTIALIAS_IN, |
74 | PROP_ANTIALIAS_OUT, |
75 | PROP_BACKGROUND_COLOR, |
76 | PROP_IMAGE, |
77 | PROP_SCROLLWHEEL_ZOOM, |
78 | PROP_TRANSP_COLOR, |
79 | PROP_TRANSPARENCY_STYLE, |
80 | PROP_USE_BG_COLOR, |
81 | PROP_ZOOM_MULTIPLIER |
82 | }; |
83 | |
84 | /* Private part of the EocScrollView structure */ |
85 | struct _EocScrollViewPrivate { |
86 | /* some widgets we rely on */ |
87 | CtkWidget *display; |
88 | CtkAdjustment *hadj; |
89 | CtkAdjustment *vadj; |
90 | CtkWidget *hbar; |
91 | CtkWidget *vbar; |
92 | CtkWidget *menu; |
93 | |
94 | /* actual image */ |
95 | EocImage *image; |
96 | guint image_changed_id; |
97 | guint frame_changed_id; |
98 | GdkPixbuf *pixbuf; |
99 | cairo_surface_t *surface; |
100 | |
101 | /* scale factor */ |
102 | gint scale; |
103 | |
104 | /* zoom mode, either ZOOM_MODE_FIT or ZOOM_MODE_FREE */ |
105 | ZoomMode zoom_mode; |
106 | |
107 | /* whether to allow zoom > 1.0 on zoom fit */ |
108 | gboolean upscale; |
109 | |
110 | /* the actual zoom factor */ |
111 | double zoom; |
112 | |
113 | /* the minimum possible (reasonable) zoom factor */ |
114 | double min_zoom; |
115 | |
116 | /* Current scrolling offsets */ |
117 | int xofs, yofs; |
118 | |
119 | /* handler ID for paint idle callback */ |
120 | guint idle_id; |
121 | |
122 | /* Interpolation type when zoomed in*/ |
123 | cairo_filter_t interp_type_in; |
124 | |
125 | /* Interpolation type when zoomed out*/ |
126 | cairo_filter_t interp_type_out; |
127 | |
128 | /* Scroll wheel zoom */ |
129 | gboolean scroll_wheel_zoom; |
130 | |
131 | /* Scroll wheel zoom */ |
132 | gdouble zoom_multiplier; |
133 | |
134 | /* dragging stuff */ |
135 | int drag_anchor_x, drag_anchor_y; |
136 | int drag_ofs_x, drag_ofs_y; |
137 | guint dragging : 1; |
138 | |
139 | /* how to indicate transparency in images */ |
140 | EocTransparencyStyle transp_style; |
141 | CdkRGBA transp_color; |
142 | |
143 | /* the type of the cursor we are currently showing */ |
144 | EocScrollViewCursor cursor; |
145 | |
146 | gboolean use_bg_color; |
147 | CdkRGBA *background_color; |
148 | CdkRGBA *override_bg_color; |
149 | |
150 | cairo_surface_t *background_surface; |
151 | |
152 | /* Two-pass filtering */ |
153 | GSource *hq_redraw_timeout_source; |
154 | gboolean force_unfiltered; |
155 | }; |
156 | |
157 | static void scroll_by (EocScrollView *view, int xofs, int yofs); |
158 | static void set_zoom_fit (EocScrollView *view); |
159 | /* static void request_paint_area (EocScrollView *view, CdkRectangle *area); */ |
160 | static void set_minimum_zoom_factor (EocScrollView *view); |
161 | static void view_on_drag_begin_cb (CtkWidget *widget, CdkDragContext *context, |
162 | gpointer user_data); |
163 | static void view_on_drag_data_get_cb (CtkWidget *widget, |
164 | CdkDragContext*drag_context, |
165 | CtkSelectionData *data, guint info, |
166 | guint time, gpointer user_data); |
167 | |
168 | static gboolean _eoc_cdk_rgba_equal0 (const CdkRGBA *a, const CdkRGBA *b); |
169 | |
170 | G_DEFINE_TYPE_WITH_PRIVATE (EocScrollView, eoc_scroll_view, CTK_TYPE_GRID)static void eoc_scroll_view_init (EocScrollView *self); static void eoc_scroll_view_class_init (EocScrollViewClass *klass); static GType eoc_scroll_view_get_type_once (void); static gpointer eoc_scroll_view_parent_class = ((void*)0); static gint EocScrollView_private_offset ; static void eoc_scroll_view_class_intern_init (gpointer klass ) { eoc_scroll_view_parent_class = g_type_class_peek_parent ( klass); if (EocScrollView_private_offset != 0) g_type_class_adjust_private_offset (klass, &EocScrollView_private_offset); eoc_scroll_view_class_init ((EocScrollViewClass*) klass); } __attribute__ ((__unused__) ) static inline gpointer eoc_scroll_view_get_instance_private (EocScrollView *self) { return (((gpointer) ((guint8*) (self ) + (glong) (EocScrollView_private_offset)))); } GType eoc_scroll_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = eoc_scroll_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType eoc_scroll_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_grid_get_type ()), g_intern_static_string ("EocScrollView" ), sizeof (EocScrollViewClass), (GClassInitFunc)(void (*)(void )) eoc_scroll_view_class_intern_init, sizeof (EocScrollView), (GInstanceInitFunc)(void (*)(void)) eoc_scroll_view_init, (GTypeFlags ) 0); { {{ EocScrollView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (EocScrollViewPrivate)); };} } return g_define_type_id; } |
171 | |
172 | /*=================================== |
173 | widget size changing handler & |
174 | util functions |
175 | ---------------------------------*/ |
176 | |
177 | static cairo_surface_t * |
178 | create_surface_from_pixbuf (EocScrollView *view, GdkPixbuf *pixbuf) |
179 | { |
180 | cairo_surface_t *surface; |
181 | |
182 | surface = cdk_cairo_surface_create_from_pixbuf (pixbuf, |
183 | view->priv->scale, |
184 | ctk_widget_get_window (view->priv->display)); |
185 | |
186 | return surface; |
187 | } |
188 | |
189 | /* Disconnects from the EocImage and removes references to it */ |
190 | static void |
191 | free_image_resources (EocScrollView *view) |
192 | { |
193 | EocScrollViewPrivate *priv; |
194 | |
195 | priv = view->priv; |
196 | |
197 | if (priv->image_changed_id > 0) { |
198 | g_signal_handler_disconnect (G_OBJECT (priv->image)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->image)), (((GType) ((20) << (2)))))))), priv->image_changed_id); |
199 | priv->image_changed_id = 0; |
200 | } |
201 | |
202 | if (priv->frame_changed_id > 0) { |
203 | g_signal_handler_disconnect (G_OBJECT (priv->image)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->image)), (((GType) ((20) << (2)))))))), priv->frame_changed_id); |
204 | priv->frame_changed_id = 0; |
205 | } |
206 | |
207 | if (priv->image != NULL((void*)0)) { |
208 | eoc_image_data_unref (priv->image); |
209 | priv->image = NULL((void*)0); |
210 | } |
211 | |
212 | if (priv->pixbuf != NULL((void*)0)) { |
213 | g_object_unref (priv->pixbuf); |
214 | priv->pixbuf = NULL((void*)0); |
215 | } |
216 | |
217 | if (priv->surface !=NULL((void*)0)) { |
218 | cairo_surface_destroy (priv->surface); |
219 | priv->surface = NULL((void*)0); |
220 | } |
221 | } |
222 | |
223 | /* Computes the size in pixels of the scaled image */ |
224 | static void |
225 | compute_scaled_size (EocScrollView *view, double zoom, int *width, int *height) |
226 | { |
227 | EocScrollViewPrivate *priv; |
228 | |
229 | priv = view->priv; |
230 | |
231 | if (priv->pixbuf) { |
232 | *width = floor (gdk_pixbuf_get_width (priv->pixbuf) / priv->scale * zoom + 0.5); |
233 | *height = floor (gdk_pixbuf_get_height (priv->pixbuf) / priv->scale * zoom + 0.5); |
234 | } else |
235 | *width = *height = 0; |
236 | } |
237 | |
238 | /* Computes the offsets for the new zoom value so that they keep the image |
239 | * centered on the view. |
240 | */ |
241 | static void |
242 | compute_center_zoom_offsets (EocScrollView *view, |
243 | double old_zoom, double new_zoom, |
244 | int width, int height, |
245 | double zoom_x_anchor, double zoom_y_anchor, |
246 | int *xofs, int *yofs) |
247 | { |
248 | EocScrollViewPrivate *priv; |
249 | int old_scaled_width, old_scaled_height; |
250 | int new_scaled_width, new_scaled_height; |
251 | double view_cx, view_cy; |
252 | |
253 | priv = view->priv; |
254 | |
255 | compute_scaled_size (view, old_zoom, |
256 | &old_scaled_width, &old_scaled_height); |
257 | |
258 | if (old_scaled_width < width) |
259 | view_cx = (zoom_x_anchor * old_scaled_width) / old_zoom; |
260 | else |
261 | view_cx = (priv->xofs + zoom_x_anchor * width) / old_zoom; |
262 | |
263 | if (old_scaled_height < height) |
264 | view_cy = (zoom_y_anchor * old_scaled_height) / old_zoom; |
265 | else |
266 | view_cy = (priv->yofs + zoom_y_anchor * height) / old_zoom; |
267 | |
268 | compute_scaled_size (view, new_zoom, |
269 | &new_scaled_width, &new_scaled_height); |
270 | |
271 | if (new_scaled_width < width) |
272 | *xofs = 0; |
273 | else { |
274 | *xofs = floor (view_cx * new_zoom - zoom_x_anchor * width + 0.5); |
275 | if (*xofs < 0) |
276 | *xofs = 0; |
277 | } |
278 | |
279 | if (new_scaled_height < height) |
280 | *yofs = 0; |
281 | else { |
282 | *yofs = floor (view_cy * new_zoom - zoom_y_anchor * height + 0.5); |
283 | if (*yofs < 0) |
284 | *yofs = 0; |
285 | } |
286 | } |
287 | |
288 | /* Sets the scrollbar values based on the current scrolling offset */ |
289 | static void |
290 | update_scrollbar_values (EocScrollView *view) |
291 | { |
292 | EocScrollViewPrivate *priv; |
293 | int scaled_width, scaled_height; |
294 | gdouble page_size,page_increment,step_increment; |
295 | gdouble lower, upper; |
296 | CtkAllocation allocation; |
297 | |
298 | priv = view->priv; |
299 | |
300 | if (!ctk_widget_get_visible (CTK_WIDGET (priv->hbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->hbar)), ((ctk_widget_get_type ()))))))) |
301 | && !ctk_widget_get_visible (CTK_WIDGET (priv->vbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->vbar)), ((ctk_widget_get_type ())))))))) |
302 | return; |
303 | |
304 | compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height); |
305 | ctk_widget_get_allocation (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ())))))), &allocation); |
306 | |
307 | if (ctk_widget_get_visible (CTK_WIDGET (priv->hbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->hbar)), ((ctk_widget_get_type ())))))))) { |
308 | /* Set scroll increments */ |
309 | page_size = MIN (scaled_width, allocation.width)(((scaled_width) < (allocation.width)) ? (scaled_width) : ( allocation.width)); |
310 | |
311 | page_increment = allocation.width / 2; |
312 | step_increment = SCROLL_STEP_SIZE32; |
313 | |
314 | /* Set scroll bounds and new offsets */ |
315 | lower = 0; |
316 | upper = scaled_width; |
317 | priv->xofs = CLAMP (priv->xofs, 0, upper - page_size)(((priv->xofs) > (upper - page_size)) ? (upper - page_size ) : (((priv->xofs) < (0)) ? (0) : (priv->xofs))); |
318 | |
319 | g_signal_handlers_block_matched ( |
320 | priv->hadj, G_SIGNAL_MATCH_DATA, |
321 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
322 | |
323 | ctk_adjustment_configure (priv->hadj, priv->xofs, lower, |
324 | upper, step_increment, |
325 | page_increment, page_size); |
326 | |
327 | g_signal_handlers_unblock_matched ( |
328 | priv->hadj, G_SIGNAL_MATCH_DATA, |
329 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
330 | } |
331 | |
332 | if (ctk_widget_get_visible (CTK_WIDGET (priv->vbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->vbar)), ((ctk_widget_get_type ())))))))) { |
333 | page_size = MIN (scaled_height, allocation.height)(((scaled_height) < (allocation.height)) ? (scaled_height) : (allocation.height)); |
334 | page_increment = allocation.height / 2; |
335 | step_increment = SCROLL_STEP_SIZE32; |
336 | |
337 | lower = 0; |
338 | upper = scaled_height; |
339 | priv->yofs = CLAMP (priv->yofs, 0, upper - page_size)(((priv->yofs) > (upper - page_size)) ? (upper - page_size ) : (((priv->yofs) < (0)) ? (0) : (priv->yofs))); |
340 | |
341 | g_signal_handlers_block_matched ( |
342 | priv->vadj, G_SIGNAL_MATCH_DATA, |
343 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
344 | |
345 | ctk_adjustment_configure (priv->vadj, priv->yofs, lower, |
346 | upper, step_increment, |
347 | page_increment, page_size); |
348 | |
349 | g_signal_handlers_unblock_matched ( |
350 | priv->vadj, G_SIGNAL_MATCH_DATA, |
351 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
352 | } |
353 | } |
354 | |
355 | static void |
356 | eoc_scroll_view_set_cursor (EocScrollView *view, EocScrollViewCursor new_cursor) |
357 | { |
358 | CdkCursor *cursor = NULL((void*)0); |
359 | CdkDisplay *display; |
360 | CtkWidget *widget; |
361 | |
362 | if (view->priv->cursor == new_cursor) { |
363 | return; |
364 | } |
365 | |
366 | widget = ctk_widget_get_toplevel (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
367 | display = ctk_widget_get_display (widget); |
368 | view->priv->cursor = new_cursor; |
369 | |
370 | switch (new_cursor) { |
371 | case EOC_SCROLL_VIEW_CURSOR_NORMAL: |
372 | cdk_window_set_cursor (ctk_widget_get_window (widget), NULL((void*)0)); |
373 | break; |
374 | case EOC_SCROLL_VIEW_CURSOR_HIDDEN: |
375 | cursor = cdk_cursor_new_for_display (display, CDK_BLANK_CURSOR); |
376 | break; |
377 | case EOC_SCROLL_VIEW_CURSOR_DRAG: |
378 | cursor = cdk_cursor_new_for_display (display, CDK_FLEUR); |
379 | break; |
380 | } |
381 | |
382 | if (cursor) { |
383 | cdk_window_set_cursor (ctk_widget_get_window (widget), cursor); |
384 | g_object_unref (cursor); |
385 | cdk_display_flush (display); |
386 | } |
387 | } |
388 | |
389 | /* Changes visibility of the scrollbars based on the zoom factor and the |
390 | * specified allocation, or the current allocation if NULL is specified. |
391 | */ |
392 | static void |
393 | check_scrollbar_visibility (EocScrollView *view, CtkAllocation *alloc) |
394 | { |
395 | EocScrollViewPrivate *priv; |
396 | int bar_height; |
397 | int bar_width; |
398 | int img_width; |
399 | int img_height; |
400 | CtkRequisition req; |
401 | int width, height; |
402 | gboolean hbar_visible, vbar_visible; |
403 | |
404 | priv = view->priv; |
405 | |
406 | if (alloc) { |
407 | width = alloc->width; |
408 | height = alloc->height; |
409 | } else { |
410 | CtkAllocation allocation; |
411 | |
412 | ctk_widget_get_allocation (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), &allocation); |
413 | width = allocation.width; |
414 | height = allocation.height; |
415 | } |
416 | |
417 | compute_scaled_size (view, priv->zoom, &img_width, &img_height); |
418 | |
419 | /* this should work fairly well in this special case for scrollbars */ |
420 | ctk_widget_get_preferred_size (priv->hbar, &req, NULL((void*)0)); |
421 | bar_height = req.height; |
422 | ctk_widget_get_preferred_size (priv->vbar, &req, NULL((void*)0)); |
423 | bar_width = req.width; |
424 | |
425 | eoc_debug_message (DEBUG_WINDOWEOC_DEBUG_WINDOW, "eoc-scroll-view.c", 425, ((const char*) (__func__ )), "Widget Size allocate: %i, %i Bar: %i, %i\n", |
426 | width, height, bar_width, bar_height); |
427 | |
428 | hbar_visible = vbar_visible = FALSE(0); |
429 | if (priv->zoom_mode == ZOOM_MODE_FIT) |
430 | hbar_visible = vbar_visible = FALSE(0); |
431 | else if (img_width <= width && img_height <= height) |
432 | hbar_visible = vbar_visible = FALSE(0); |
433 | else if (img_width > width && img_height > height) |
434 | hbar_visible = vbar_visible = TRUE(!(0)); |
435 | else if (img_width > width) { |
436 | hbar_visible = TRUE(!(0)); |
437 | if (img_height <= (height - bar_height)) |
438 | vbar_visible = FALSE(0); |
439 | else |
440 | vbar_visible = TRUE(!(0)); |
441 | } |
442 | else if (img_height > height) { |
443 | vbar_visible = TRUE(!(0)); |
444 | if (img_width <= (width - bar_width)) |
445 | hbar_visible = FALSE(0); |
446 | else |
447 | hbar_visible = TRUE(!(0)); |
448 | } |
449 | |
450 | if (hbar_visible != ctk_widget_get_visible (CTK_WIDGET (priv->hbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->hbar)), ((ctk_widget_get_type ())))))))) |
451 | g_object_set (G_OBJECT (priv->hbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->hbar)), (((GType) ((20) << (2)))))))), "visible", hbar_visible, NULL((void*)0)); |
452 | |
453 | if (vbar_visible != ctk_widget_get_visible (CTK_WIDGET (priv->vbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->vbar)), ((ctk_widget_get_type ())))))))) |
454 | g_object_set (G_OBJECT (priv->vbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->vbar)), (((GType) ((20) << (2)))))))), "visible", vbar_visible, NULL((void*)0)); |
455 | } |
456 | |
457 | #define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6 |
458 | #define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6) |
459 | |
460 | /* Returns whether the image is zoomed in */ |
461 | static gboolean |
462 | is_zoomed_in (EocScrollView *view) |
463 | { |
464 | EocScrollViewPrivate *priv; |
465 | |
466 | priv = view->priv; |
467 | return priv->zoom - 1.0 > DOUBLE_EQUAL_MAX_DIFF1e-6; |
468 | } |
469 | |
470 | /* Returns whether the image is zoomed out */ |
471 | static gboolean |
472 | is_zoomed_out (EocScrollView *view) |
473 | { |
474 | EocScrollViewPrivate *priv; |
475 | |
476 | priv = view->priv; |
477 | return DOUBLE_EQUAL_MAX_DIFF1e-6 + priv->zoom - 1.0 < 0.0; |
478 | } |
479 | |
480 | /* Returns wether the image is movable, that means if it is larger then |
481 | * the actual visible area. |
482 | */ |
483 | static gboolean |
484 | is_image_movable (EocScrollView *view) |
485 | { |
486 | EocScrollViewPrivate *priv; |
487 | |
488 | priv = view->priv; |
489 | |
490 | return (ctk_widget_get_visible (priv->hbar) || ctk_widget_get_visible (priv->vbar)); |
491 | } |
492 | |
493 | /*=================================== |
494 | drawing core |
495 | ---------------------------------*/ |
496 | |
497 | static void |
498 | get_transparency_params (EocScrollView *view, int *size, CdkRGBA *color1, CdkRGBA *color2) |
499 | { |
500 | EocScrollViewPrivate *priv; |
501 | |
502 | priv = view->priv; |
503 | |
504 | /* Compute transparency parameters */ |
505 | switch (priv->transp_style) { |
506 | case EOC_TRANSP_BACKGROUND: { |
507 | /* Simply return fully transparent color */ |
508 | color1->red = color1->green = color1->blue = color1->alpha = 0.0; |
509 | color2->red = color2->green = color2->blue = color2->alpha = 0.0; |
510 | break; |
511 | } |
512 | |
513 | case EOC_TRANSP_CHECKED: |
514 | g_warn_if_fail (cdk_rgba_parse (color1, CHECK_GRAY))do { if (cdk_rgba_parse (color1, "#808080")) ; else g_warn_message ("EOC", "eoc-scroll-view.c", 514, ((const char*) (__func__)) , "cdk_rgba_parse (color1, CHECK_GRAY)"); } while (0); |
515 | g_warn_if_fail (cdk_rgba_parse (color2, CHECK_LIGHT))do { if (cdk_rgba_parse (color2, "#cccccc")) ; else g_warn_message ("EOC", "eoc-scroll-view.c", 515, ((const char*) (__func__)) , "cdk_rgba_parse (color2, CHECK_LIGHT)"); } while (0); |
516 | break; |
517 | |
518 | case EOC_TRANSP_COLOR: |
519 | *color1 = *color2 = priv->transp_color; |
520 | break; |
521 | |
522 | default: |
523 | g_assert_not_reached ()do { g_assertion_message_expr ("EOC", "eoc-scroll-view.c", 523 , ((const char*) (__func__)), ((void*)0)); } while (0); |
524 | }; |
525 | |
526 | *size = CHECK_MEDIUM8; |
527 | } |
528 | |
529 | static cairo_surface_t * |
530 | create_background_surface (EocScrollView *view) |
531 | { |
532 | int check_size; |
533 | CdkRGBA check_1; |
534 | CdkRGBA check_2; |
535 | cairo_surface_t *surface; |
536 | |
537 | get_transparency_params (view, &check_size, &check_1, &check_2); |
538 | surface = cdk_window_create_similar_surface (ctk_widget_get_window (view->priv->display), |
539 | CAIRO_CONTENT_COLOR_ALPHA, |
540 | check_size * 2, check_size * 2); |
541 | cairo_t* cr = cairo_create (surface); |
542 | |
543 | /* Use source operator to make fully transparent work */ |
544 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); |
545 | |
546 | cdk_cairo_set_source_rgba(cr, &check_1); |
547 | cairo_rectangle (cr, 0, 0, check_size, check_size); |
548 | cairo_rectangle (cr, check_size, check_size, check_size, check_size); |
549 | cairo_fill (cr); |
550 | |
551 | cdk_cairo_set_source_rgba(cr, &check_2); |
552 | cairo_rectangle (cr, 0, check_size, check_size, check_size); |
553 | cairo_rectangle (cr, check_size, 0, check_size, check_size); |
554 | cairo_fill (cr); |
555 | |
556 | cairo_destroy (cr); |
557 | |
558 | return surface; |
559 | } |
560 | |
561 | /* ======================================= |
562 | |
563 | scrolling stuff |
564 | |
565 | --------------------------------------*/ |
566 | |
567 | |
568 | /* Scrolls the view to the specified offsets. */ |
569 | static void |
570 | scroll_to (EocScrollView *view, int x, int y, gboolean change_adjustments) |
571 | { |
572 | EocScrollViewPrivate *priv; |
573 | CtkAllocation allocation; |
574 | int xofs, yofs; |
575 | CdkWindow *window; |
576 | |
577 | priv = view->priv; |
578 | |
579 | /* Check bounds & Compute offsets */ |
580 | if (ctk_widget_get_visible (priv->hbar)) { |
581 | x = CLAMP (x, 0, ctk_adjustment_get_upper (priv->hadj)(((x) > (ctk_adjustment_get_upper (priv->hadj) - ctk_adjustment_get_page_size (priv->hadj))) ? (ctk_adjustment_get_upper (priv->hadj ) - ctk_adjustment_get_page_size (priv->hadj)) : (((x) < (0)) ? (0) : (x))) |
582 | - ctk_adjustment_get_page_size (priv->hadj))(((x) > (ctk_adjustment_get_upper (priv->hadj) - ctk_adjustment_get_page_size (priv->hadj))) ? (ctk_adjustment_get_upper (priv->hadj ) - ctk_adjustment_get_page_size (priv->hadj)) : (((x) < (0)) ? (0) : (x))); |
583 | xofs = x - priv->xofs; |
584 | } else |
585 | xofs = 0; |
586 | |
587 | if (ctk_widget_get_visible (priv->vbar)) { |
588 | y = CLAMP (y, 0, ctk_adjustment_get_upper (priv->vadj)(((y) > (ctk_adjustment_get_upper (priv->vadj) - ctk_adjustment_get_page_size (priv->vadj))) ? (ctk_adjustment_get_upper (priv->vadj ) - ctk_adjustment_get_page_size (priv->vadj)) : (((y) < (0)) ? (0) : (y))) |
589 | - ctk_adjustment_get_page_size (priv->vadj))(((y) > (ctk_adjustment_get_upper (priv->vadj) - ctk_adjustment_get_page_size (priv->vadj))) ? (ctk_adjustment_get_upper (priv->vadj ) - ctk_adjustment_get_page_size (priv->vadj)) : (((y) < (0)) ? (0) : (y))); |
590 | yofs = y - priv->yofs; |
591 | } else |
592 | yofs = 0; |
593 | |
594 | if (xofs == 0 && yofs == 0) |
595 | return; |
596 | |
597 | priv->xofs = x; |
598 | priv->yofs = y; |
599 | |
600 | if (!ctk_widget_is_drawable (priv->display)) |
601 | goto out; |
602 | |
603 | ctk_widget_get_allocation (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ())))))), &allocation); |
604 | |
605 | if (abs (xofs) >= allocation.width || abs (yofs) >= allocation.height) { |
606 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
607 | goto out; |
608 | } |
609 | |
610 | window = ctk_widget_get_window (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
611 | |
612 | cdk_window_scroll (window, -xofs, -yofs); |
613 | |
614 | out: |
615 | if (!change_adjustments) |
616 | return; |
617 | |
618 | g_signal_handlers_block_matched ( |
619 | priv->hadj, G_SIGNAL_MATCH_DATA, |
620 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
621 | g_signal_handlers_block_matched ( |
622 | priv->vadj, G_SIGNAL_MATCH_DATA, |
623 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
624 | |
625 | ctk_adjustment_set_value (priv->hadj, x); |
626 | ctk_adjustment_set_value (priv->vadj, y); |
627 | |
628 | g_signal_handlers_unblock_matched ( |
629 | priv->hadj, G_SIGNAL_MATCH_DATA, |
630 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
631 | g_signal_handlers_unblock_matched ( |
632 | priv->vadj, G_SIGNAL_MATCH_DATA, |
633 | 0, 0, NULL((void*)0), NULL((void*)0), view); |
634 | } |
635 | |
636 | /* Scrolls the image view by the specified offsets. Notifies the adjustments |
637 | * about their new values. |
638 | */ |
639 | static void |
640 | scroll_by (EocScrollView *view, int xofs, int yofs) |
641 | { |
642 | EocScrollViewPrivate *priv; |
643 | |
644 | priv = view->priv; |
645 | |
646 | scroll_to (view, priv->xofs + xofs, priv->yofs + yofs, TRUE(!(0))); |
647 | } |
648 | |
649 | |
650 | /* Callback used when an adjustment is changed */ |
651 | static void |
652 | adjustment_changed_cb (CtkAdjustment *adj G_GNUC_UNUSED__attribute__ ((__unused__)), |
653 | gpointer data) |
654 | { |
655 | EocScrollView *view; |
656 | EocScrollViewPrivate *priv; |
657 | |
658 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
659 | priv = view->priv; |
660 | |
661 | scroll_to (view, ctk_adjustment_get_value (priv->hadj), |
662 | ctk_adjustment_get_value (priv->vadj), FALSE(0)); |
663 | |
664 | ctk_widget_queue_resize (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
665 | } |
666 | |
667 | |
668 | /* Drags the image to the specified position */ |
669 | static void |
670 | drag_to (EocScrollView *view, int x, int y) |
671 | { |
672 | EocScrollViewPrivate *priv; |
673 | int dx, dy; |
674 | |
675 | priv = view->priv; |
676 | |
677 | dx = priv->drag_anchor_x - x; |
678 | dy = priv->drag_anchor_y - y; |
679 | |
680 | x = priv->drag_ofs_x + dx; |
681 | y = priv->drag_ofs_y + dy; |
682 | |
683 | scroll_to (view, x, y, TRUE(!(0))); |
684 | } |
685 | |
686 | static void |
687 | set_minimum_zoom_factor (EocScrollView *view) |
688 | { |
689 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
690 | |
691 | view->priv->min_zoom = MAX (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view->priv->scale,(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view ->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view ->priv->pixbuf) / view->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view ->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view->priv->scale) : (((( 1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view ->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view->priv->scale) : (0.02 )))) |
692 | MAX(1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view->priv->scale,(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view ->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view ->priv->pixbuf) / view->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view ->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view->priv->scale) : (((( 1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view ->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view->priv->scale) : (0.02 )))) |
693 | MIN_ZOOM_FACTOR) )(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view ->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view ->priv->pixbuf) / view->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view ->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view->priv->scale) : (((( 1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view ->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view->priv->scale) : (0.02 )))); |
694 | return; |
695 | } |
696 | |
697 | /** |
698 | * set_zoom: |
699 | * @view: A scroll view. |
700 | * @zoom: Zoom factor. |
701 | * @have_anchor: Whether the anchor point specified by (@anchorx, @anchory) |
702 | * should be used. |
703 | * @anchorx: Horizontal anchor point in pixels. |
704 | * @anchory: Vertical anchor point in pixels. |
705 | * |
706 | * Sets the zoom factor for an image view. The anchor point can be used to |
707 | * specify the point that stays fixed when the image is zoomed. If @have_anchor |
708 | * is %TRUE, then (@anchorx, @anchory) specify the point relative to the image |
709 | * view widget's allocation that will stay fixed when zooming. If @have_anchor |
710 | * is %FALSE, then the center point of the image view will be used. |
711 | **/ |
712 | static void |
713 | set_zoom (EocScrollView *view, double zoom, |
714 | gboolean have_anchor, int anchorx, int anchory) |
715 | { |
716 | EocScrollViewPrivate *priv; |
717 | CtkAllocation allocation; |
718 | int xofs, yofs; |
719 | double x_rel, y_rel; |
720 | |
721 | priv = view->priv; |
722 | |
723 | if (priv->pixbuf == NULL((void*)0)) |
724 | return; |
725 | |
726 | if (zoom > MAX_ZOOM_FACTOR20) |
727 | zoom = MAX_ZOOM_FACTOR20; |
728 | else if (zoom < MIN_ZOOM_FACTOR0.02) |
729 | zoom = MIN_ZOOM_FACTOR0.02; |
730 | |
731 | if (DOUBLE_EQUAL (priv->zoom, zoom)(fabs (priv->zoom - zoom) < 1e-6)) |
732 | return; |
733 | if (DOUBLE_EQUAL (priv->zoom, priv->min_zoom)(fabs (priv->zoom - priv->min_zoom) < 1e-6) && zoom < priv->zoom) |
734 | return; |
735 | |
736 | priv->zoom_mode = ZOOM_MODE_FREE; |
737 | |
738 | ctk_widget_get_allocation (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ())))))), &allocation); |
739 | |
740 | /* compute new xofs/yofs values */ |
741 | if (have_anchor) { |
742 | x_rel = (double) anchorx / allocation.width; |
743 | y_rel = (double) anchory / allocation.height; |
744 | } else { |
745 | x_rel = 0.5; |
746 | y_rel = 0.5; |
747 | } |
748 | |
749 | compute_center_zoom_offsets (view, priv->zoom, zoom, |
750 | allocation.width, allocation.height, |
751 | x_rel, y_rel, |
752 | &xofs, &yofs); |
753 | |
754 | /* set new values */ |
755 | priv->xofs = xofs; /* (img_width * x_rel * zoom) - anchorx; */ |
756 | priv->yofs = yofs; /* (img_height * y_rel * zoom) - anchory; */ |
757 | #if 0 |
758 | g_print ("xofs: %i yofs: %i\n", priv->xofs, priv->yofs); |
759 | #endif |
760 | if (zoom <= priv->min_zoom) |
761 | priv->zoom = priv->min_zoom; |
762 | else |
763 | priv->zoom = zoom; |
764 | |
765 | /* we make use of the new values here */ |
766 | check_scrollbar_visibility (view, NULL((void*)0)); |
767 | update_scrollbar_values (view); |
768 | |
769 | /* repaint the whole image */ |
770 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
771 | |
772 | g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom); |
773 | } |
774 | |
775 | /* Zooms the image to fit the available allocation */ |
776 | static void |
777 | set_zoom_fit (EocScrollView *view) |
778 | { |
779 | EocScrollViewPrivate *priv; |
780 | CtkAllocation allocation; |
781 | double new_zoom; |
782 | |
783 | priv = view->priv; |
784 | |
785 | priv->zoom_mode = ZOOM_MODE_FIT; |
786 | |
787 | if (!ctk_widget_get_mapped (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))))) |
788 | return; |
789 | |
790 | if (priv->pixbuf == NULL((void*)0)) |
791 | return; |
792 | |
793 | ctk_widget_get_allocation (CTK_WIDGET(priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ())))))), &allocation); |
794 | |
795 | new_zoom = zoom_fit_scale (allocation.width, allocation.height, |
796 | gdk_pixbuf_get_width (priv->pixbuf) / priv->scale, |
797 | gdk_pixbuf_get_height (priv->pixbuf) / priv->scale, |
798 | priv->upscale); |
799 | |
800 | if (new_zoom > MAX_ZOOM_FACTOR20) |
801 | new_zoom = MAX_ZOOM_FACTOR20; |
802 | else if (new_zoom < MIN_ZOOM_FACTOR0.02) |
803 | new_zoom = MIN_ZOOM_FACTOR0.02; |
804 | |
805 | priv->zoom = new_zoom; |
806 | priv->xofs = 0; |
807 | priv->yofs = 0; |
808 | |
809 | g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom); |
810 | } |
811 | |
812 | /*=================================== |
813 | |
814 | internal signal callbacks |
815 | |
816 | ---------------------------------*/ |
817 | |
818 | /* Key press event handler for the image view */ |
819 | static gboolean |
820 | display_key_press_event (CtkWidget *widget, CdkEventKey *event, gpointer data) |
821 | { |
822 | EocScrollView *view; |
823 | EocScrollViewPrivate *priv; |
824 | CtkAllocation allocation; |
825 | gboolean do_zoom; |
826 | double zoom; |
827 | gboolean do_scroll; |
828 | int xofs, yofs; |
829 | |
830 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
831 | priv = view->priv; |
832 | |
833 | do_zoom = FALSE(0); |
834 | do_scroll = FALSE(0); |
835 | xofs = yofs = 0; |
836 | zoom = 1.0; |
837 | |
838 | ctk_widget_get_allocation (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ())))))), &allocation); |
839 | |
840 | /* EocScrollView doesn't handle/have any Alt+Key combos */ |
841 | if (event->state & CDK_MOD1_MASK) { |
842 | return FALSE(0); |
843 | } |
844 | |
845 | switch (event->keyval) { |
846 | case CDK_KEY_Up0xff52: |
847 | do_scroll = TRUE(!(0)); |
848 | xofs = 0; |
849 | yofs = -SCROLL_STEP_SIZE32; |
850 | break; |
851 | |
852 | case CDK_KEY_Page_Up0xff55: |
853 | do_scroll = TRUE(!(0)); |
854 | if (event->state & CDK_CONTROL_MASK) { |
855 | xofs = -(allocation.width * 3) / 4; |
856 | yofs = 0; |
857 | } else { |
858 | xofs = 0; |
859 | yofs = -(allocation.height * 3) / 4; |
860 | } |
861 | break; |
862 | |
863 | case CDK_KEY_Down0xff54: |
864 | do_scroll = TRUE(!(0)); |
865 | xofs = 0; |
866 | yofs = SCROLL_STEP_SIZE32; |
867 | break; |
868 | |
869 | case CDK_KEY_Page_Down0xff56: |
870 | do_scroll = TRUE(!(0)); |
871 | if (event->state & CDK_CONTROL_MASK) { |
872 | xofs = (allocation.width * 3) / 4; |
873 | yofs = 0; |
874 | } else { |
875 | xofs = 0; |
876 | yofs = (allocation.height * 3) / 4; |
877 | } |
878 | break; |
879 | |
880 | case CDK_KEY_Left0xff51: |
881 | do_scroll = TRUE(!(0)); |
882 | xofs = -SCROLL_STEP_SIZE32; |
883 | yofs = 0; |
884 | break; |
885 | |
886 | case CDK_KEY_Right0xff53: |
887 | do_scroll = TRUE(!(0)); |
888 | xofs = SCROLL_STEP_SIZE32; |
889 | yofs = 0; |
890 | break; |
891 | |
892 | case CDK_KEY_plus0x02b: |
893 | case CDK_KEY_equal0x03d: |
894 | case CDK_KEY_KP_Add0xffab: |
895 | do_zoom = TRUE(!(0)); |
896 | zoom = priv->zoom * priv->zoom_multiplier; |
897 | break; |
898 | |
899 | case CDK_KEY_minus0x02d: |
900 | case CDK_KEY_KP_Subtract0xffad: |
901 | do_zoom = TRUE(!(0)); |
902 | zoom = priv->zoom / priv->zoom_multiplier; |
903 | break; |
904 | |
905 | case CDK_KEY_10x031: |
906 | do_zoom = TRUE(!(0)); |
907 | zoom = 1.0; |
908 | break; |
909 | |
910 | default: |
911 | return FALSE(0); |
912 | } |
913 | |
914 | if (do_zoom) { |
915 | CdkSeat *seat; |
916 | CdkDevice *device; |
917 | gint x, y; |
918 | |
919 | seat = cdk_display_get_default_seat (ctk_widget_get_display (widget)); |
920 | device = cdk_seat_get_pointer (seat); |
921 | |
922 | cdk_window_get_device_position (ctk_widget_get_window (widget), device, |
923 | &x, &y, NULL((void*)0)); |
924 | set_zoom (view, zoom, TRUE(!(0)), x, y); |
925 | } |
926 | |
927 | if (do_scroll) |
928 | scroll_by (view, xofs, yofs); |
929 | |
930 | return TRUE(!(0)); |
931 | } |
932 | |
933 | |
934 | /* Button press event handler for the image view */ |
935 | static gboolean |
936 | eoc_scroll_view_button_press_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
937 | CdkEventButton *event, |
938 | gpointer data) |
939 | { |
940 | EocScrollView *view; |
941 | EocScrollViewPrivate *priv; |
942 | |
943 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
944 | priv = view->priv; |
945 | |
946 | if (!ctk_widget_has_focus (priv->display)) |
947 | ctk_widget_grab_focus (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
948 | |
949 | if (priv->dragging) |
950 | return FALSE(0); |
951 | |
952 | switch (event->button) { |
953 | case 1: |
954 | case 2: |
955 | if (event->button == 1 && !priv->scroll_wheel_zoom && |
956 | !(event->state & CDK_CONTROL_MASK)) |
957 | break; |
958 | |
959 | if (is_image_movable (view)) { |
960 | eoc_scroll_view_set_cursor (view, EOC_SCROLL_VIEW_CURSOR_DRAG); |
961 | |
962 | priv->dragging = TRUE(!(0)); |
963 | priv->drag_anchor_x = event->x; |
964 | priv->drag_anchor_y = event->y; |
965 | |
966 | priv->drag_ofs_x = priv->xofs; |
967 | priv->drag_ofs_y = priv->yofs; |
968 | |
969 | ctk_widget_queue_resize (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
970 | |
971 | return TRUE(!(0)); |
972 | } |
973 | default: |
974 | break; |
975 | } |
976 | |
977 | return FALSE(0); |
978 | } |
979 | |
980 | /* Button release event handler for the image view */ |
981 | static gboolean |
982 | eoc_scroll_view_button_release_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
983 | CdkEventButton *event, |
984 | gpointer data) |
985 | { |
986 | EocScrollView *view; |
987 | EocScrollViewPrivate *priv; |
988 | |
989 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
990 | priv = view->priv; |
991 | |
992 | if (!priv->dragging) |
993 | return FALSE(0); |
994 | |
995 | switch (event->button) { |
996 | case 1: |
997 | case 2: |
998 | drag_to (view, event->x, event->y); |
999 | priv->dragging = FALSE(0); |
1000 | |
1001 | eoc_scroll_view_set_cursor (view, EOC_SCROLL_VIEW_CURSOR_NORMAL); |
1002 | break; |
1003 | |
1004 | default: |
1005 | break; |
1006 | } |
1007 | |
1008 | return TRUE(!(0)); |
1009 | } |
1010 | |
1011 | /* Scroll event handler for the image view. We zoom with an event without |
1012 | * modifiers rather than scroll; we use the Shift modifier to scroll. |
1013 | * Rationale: images are not primarily vertical, and in EOC you scan scroll by |
1014 | * dragging the image with button 1 anyways. |
1015 | */ |
1016 | static gboolean |
1017 | eoc_scroll_view_scroll_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1018 | CdkEventScroll *event, |
1019 | gpointer data) |
1020 | { |
1021 | EocScrollView *view; |
1022 | EocScrollViewPrivate *priv; |
1023 | double zoom_factor; |
1024 | int xofs, yofs; |
1025 | |
1026 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
1027 | priv = view->priv; |
1028 | |
1029 | /* Compute zoom factor and scrolling offsets; we'll only use either of them */ |
1030 | /* same as in ctkscrolledwindow.c */ |
1031 | xofs = ctk_adjustment_get_page_increment (priv->hadj) / 2; |
1032 | yofs = ctk_adjustment_get_page_increment (priv->vadj) / 2; |
1033 | |
1034 | switch (event->direction) { |
1035 | case CDK_SCROLL_UP: |
1036 | zoom_factor = priv->zoom_multiplier; |
1037 | xofs = 0; |
1038 | yofs = -yofs; |
1039 | break; |
1040 | |
1041 | case CDK_SCROLL_LEFT: |
1042 | zoom_factor = 1.0 / priv->zoom_multiplier; |
1043 | xofs = -xofs; |
1044 | yofs = 0; |
1045 | break; |
1046 | |
1047 | case CDK_SCROLL_DOWN: |
1048 | zoom_factor = 1.0 / priv->zoom_multiplier; |
1049 | xofs = 0; |
1050 | yofs = yofs; |
1051 | break; |
1052 | |
1053 | case CDK_SCROLL_RIGHT: |
1054 | zoom_factor = priv->zoom_multiplier; |
1055 | xofs = xofs; |
1056 | yofs = 0; |
1057 | break; |
1058 | |
1059 | default: |
1060 | g_assert_not_reached ()do { g_assertion_message_expr ("EOC", "eoc-scroll-view.c", 1060 , ((const char*) (__func__)), ((void*)0)); } while (0); |
1061 | return FALSE(0); |
1062 | } |
1063 | |
1064 | if (priv->scroll_wheel_zoom) { |
1065 | if (event->state & CDK_SHIFT_MASK) |
1066 | scroll_by (view, yofs, xofs); |
1067 | else if (event->state & CDK_CONTROL_MASK) |
1068 | scroll_by (view, xofs, yofs); |
1069 | else |
1070 | set_zoom (view, priv->zoom * zoom_factor, |
1071 | TRUE(!(0)), event->x, event->y); |
1072 | } else { |
1073 | if (event->state & CDK_SHIFT_MASK) |
1074 | scroll_by (view, yofs, xofs); |
1075 | else if (event->state & CDK_CONTROL_MASK) |
1076 | set_zoom (view, priv->zoom * zoom_factor, |
1077 | TRUE(!(0)), event->x, event->y); |
1078 | else |
1079 | scroll_by (view, xofs, yofs); |
1080 | } |
1081 | |
1082 | return TRUE(!(0)); |
1083 | } |
1084 | |
1085 | /* Motion event handler for the image view */ |
1086 | static gboolean |
1087 | eoc_scroll_view_motion_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1088 | CdkEventMotion *event, |
1089 | gpointer data) |
1090 | { |
1091 | EocScrollView *view; |
1092 | EocScrollViewPrivate *priv; |
1093 | gint x, y; |
1094 | CdkModifierType mods; |
1095 | |
1096 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
1097 | priv = view->priv; |
1098 | |
1099 | if (!priv->dragging) |
1100 | return FALSE(0); |
1101 | |
1102 | if (event->is_hint) |
1103 | cdk_window_get_device_position (ctk_widget_get_window (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))), event->device, &x, &y, &mods); |
1104 | else { |
1105 | x = event->x; |
1106 | y = event->y; |
1107 | } |
1108 | |
1109 | drag_to (view, x, y); |
1110 | return TRUE(!(0)); |
1111 | } |
1112 | |
1113 | static void |
1114 | display_map_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1115 | CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)), |
1116 | gpointer data) |
1117 | { |
1118 | EocScrollView *view; |
1119 | EocScrollViewPrivate *priv; |
1120 | |
1121 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
1122 | priv = view->priv; |
1123 | |
1124 | eoc_debug (DEBUG_WINDOWEOC_DEBUG_WINDOW, "eoc-scroll-view.c", 1124, ((const char*) ( __func__))); |
1125 | |
1126 | set_zoom_fit (view); |
1127 | check_scrollbar_visibility (view, NULL((void*)0)); |
1128 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1129 | } |
1130 | |
1131 | static void |
1132 | eoc_scroll_view_size_allocate (CtkWidget *widget, CtkAllocation *alloc) |
1133 | { |
1134 | EocScrollView *view; |
1135 | |
1136 | view = EOC_SCROLL_VIEW (widget)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((eoc_scroll_view_get_type ())))))); |
1137 | check_scrollbar_visibility (view, alloc); |
1138 | |
1139 | CTK_WIDGET_CLASS (eoc_scroll_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((eoc_scroll_view_parent_class)), ((ctk_widget_get_type () ))))))->size_allocate (widget |
1140 | ,alloc); |
1141 | } |
1142 | |
1143 | static void |
1144 | display_size_change (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1145 | CdkEventConfigure *event, |
1146 | gpointer data) |
1147 | { |
1148 | EocScrollView *view; |
1149 | EocScrollViewPrivate *priv; |
1150 | |
1151 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
1152 | priv = view->priv; |
1153 | |
1154 | if (priv->zoom_mode == ZOOM_MODE_FIT) { |
1155 | CtkAllocation alloc; |
1156 | |
1157 | alloc.width = event->width; |
1158 | alloc.height = event->height; |
1159 | |
1160 | set_zoom_fit (view); |
1161 | check_scrollbar_visibility (view, &alloc); |
1162 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1163 | } else { |
1164 | int scaled_width, scaled_height; |
1165 | int x_offset = 0; |
1166 | int y_offset = 0; |
1167 | |
1168 | compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height); |
1169 | |
1170 | if (priv->xofs + event->width > scaled_width) |
1171 | x_offset = scaled_width - event->width - priv->xofs; |
1172 | |
1173 | if (priv->yofs + event->height > scaled_height) |
1174 | y_offset = scaled_height - event->height - priv->yofs; |
1175 | |
1176 | scroll_by (view, x_offset, y_offset); |
1177 | } |
1178 | |
1179 | update_scrollbar_values (view); |
1180 | } |
1181 | |
1182 | |
1183 | static gboolean |
1184 | eoc_scroll_view_focus_in_event (CtkWidget *widget, |
1185 | CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__)), |
1186 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
1187 | { |
1188 | g_signal_stop_emission_by_name (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), (((GType) ((20) << (2)))))))), "focus_in_event"); |
1189 | return FALSE(0); |
1190 | } |
1191 | |
1192 | static gboolean |
1193 | eoc_scroll_view_focus_out_event (CtkWidget *widget, |
1194 | CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__)), |
1195 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
1196 | { |
1197 | g_signal_stop_emission_by_name (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), (((GType) ((20) << (2)))))))), "focus_out_event"); |
1198 | return FALSE(0); |
1199 | } |
1200 | |
1201 | static gboolean _hq_redraw_cb (gpointer user_data) |
1202 | { |
1203 | EocScrollViewPrivate *priv = EOC_SCROLL_VIEW (user_data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((eoc_scroll_view_get_type ()))))))->priv; |
1204 | |
1205 | priv->force_unfiltered = FALSE(0); |
1206 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1207 | |
1208 | priv->hq_redraw_timeout_source = NULL((void*)0); |
1209 | return G_SOURCE_REMOVE(0); |
1210 | } |
1211 | |
1212 | static void |
1213 | _clear_hq_redraw_timeout (EocScrollView *view) |
1214 | { |
1215 | EocScrollViewPrivate *priv = view->priv; |
1216 | |
1217 | if (priv->hq_redraw_timeout_source != NULL((void*)0)) { |
1218 | g_source_unref (priv->hq_redraw_timeout_source); |
1219 | g_source_destroy (priv->hq_redraw_timeout_source); |
1220 | } |
1221 | |
1222 | priv->hq_redraw_timeout_source = NULL((void*)0); |
1223 | } |
1224 | |
1225 | static void |
1226 | _set_hq_redraw_timeout (EocScrollView *view) |
1227 | { |
1228 | GSource *source; |
1229 | |
1230 | _clear_hq_redraw_timeout (view); |
1231 | |
1232 | source = g_timeout_source_new (200); |
1233 | g_source_set_callback (source, &_hq_redraw_cb, view, NULL((void*)0)); |
1234 | |
1235 | g_source_attach (source, NULL((void*)0)); |
1236 | |
1237 | view->priv->hq_redraw_timeout_source = source; |
1238 | } |
1239 | |
1240 | static gboolean |
1241 | display_draw (CtkWidget *widget, cairo_t *cr, gpointer data) |
1242 | { |
1243 | const CdkRGBA *background_color = NULL((void*)0); |
1244 | EocScrollView *view; |
1245 | EocScrollViewPrivate *priv; |
1246 | CtkAllocation allocation; |
1247 | int scaled_width, scaled_height; |
1248 | int xofs, yofs; |
1249 | |
1250 | g_return_val_if_fail (CTK_IS_DRAWING_AREA (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_drawing_area_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "CTK_IS_DRAWING_AREA (widget)"); return ((0)); } } while ( 0); |
1251 | g_return_val_if_fail (EOC_IS_SCROLL_VIEW (data), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((data)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (data)"); return ((0)); } } while (0); |
1252 | |
1253 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
1254 | |
1255 | priv = view->priv; |
1256 | |
1257 | if (priv->pixbuf == NULL((void*)0)) |
1258 | return TRUE(!(0)); |
1259 | |
1260 | compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height); |
1261 | |
1262 | ctk_widget_get_allocation (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ())))))), &allocation); |
1263 | |
1264 | /* Compute image offsets with respect to the window */ |
1265 | |
1266 | if (scaled_width <= allocation.width) |
1267 | xofs = (allocation.width - scaled_width) / 2; |
1268 | else |
1269 | xofs = -priv->xofs; |
1270 | |
1271 | if (scaled_height <= allocation.height) |
1272 | yofs = (allocation.height - scaled_height) / 2; |
1273 | else |
1274 | yofs = -priv->yofs; |
1275 | |
1276 | eoc_debug_message (DEBUG_WINDOWEOC_DEBUG_WINDOW, "eoc-scroll-view.c", 1276, ((const char*) ( __func__)), "zoom %.2f, xofs: %i, yofs: %i scaled w: %i h: %i\n", |
1277 | priv->zoom, xofs, yofs, scaled_width, scaled_height); |
1278 | |
1279 | /* Paint the background */ |
1280 | cairo_rectangle (cr, 0, 0, allocation.width, allocation.height); |
1281 | if (priv->transp_style != EOC_TRANSP_BACKGROUND) |
1282 | cairo_rectangle (cr, MAX (0, xofs)(((0) > (xofs)) ? (0) : (xofs)), MAX (0, yofs)(((0) > (yofs)) ? (0) : (yofs)), |
1283 | scaled_width, scaled_height); |
1284 | if (priv->override_bg_color != NULL((void*)0)) |
1285 | background_color = priv->override_bg_color; |
1286 | else if (priv->use_bg_color) |
1287 | background_color = priv->background_color; |
1288 | if (background_color != NULL((void*)0)) |
1289 | cairo_set_source_rgba (cr, |
1290 | background_color->red, |
1291 | background_color->green, |
1292 | background_color->blue, |
1293 | background_color->alpha); |
1294 | else |
1295 | cairo_set_source (cr, cdk_window_get_background_pattern (ctk_widget_get_window (priv->display))); |
1296 | cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); |
1297 | cairo_fill (cr); |
1298 | |
1299 | if (gdk_pixbuf_get_has_alpha (priv->pixbuf)) { |
1300 | if (priv->background_surface == NULL((void*)0)) { |
1301 | priv->background_surface = create_background_surface (view); |
1302 | } |
1303 | cairo_set_source_surface (cr, priv->background_surface, xofs, yofs); |
1304 | cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT); |
1305 | cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height); |
1306 | cairo_fill (cr); |
1307 | } |
1308 | |
1309 | /* Make sure the image is only drawn as large as needed. |
1310 | * This is especially necessary for SVGs where there might |
1311 | * be more image data available outside the image boundaries. |
1312 | */ |
1313 | cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height); |
1314 | cairo_clip (cr); |
1315 | |
1316 | #ifdef HAVE_RSVG1 |
1317 | if (eoc_image_is_svg (view->priv->image)) { |
1318 | cairo_matrix_t matrix, translate, scale, original; |
1319 | EocTransform *transform = eoc_image_get_transform (priv->image); |
1320 | cairo_matrix_init_identity (&matrix); |
1321 | if (transform) { |
1322 | cairo_matrix_t affine; |
1323 | double image_offset_x = 0., image_offset_y = 0.; |
1324 | |
1325 | eoc_transform_get_affine (transform, &affine); |
1326 | cairo_matrix_multiply (&matrix, &affine, &matrix); |
1327 | |
1328 | switch (eoc_transform_get_transform_type (transform)) { |
1329 | case EOC_TRANSFORM_ROT_90: |
1330 | case EOC_TRANSFORM_FLIP_HORIZONTAL: |
1331 | image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf); |
1332 | break; |
1333 | case EOC_TRANSFORM_ROT_270: |
1334 | case EOC_TRANSFORM_FLIP_VERTICAL: |
1335 | image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf); |
1336 | break; |
1337 | case EOC_TRANSFORM_ROT_180: |
1338 | case EOC_TRANSFORM_TRANSPOSE: |
1339 | case EOC_TRANSFORM_TRANSVERSE: |
1340 | image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf); |
1341 | image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf); |
1342 | break; |
1343 | case EOC_TRANSFORM_NONE: |
1344 | default: |
1345 | break; |
1346 | } |
1347 | cairo_matrix_init_translate (&translate, image_offset_x, image_offset_y); |
1348 | cairo_matrix_multiply (&matrix, &matrix, &translate); |
1349 | } |
1350 | /* Zoom factor for SVGs is already scaled, so scale back to application pixels. */ |
1351 | cairo_matrix_init_scale (&scale, priv->zoom / priv->scale, priv->zoom / priv->scale); |
1352 | cairo_matrix_multiply (&matrix, &matrix, &scale); |
1353 | cairo_matrix_init_translate (&translate, xofs, yofs); |
1354 | cairo_matrix_multiply (&matrix, &matrix, &translate); |
1355 | |
1356 | cairo_get_matrix (cr, &original); |
1357 | cairo_matrix_multiply (&matrix, &matrix, &original); |
1358 | cairo_set_matrix (cr, &matrix); |
1359 | |
1360 | rsvg_handle_render_cairo (eoc_image_get_svg (priv->image), cr); |
1361 | |
1362 | } else |
1363 | #endif /* HAVE_RSVG */ |
1364 | { |
1365 | cairo_filter_t interp_type; |
1366 | |
1367 | if(!DOUBLE_EQUAL(priv->zoom, 1.0)(fabs (priv->zoom - 1.0) < 1e-6) && priv->force_unfiltered) |
1368 | { |
1369 | interp_type = CAIRO_FILTER_NEAREST; |
1370 | _set_hq_redraw_timeout(view); |
1371 | } |
1372 | else |
1373 | { |
1374 | if (is_zoomed_in (view)) |
1375 | interp_type = priv->interp_type_in; |
1376 | else |
1377 | interp_type = priv->interp_type_out; |
1378 | |
1379 | _clear_hq_redraw_timeout (view); |
1380 | priv->force_unfiltered = TRUE(!(0)); |
1381 | } |
1382 | cairo_scale (cr, priv->zoom, priv->zoom); |
1383 | cairo_set_source_surface (cr, priv->surface, xofs/priv->zoom, yofs/priv->zoom); |
1384 | cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD); |
1385 | if (is_zoomed_in (view) || is_zoomed_out (view)) |
1386 | cairo_pattern_set_filter (cairo_get_source (cr), interp_type); |
1387 | |
1388 | cairo_paint (cr); |
1389 | } |
1390 | |
1391 | return TRUE(!(0)); |
1392 | } |
1393 | |
1394 | |
1395 | /*================================== |
1396 | |
1397 | image loading callbacks |
1398 | |
1399 | -----------------------------------*/ |
1400 | |
1401 | /* Use when the pixbuf in the view is changed, to keep a |
1402 | reference to it and create its cairo surface. */ |
1403 | static void |
1404 | update_pixbuf (EocScrollView *view, GdkPixbuf *pixbuf) |
1405 | { |
1406 | EocScrollViewPrivate *priv; |
1407 | |
1408 | priv = view->priv; |
1409 | |
1410 | if (priv->pixbuf != NULL((void*)0)) { |
1411 | g_object_unref (priv->pixbuf); |
1412 | priv->pixbuf = NULL((void*)0); |
1413 | } |
1414 | |
1415 | priv->pixbuf = pixbuf; |
1416 | |
1417 | if (priv->surface) { |
1418 | cairo_surface_destroy (priv->surface); |
1419 | } |
1420 | priv->surface = create_surface_from_pixbuf (view, priv->pixbuf); |
1421 | } |
1422 | |
1423 | static void |
1424 | image_changed_cb (EocImage *img, gpointer data) |
1425 | { |
1426 | EocScrollViewPrivate *priv; |
1427 | |
1428 | priv = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ()))))))->priv; |
1429 | |
1430 | update_pixbuf (EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))), eoc_image_get_pixbuf (img)); |
1431 | |
1432 | set_zoom_fit (EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ()))))))); |
1433 | check_scrollbar_visibility (EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))), NULL((void*)0)); |
1434 | |
1435 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1436 | } |
1437 | |
1438 | /*=================================== |
1439 | public API |
1440 | ---------------------------------*/ |
1441 | |
1442 | void |
1443 | eoc_scroll_view_hide_cursor (EocScrollView *view) |
1444 | { |
1445 | eoc_scroll_view_set_cursor (view, EOC_SCROLL_VIEW_CURSOR_HIDDEN); |
1446 | } |
1447 | |
1448 | void |
1449 | eoc_scroll_view_show_cursor (EocScrollView *view) |
1450 | { |
1451 | eoc_scroll_view_set_cursor (view, EOC_SCROLL_VIEW_CURSOR_NORMAL); |
1452 | } |
1453 | |
1454 | /* general properties */ |
1455 | void |
1456 | eoc_scroll_view_set_zoom_upscale (EocScrollView *view, gboolean upscale) |
1457 | { |
1458 | EocScrollViewPrivate *priv; |
1459 | |
1460 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1461 | |
1462 | priv = view->priv; |
1463 | |
1464 | if (priv->upscale != upscale) { |
1465 | priv->upscale = upscale; |
1466 | |
1467 | if (priv->zoom_mode == ZOOM_MODE_FIT) { |
1468 | set_zoom_fit (view); |
1469 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1470 | } |
1471 | } |
1472 | } |
1473 | |
1474 | void |
1475 | eoc_scroll_view_set_antialiasing_in (EocScrollView *view, gboolean state) |
1476 | { |
1477 | EocScrollViewPrivate *priv; |
1478 | cairo_filter_t new_interp_type; |
1479 | |
1480 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1481 | |
1482 | priv = view->priv; |
1483 | |
1484 | new_interp_type = state ? CAIRO_FILTER_GOOD : CAIRO_FILTER_NEAREST; |
1485 | |
1486 | if (priv->interp_type_in != new_interp_type) { |
1487 | priv->interp_type_in = new_interp_type; |
1488 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1489 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "antialiasing-in"); |
1490 | } |
1491 | } |
1492 | |
1493 | void |
1494 | eoc_scroll_view_set_antialiasing_out (EocScrollView *view, gboolean state) |
1495 | { |
1496 | EocScrollViewPrivate *priv; |
1497 | cairo_filter_t new_interp_type; |
1498 | |
1499 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1500 | |
1501 | priv = view->priv; |
1502 | |
1503 | new_interp_type = state ? CAIRO_FILTER_GOOD : CAIRO_FILTER_NEAREST; |
1504 | |
1505 | if (priv->interp_type_out != new_interp_type) { |
1506 | priv->interp_type_out = new_interp_type; |
1507 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1508 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "antialiasing-out"); |
1509 | |
1510 | } |
1511 | } |
1512 | |
1513 | static void |
1514 | _transp_background_changed (EocScrollView *view) |
1515 | { |
1516 | EocScrollViewPrivate *priv = view->priv; |
1517 | |
1518 | if (priv->pixbuf != NULL((void*)0) && gdk_pixbuf_get_has_alpha (priv->pixbuf)) { |
1519 | if (priv->background_surface) { |
1520 | cairo_surface_destroy (priv->background_surface); |
1521 | /* Will be recreated if needed during redraw */ |
1522 | priv->background_surface = NULL((void*)0); |
1523 | } |
1524 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1525 | } |
1526 | |
1527 | } |
1528 | |
1529 | void |
1530 | eoc_scroll_view_set_transparency_color (EocScrollView *view, CdkRGBA *color) |
1531 | { |
1532 | EocScrollViewPrivate *priv; |
1533 | |
1534 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1535 | |
1536 | priv = view->priv; |
1537 | |
1538 | if (!_eoc_cdk_rgba_equal0 (&priv->transp_color, color)) { |
1539 | priv->transp_color = *color; |
1540 | if (priv->transp_style == EOC_TRANSP_COLOR) |
1541 | _transp_background_changed (view); |
1542 | |
1543 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "transparency-color"); |
1544 | } |
1545 | } |
1546 | |
1547 | void |
1548 | eoc_scroll_view_set_transparency (EocScrollView *view, |
1549 | EocTransparencyStyle style) |
1550 | { |
1551 | EocScrollViewPrivate *priv; |
1552 | |
1553 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1554 | |
1555 | priv = view->priv; |
1556 | |
1557 | if (priv->transp_style != style) { |
1558 | priv->transp_style = style; |
1559 | _transp_background_changed (view); |
1560 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "transparency-style"); |
1561 | } |
1562 | } |
1563 | |
1564 | /* zoom api */ |
1565 | |
1566 | static double preferred_zoom_levels[] = { |
1567 | 1.0 / 100, 1.0 / 50, 1.0 / 20, |
1568 | 1.0 / 10.0, 1.0 / 5.0, 1.0 / 3.0, 1.0 / 2.0, 1.0 / 1.5, |
1569 | 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, |
1570 | 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0 |
1571 | }; |
1572 | static const gint n_zoom_levels = (sizeof (preferred_zoom_levels) / sizeof (double)); |
1573 | |
1574 | void |
1575 | eoc_scroll_view_zoom_in (EocScrollView *view, gboolean smooth) |
1576 | { |
1577 | EocScrollViewPrivate *priv; |
1578 | double zoom; |
1579 | |
1580 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1581 | |
1582 | priv = view->priv; |
1583 | |
1584 | if (smooth) { |
1585 | zoom = priv->zoom * priv->zoom_multiplier; |
1586 | } |
1587 | else { |
1588 | int i; |
1589 | int index = -1; |
1590 | |
1591 | for (i = 0; i < n_zoom_levels; i++) { |
1592 | if (preferred_zoom_levels [i] - priv->zoom |
1593 | > DOUBLE_EQUAL_MAX_DIFF1e-6) { |
1594 | index = i; |
1595 | break; |
1596 | } |
1597 | } |
1598 | |
1599 | if (index == -1) { |
1600 | zoom = priv->zoom; |
1601 | } |
1602 | else { |
1603 | zoom = preferred_zoom_levels [i]; |
1604 | } |
1605 | } |
1606 | set_zoom (view, zoom, FALSE(0), 0, 0); |
1607 | |
1608 | } |
1609 | |
1610 | void |
1611 | eoc_scroll_view_zoom_out (EocScrollView *view, gboolean smooth) |
1612 | { |
1613 | EocScrollViewPrivate *priv; |
1614 | double zoom; |
1615 | |
1616 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1617 | |
1618 | priv = view->priv; |
1619 | |
1620 | if (smooth) { |
1621 | zoom = priv->zoom / priv->zoom_multiplier; |
1622 | } |
1623 | else { |
1624 | int i; |
1625 | int index = -1; |
1626 | |
1627 | for (i = n_zoom_levels - 1; i >= 0; i--) { |
1628 | if (priv->zoom - preferred_zoom_levels [i] |
1629 | > DOUBLE_EQUAL_MAX_DIFF1e-6) { |
1630 | index = i; |
1631 | break; |
1632 | } |
1633 | } |
1634 | if (index == -1) { |
1635 | zoom = priv->zoom; |
1636 | } |
1637 | else { |
1638 | zoom = preferred_zoom_levels [i]; |
1639 | } |
1640 | } |
1641 | set_zoom (view, zoom, FALSE(0), 0, 0); |
1642 | } |
1643 | |
1644 | void |
1645 | eoc_scroll_view_zoom_fit (EocScrollView *view) |
1646 | { |
1647 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1648 | |
1649 | set_zoom_fit (view); |
1650 | check_scrollbar_visibility (view, NULL((void*)0)); |
1651 | ctk_widget_queue_draw (CTK_WIDGET (view->priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->priv->display)), ((ctk_widget_get_type ()))) )))); |
1652 | } |
1653 | |
1654 | void |
1655 | eoc_scroll_view_set_zoom (EocScrollView *view, double zoom) |
1656 | { |
1657 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1658 | |
1659 | set_zoom (view, zoom, FALSE(0), 0, 0); |
1660 | } |
1661 | |
1662 | double |
1663 | eoc_scroll_view_get_zoom (EocScrollView *view) |
1664 | { |
1665 | g_return_val_if_fail (EOC_IS_SCROLL_VIEW (view), 0.0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return (0.0); } } while (0); |
1666 | |
1667 | return view->priv->zoom; |
1668 | } |
1669 | |
1670 | gboolean |
1671 | eoc_scroll_view_get_zoom_is_min (EocScrollView *view) |
1672 | { |
1673 | g_return_val_if_fail (EOC_IS_SCROLL_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return ((0)); } } while (0); |
1674 | |
1675 | set_minimum_zoom_factor (view); |
1676 | |
1677 | return DOUBLE_EQUAL (view->priv->zoom, MIN_ZOOM_FACTOR)(fabs (view->priv->zoom - 0.02) < 1e-6) || |
1678 | DOUBLE_EQUAL (view->priv->zoom, view->priv->min_zoom)(fabs (view->priv->zoom - view->priv->min_zoom) < 1e-6); |
1679 | } |
1680 | |
1681 | gboolean |
1682 | eoc_scroll_view_get_zoom_is_max (EocScrollView *view) |
1683 | { |
1684 | g_return_val_if_fail (EOC_IS_SCROLL_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return ((0)); } } while (0); |
1685 | |
1686 | return DOUBLE_EQUAL (view->priv->zoom, MAX_ZOOM_FACTOR)(fabs (view->priv->zoom - 20) < 1e-6); |
1687 | } |
1688 | |
1689 | static void |
1690 | display_next_frame_cb (EocImage *image, |
1691 | gint delay G_GNUC_UNUSED__attribute__ ((__unused__)), |
1692 | gpointer data) |
1693 | { |
1694 | EocScrollViewPrivate *priv; |
1695 | EocScrollView *view; |
1696 | |
1697 | if (!EOC_IS_SCROLL_VIEW (data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (data)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) |
1698 | return; |
1699 | |
1700 | view = EOC_SCROLL_VIEW (data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((eoc_scroll_view_get_type ())))))); |
1701 | priv = view->priv; |
1702 | |
1703 | update_pixbuf (view, eoc_image_get_pixbuf (image)); |
1704 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1705 | } |
1706 | |
1707 | void |
1708 | eoc_scroll_view_set_image (EocScrollView *view, EocImage *image) |
1709 | { |
1710 | EocScrollViewPrivate *priv; |
1711 | |
1712 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
1713 | |
1714 | priv = view->priv; |
1715 | |
1716 | if (priv->image == image) { |
1717 | return; |
1718 | } |
1719 | |
1720 | if (priv->image != NULL((void*)0)) { |
1721 | free_image_resources (view); |
1722 | } |
1723 | g_assert (priv->image == NULL)do { if (priv->image == ((void*)0)) ; else g_assertion_message_expr ("EOC", "eoc-scroll-view.c", 1723, ((const char*) (__func__) ), "priv->image == NULL"); } while (0); |
1724 | g_assert (priv->pixbuf == NULL)do { if (priv->pixbuf == ((void*)0)) ; else g_assertion_message_expr ("EOC", "eoc-scroll-view.c", 1724, ((const char*) (__func__) ), "priv->pixbuf == NULL"); } while (0); |
1725 | |
1726 | if (image != NULL((void*)0)) { |
1727 | eoc_image_data_ref (image); |
1728 | |
1729 | if (priv->pixbuf == NULL((void*)0)) { |
1730 | update_pixbuf (view, eoc_image_get_pixbuf (image)); |
1731 | set_zoom_fit (view); |
1732 | check_scrollbar_visibility (view, NULL((void*)0)); |
1733 | ctk_widget_queue_draw (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1734 | |
1735 | } |
1736 | |
1737 | priv->image_changed_id = g_signal_connect (image, "changed",g_signal_connect_data ((image), ("changed"), ((GCallback) image_changed_cb ), (view), ((void*)0), (GConnectFlags) 0) |
1738 | (GCallback) image_changed_cb, view)g_signal_connect_data ((image), ("changed"), ((GCallback) image_changed_cb ), (view), ((void*)0), (GConnectFlags) 0); |
1739 | if (eoc_image_is_animation (image) == TRUE(!(0)) ) { |
1740 | eoc_image_start_animation (image); |
1741 | priv->frame_changed_id = g_signal_connect (image, "next-frame",g_signal_connect_data ((image), ("next-frame"), ((GCallback) display_next_frame_cb ), (view), ((void*)0), (GConnectFlags) 0) |
1742 | (GCallback) display_next_frame_cb, view)g_signal_connect_data ((image), ("next-frame"), ((GCallback) display_next_frame_cb ), (view), ((void*)0), (GConnectFlags) 0); |
1743 | } |
1744 | } |
1745 | |
1746 | priv->image = image; |
1747 | |
1748 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "image"); |
1749 | } |
1750 | |
1751 | /** |
1752 | * eoc_scroll_view_get_image: |
1753 | * @view: An #EocScrollView. |
1754 | * |
1755 | * Gets the the currently displayed #EocImage. |
1756 | * |
1757 | * Returns: (transfer full): An #EocImage. |
1758 | **/ |
1759 | EocImage* |
1760 | eoc_scroll_view_get_image (EocScrollView *view) |
1761 | { |
1762 | EocImage *img; |
1763 | |
1764 | g_return_val_if_fail (EOC_IS_SCROLL_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return (((void*)0)); } } while (0); |
1765 | |
1766 | img = view->priv->image; |
1767 | |
1768 | if (img != NULL((void*)0)) |
1769 | g_object_ref (img)((__typeof__ (img)) (g_object_ref) (img)); |
1770 | |
1771 | return img; |
1772 | } |
1773 | |
1774 | gboolean |
1775 | eoc_scroll_view_scrollbars_visible (EocScrollView *view) |
1776 | { |
1777 | if (!ctk_widget_get_visible (CTK_WIDGET (view->priv->hbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->priv->hbar)), ((ctk_widget_get_type ()))))))) && |
1778 | !ctk_widget_get_visible (CTK_WIDGET (view->priv->vbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->priv->vbar)), ((ctk_widget_get_type ())))))))) |
1779 | return FALSE(0); |
1780 | |
1781 | return TRUE(!(0)); |
1782 | } |
1783 | |
1784 | /*=================================== |
1785 | object creation/freeing |
1786 | ---------------------------------*/ |
1787 | |
1788 | static gboolean |
1789 | sv_string_to_rgba_mapping (GValue *value, |
1790 | GVariant *variant, |
1791 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
1792 | { |
1793 | CdkRGBA color; |
1794 | |
1795 | g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING), FALSE)do { if ((g_variant_is_of_type (variant, ((const GVariantType *) "s")))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__)), "g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)" ); return ((0)); } } while (0); |
1796 | |
1797 | if (cdk_rgba_parse (&color, g_variant_get_string (variant, NULL((void*)0)))) { |
1798 | g_value_set_boxed (value, &color); |
1799 | return TRUE(!(0)); |
1800 | } |
1801 | |
1802 | return FALSE(0); |
1803 | } |
1804 | |
1805 | static GVariant* |
1806 | sv_rgba_to_string_mapping (const GValue *value, |
1807 | const GVariantType *expected_type, |
1808 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
1809 | { |
1810 | GVariant *variant = NULL((void*)0); |
1811 | CdkRGBA *color; |
1812 | gchar *hex_val; |
1813 | |
1814 | g_return_val_if_fail (G_VALUE_TYPE (value) == CDK_TYPE_RGBA, NULL)do { if (((((GValue*) (value))->g_type) == (cdk_rgba_get_type ()))) { } else { g_return_if_fail_warning ("EOC", ((const char *) (__func__)), "G_VALUE_TYPE (value) == CDK_TYPE_RGBA"); return (((void*)0)); } } while (0); |
1815 | g_return_val_if_fail (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING), NULL)do { if ((g_variant_type_equal (expected_type, ((const GVariantType *) "s")))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__)), "g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING)" ); return (((void*)0)); } } while (0); |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
1816 | |
1817 | color = g_value_get_boxed (value); |
1818 | hex_val = cdk_rgba_to_string(color); |
1819 | variant = g_variant_new_string (hex_val); |
1820 | g_free (hex_val); |
1821 | |
1822 | return variant; |
1823 | } |
1824 | |
1825 | static void |
1826 | eoc_scroll_view_init (EocScrollView *view) |
1827 | { |
1828 | GSettings *settings; |
1829 | EocScrollViewPrivate *priv; |
1830 | |
1831 | priv = view->priv = eoc_scroll_view_get_instance_private (view); |
1832 | settings = g_settings_new (EOC_CONF_VIEW"org.cafe.eoc"".view"); |
1833 | |
1834 | priv->zoom = 1.0; |
1835 | priv->min_zoom = MIN_ZOOM_FACTOR0.02; |
1836 | priv->zoom_mode = ZOOM_MODE_FIT; |
1837 | priv->upscale = FALSE(0); |
1838 | priv->interp_type_in = CAIRO_FILTER_GOOD; |
1839 | priv->interp_type_out = CAIRO_FILTER_GOOD; |
1840 | priv->scroll_wheel_zoom = FALSE(0); |
1841 | priv->zoom_multiplier = IMAGE_VIEW_ZOOM_MULTIPLIER1.05; |
1842 | priv->image = NULL((void*)0); |
1843 | priv->pixbuf = NULL((void*)0); |
1844 | priv->surface = NULL((void*)0); |
1845 | priv->transp_style = EOC_TRANSP_BACKGROUND; |
1846 | g_warn_if_fail (cdk_rgba_parse(&priv->transp_color, CHECK_BLACK))do { if (cdk_rgba_parse(&priv->transp_color, "#000000" )) ; else g_warn_message ("EOC", "eoc-scroll-view.c", 1846, ( (const char*) (__func__)), "cdk_rgba_parse(&priv->transp_color, CHECK_BLACK)" ); } while (0); |
1847 | priv->cursor = EOC_SCROLL_VIEW_CURSOR_NORMAL; |
1848 | priv->menu = NULL((void*)0); |
1849 | priv->background_color = NULL((void*)0); |
1850 | |
1851 | priv->hadj = CTK_ADJUSTMENT (ctk_adjustment_new (0, 100, 0, 10, 10, 100))((((CtkAdjustment*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_adjustment_new (0, 100, 0, 10, 10, 100))), ((ctk_adjustment_get_type ())))))); |
1852 | g_signal_connect (priv->hadj, "value_changed",g_signal_connect_data ((priv->hadj), ("value_changed"), (( (GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags ) 0) |
1853 | G_CALLBACK (adjustment_changed_cb),g_signal_connect_data ((priv->hadj), ("value_changed"), (( (GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags ) 0) |
1854 | view)g_signal_connect_data ((priv->hadj), ("value_changed"), (( (GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags ) 0); |
1855 | |
1856 | priv->hbar = ctk_scrollbar_new (CTK_ORIENTATION_HORIZONTAL, priv->hadj); |
1857 | priv->vadj = CTK_ADJUSTMENT (ctk_adjustment_new (0, 100, 0, 10, 10, 100))((((CtkAdjustment*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_adjustment_new (0, 100, 0, 10, 10, 100))), ((ctk_adjustment_get_type ())))))); |
1858 | g_signal_connect (priv->vadj, "value_changed",g_signal_connect_data ((priv->vadj), ("value_changed"), (( (GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags ) 0) |
1859 | G_CALLBACK (adjustment_changed_cb),g_signal_connect_data ((priv->vadj), ("value_changed"), (( (GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags ) 0) |
1860 | view)g_signal_connect_data ((priv->vadj), ("value_changed"), (( (GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags ) 0); |
1861 | |
1862 | priv->vbar = ctk_scrollbar_new (CTK_ORIENTATION_VERTICAL, priv->vadj); |
1863 | priv->display = g_object_new (CTK_TYPE_DRAWING_AREA(ctk_drawing_area_get_type ()), |
1864 | "can-focus", TRUE(!(0)), |
1865 | NULL((void*)0)); |
1866 | priv->scale = ctk_widget_get_scale_factor (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ()))))))); |
1867 | |
1868 | ctk_widget_add_events (CTK_WIDGET (priv->display)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->display)), ((ctk_widget_get_type ())))))), |
1869 | CDK_EXPOSURE_MASK |
1870 | | CDK_BUTTON_PRESS_MASK |
1871 | | CDK_BUTTON_RELEASE_MASK |
1872 | | CDK_POINTER_MOTION_MASK |
1873 | | CDK_POINTER_MOTION_HINT_MASK |
1874 | | CDK_SCROLL_MASK |
1875 | | CDK_KEY_PRESS_MASK); |
1876 | g_signal_connect (G_OBJECT (priv->display), "configure_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("configure_event"), (((GCallback) (display_size_change ))), (view), ((void*)0), (GConnectFlags) 0) |
1877 | G_CALLBACK (display_size_change), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("configure_event"), (((GCallback) (display_size_change ))), (view), ((void*)0), (GConnectFlags) 0); |
1878 | g_signal_connect (G_OBJECT (priv->display), "draw", G_CALLBACK (display_draw), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("draw"), (((GCallback) (display_draw))), (view ), ((void*)0), (GConnectFlags) 0); |
1879 | g_signal_connect (G_OBJECT (priv->display), "map_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("map_event"), (((GCallback) (display_map_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1880 | G_CALLBACK (display_map_event), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("map_event"), (((GCallback) (display_map_event ))), (view), ((void*)0), (GConnectFlags) 0); |
1881 | g_signal_connect (G_OBJECT (priv->display), "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) (eoc_scroll_view_button_press_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1882 | G_CALLBACK (eoc_scroll_view_button_press_event),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) (eoc_scroll_view_button_press_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1883 | view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) (eoc_scroll_view_button_press_event ))), (view), ((void*)0), (GConnectFlags) 0); |
1884 | g_signal_connect (G_OBJECT (priv->display), "motion_notify_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback) (eoc_scroll_view_motion_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1885 | G_CALLBACK (eoc_scroll_view_motion_event), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback) (eoc_scroll_view_motion_event ))), (view), ((void*)0), (GConnectFlags) 0); |
1886 | g_signal_connect (G_OBJECT (priv->display), "button_release_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("button_release_event"), (((GCallback) (eoc_scroll_view_button_release_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1887 | G_CALLBACK (eoc_scroll_view_button_release_event),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("button_release_event"), (((GCallback) (eoc_scroll_view_button_release_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1888 | view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("button_release_event"), (((GCallback) (eoc_scroll_view_button_release_event ))), (view), ((void*)0), (GConnectFlags) 0); |
1889 | g_signal_connect (G_OBJECT (priv->display), "scroll_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("scroll_event"), (((GCallback) (eoc_scroll_view_scroll_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1890 | G_CALLBACK (eoc_scroll_view_scroll_event), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("scroll_event"), (((GCallback) (eoc_scroll_view_scroll_event ))), (view), ((void*)0), (GConnectFlags) 0); |
1891 | g_signal_connect (G_OBJECT (priv->display), "focus_in_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("focus_in_event"), (((GCallback) (eoc_scroll_view_focus_in_event ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) |
1892 | G_CALLBACK (eoc_scroll_view_focus_in_event), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("focus_in_event"), (((GCallback) (eoc_scroll_view_focus_in_event ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
1893 | g_signal_connect (G_OBJECT (priv->display), "focus_out_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("focus_out_event"), (((GCallback) (eoc_scroll_view_focus_out_event ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) |
1894 | G_CALLBACK (eoc_scroll_view_focus_out_event), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("focus_out_event"), (((GCallback) (eoc_scroll_view_focus_out_event ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
1895 | |
1896 | g_signal_connect (G_OBJECT (view), "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) )))), ("key_press_event"), (((GCallback) (display_key_press_event ))), (view), ((void*)0), (GConnectFlags) 0) |
1897 | G_CALLBACK (display_key_press_event), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) )))), ("key_press_event"), (((GCallback) (display_key_press_event ))), (view), ((void*)0), (GConnectFlags) 0); |
1898 | |
1899 | ctk_drag_source_set (priv->display, CDK_BUTTON1_MASK, |
1900 | target_table, G_N_ELEMENTS (target_table)(sizeof (target_table) / sizeof ((target_table)[0])), |
1901 | CDK_ACTION_COPY | CDK_ACTION_MOVE | |
1902 | CDK_ACTION_LINK | CDK_ACTION_ASK); |
1903 | g_signal_connect (G_OBJECT (priv->display), "drag-data-get",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("drag-data-get"), (((GCallback) (view_on_drag_data_get_cb ))), (view), ((void*)0), (GConnectFlags) 0) |
1904 | G_CALLBACK (view_on_drag_data_get_cb), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("drag-data-get"), (((GCallback) (view_on_drag_data_get_cb ))), (view), ((void*)0), (GConnectFlags) 0); |
1905 | g_signal_connect (G_OBJECT (priv->display), "drag-begin",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("drag-begin"), (((GCallback) (view_on_drag_begin_cb ))), (view), ((void*)0), (GConnectFlags) 0) |
1906 | G_CALLBACK (view_on_drag_begin_cb), view)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->display)), (((GType) ((20) << (2))))))))), ("drag-begin"), (((GCallback) (view_on_drag_begin_cb ))), (view), ((void*)0), (GConnectFlags) 0); |
1907 | |
1908 | ctk_grid_attach (CTK_GRID (view)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_grid_get_type ())))))), priv->display, |
1909 | 0, 0, 1, 1); |
1910 | ctk_widget_set_hexpand (priv->display, TRUE(!(0))); |
1911 | ctk_widget_set_vexpand (priv->display, TRUE(!(0))); |
1912 | ctk_grid_attach (CTK_GRID (view)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_grid_get_type ())))))), priv->hbar, |
1913 | 0, 1, 1, 1); |
1914 | ctk_widget_set_hexpand (priv->hbar, TRUE(!(0))); |
1915 | ctk_grid_attach (CTK_GRID (view)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_grid_get_type ())))))), priv->vbar, |
1916 | 1, 0, 1, 1); |
1917 | ctk_widget_set_vexpand (priv->vbar, TRUE(!(0))); |
1918 | |
1919 | g_settings_bind (settings, EOC_CONF_VIEW_USE_BG_COLOR"use-background-color", view, |
1920 | "use-background-color", G_SETTINGS_BIND_DEFAULT); |
1921 | g_settings_bind_with_mapping (settings, EOC_CONF_VIEW_BACKGROUND_COLOR"background-color", |
1922 | view, "background-color", |
1923 | G_SETTINGS_BIND_DEFAULT, |
1924 | sv_string_to_rgba_mapping, |
1925 | sv_rgba_to_string_mapping, NULL((void*)0), NULL((void*)0)); |
1926 | g_settings_bind (settings, EOC_CONF_VIEW_EXTRAPOLATE"extrapolate", view, |
1927 | "antialiasing-in", G_SETTINGS_BIND_GET); |
1928 | g_settings_bind (settings, EOC_CONF_VIEW_INTERPOLATE"interpolate", view, |
1929 | "antialiasing-out", G_SETTINGS_BIND_GET); |
1930 | g_settings_bind_with_mapping (settings, EOC_CONF_VIEW_TRANS_COLOR"trans-color", |
1931 | view, "transparency-color", |
1932 | G_SETTINGS_BIND_GET, |
1933 | sv_string_to_rgba_mapping, |
1934 | sv_rgba_to_string_mapping, NULL((void*)0), NULL((void*)0)); |
1935 | g_settings_bind (settings, EOC_CONF_VIEW_TRANSPARENCY"transparency", view, |
1936 | "transparency-style", G_SETTINGS_BIND_GET); |
1937 | |
1938 | g_object_unref (settings); |
1939 | |
1940 | priv->override_bg_color = NULL((void*)0); |
1941 | priv->background_surface = NULL((void*)0); |
1942 | } |
1943 | |
1944 | static void |
1945 | eoc_scroll_view_dispose (GObject *object) |
1946 | { |
1947 | EocScrollView *view; |
1948 | EocScrollViewPrivate *priv; |
1949 | |
1950 | g_return_if_fail (EOC_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((object)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (object)"); return; } } while (0); |
1951 | |
1952 | view = EOC_SCROLL_VIEW (object)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((eoc_scroll_view_get_type ())))))); |
1953 | priv = view->priv; |
1954 | |
1955 | _clear_hq_redraw_timeout (view); |
1956 | |
1957 | if (priv->idle_id != 0) { |
1958 | g_source_remove (priv->idle_id); |
1959 | priv->idle_id = 0; |
1960 | } |
1961 | |
1962 | if (priv->background_color != NULL((void*)0)) { |
1963 | cdk_rgba_free (priv->background_color); |
1964 | priv->background_color = NULL((void*)0); |
1965 | } |
1966 | |
1967 | if (priv->override_bg_color != NULL((void*)0)) { |
1968 | cdk_rgba_free (priv->override_bg_color); |
1969 | priv->override_bg_color = NULL((void*)0); |
1970 | } |
1971 | |
1972 | if (priv->background_surface != NULL((void*)0)) { |
1973 | cairo_surface_destroy (priv->background_surface); |
1974 | priv->background_surface = NULL((void*)0); |
1975 | } |
1976 | |
1977 | free_image_resources (view); |
1978 | |
1979 | G_OBJECT_CLASS (eoc_scroll_view_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((eoc_scroll_view_parent_class)), (((GType) ((20) << (2))))))))->dispose (object); |
1980 | } |
1981 | |
1982 | static void |
1983 | eoc_scroll_view_get_property (GObject *object, guint property_id, |
1984 | GValue *value, GParamSpec *pspec) |
1985 | { |
1986 | EocScrollView *view; |
1987 | EocScrollViewPrivate *priv; |
1988 | |
1989 | g_return_if_fail (EOC_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((object)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (object)"); return; } } while (0); |
1990 | |
1991 | view = EOC_SCROLL_VIEW (object)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((eoc_scroll_view_get_type ())))))); |
1992 | priv = view->priv; |
1993 | |
1994 | switch (property_id) { |
1995 | case PROP_ANTIALIAS_IN: |
1996 | { |
1997 | gboolean filter = (priv->interp_type_in != CAIRO_FILTER_NEAREST); |
1998 | g_value_set_boolean (value, filter); |
1999 | break; |
2000 | } |
2001 | case PROP_ANTIALIAS_OUT: |
2002 | { |
2003 | gboolean filter = (priv->interp_type_out != CAIRO_FILTER_NEAREST); |
2004 | g_value_set_boolean (value, filter); |
2005 | break; |
2006 | } |
2007 | case PROP_USE_BG_COLOR: |
2008 | g_value_set_boolean (value, priv->use_bg_color); |
2009 | break; |
2010 | case PROP_BACKGROUND_COLOR: |
2011 | //FIXME: This doesn't really handle the NULL color. |
2012 | g_value_set_boxed (value, priv->background_color); |
2013 | break; |
2014 | case PROP_SCROLLWHEEL_ZOOM: |
2015 | g_value_set_boolean (value, priv->scroll_wheel_zoom); |
2016 | break; |
2017 | case PROP_TRANSPARENCY_STYLE: |
2018 | g_value_set_enum (value, priv->transp_style); |
2019 | break; |
2020 | case PROP_ZOOM_MULTIPLIER: |
2021 | g_value_set_double (value, priv->zoom_multiplier); |
2022 | break; |
2023 | case PROP_IMAGE: |
2024 | g_value_set_object (value, priv->image); |
2025 | break; |
2026 | default: |
2027 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "eoc-scroll-view.c", 2027, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
2028 | } |
2029 | } |
2030 | |
2031 | static void |
2032 | eoc_scroll_view_set_property (GObject *object, guint property_id, |
2033 | const GValue *value, GParamSpec *pspec) |
2034 | { |
2035 | EocScrollView *view; |
2036 | |
2037 | g_return_if_fail (EOC_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((object)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (object)"); return; } } while (0); |
2038 | |
2039 | view = EOC_SCROLL_VIEW (object)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((eoc_scroll_view_get_type ())))))); |
2040 | |
2041 | switch (property_id) { |
2042 | case PROP_ANTIALIAS_IN: |
2043 | eoc_scroll_view_set_antialiasing_in (view, g_value_get_boolean (value)); |
2044 | break; |
2045 | case PROP_ANTIALIAS_OUT: |
2046 | eoc_scroll_view_set_antialiasing_out (view, g_value_get_boolean (value)); |
2047 | break; |
2048 | case PROP_USE_BG_COLOR: |
2049 | eoc_scroll_view_set_use_bg_color (view, g_value_get_boolean (value)); |
2050 | break; |
2051 | case PROP_BACKGROUND_COLOR: |
2052 | { |
2053 | const CdkRGBA *color = g_value_get_boxed (value); |
2054 | eoc_scroll_view_set_background_color (view, color); |
2055 | break; |
2056 | } |
2057 | case PROP_SCROLLWHEEL_ZOOM: |
2058 | eoc_scroll_view_set_scroll_wheel_zoom (view, g_value_get_boolean (value)); |
2059 | break; |
2060 | case PROP_TRANSP_COLOR: |
2061 | eoc_scroll_view_set_transparency_color (view, g_value_get_boxed (value)); |
2062 | break; |
2063 | case PROP_TRANSPARENCY_STYLE: |
2064 | eoc_scroll_view_set_transparency (view, g_value_get_enum (value)); |
2065 | break; |
2066 | case PROP_ZOOM_MULTIPLIER: |
2067 | eoc_scroll_view_set_zoom_multiplier (view, g_value_get_double (value)); |
2068 | break; |
2069 | case PROP_IMAGE: |
2070 | eoc_scroll_view_set_image (view, g_value_get_object (value)); |
2071 | break; |
2072 | default: |
2073 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "eoc-scroll-view.c", 2073, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
2074 | } |
2075 | } |
2076 | |
2077 | |
2078 | static void |
2079 | eoc_scroll_view_class_init (EocScrollViewClass *klass) |
2080 | { |
2081 | GObjectClass *gobject_class; |
2082 | CtkWidgetClass *widget_class; |
2083 | |
2084 | gobject_class = (GObjectClass*) klass; |
2085 | widget_class = (CtkWidgetClass*) klass; |
2086 | |
2087 | gobject_class->dispose = eoc_scroll_view_dispose; |
2088 | gobject_class->set_property = eoc_scroll_view_set_property; |
2089 | gobject_class->get_property = eoc_scroll_view_get_property; |
2090 | |
2091 | g_object_class_install_property ( |
2092 | gobject_class, PROP_ANTIALIAS_IN, |
2093 | g_param_spec_boolean ("antialiasing-in", NULL((void*)0), NULL((void*)0), TRUE(!(0)), |
2094 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2095 | |
2096 | g_object_class_install_property ( |
2097 | gobject_class, PROP_ANTIALIAS_OUT, |
2098 | g_param_spec_boolean ("antialiasing-out", NULL((void*)0), NULL((void*)0), TRUE(!(0)), |
2099 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2100 | |
2101 | /** |
2102 | * EocScrollView:background-color: |
2103 | * |
2104 | * This is the default background color used for painting the background |
2105 | * of the image view. If set to %NULL the color is determined by the |
2106 | * active CTK theme. |
2107 | */ |
2108 | g_object_class_install_property ( |
2109 | gobject_class, PROP_BACKGROUND_COLOR, |
2110 | g_param_spec_boxed ("background-color", NULL((void*)0), NULL((void*)0), |
2111 | CDK_TYPE_RGBA(cdk_rgba_get_type ()), |
2112 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2113 | |
2114 | g_object_class_install_property ( |
2115 | gobject_class, PROP_USE_BG_COLOR, |
2116 | g_param_spec_boolean ("use-background-color", NULL((void*)0), NULL((void*)0), FALSE(0), |
2117 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2118 | |
2119 | /** |
2120 | * EocScrollView:zoom-multiplier: |
2121 | * |
2122 | * The current zoom factor is multiplied with this value + 1.0 when |
2123 | * scrolling with the scrollwheel to determine the next zoom factor. |
2124 | */ |
2125 | g_object_class_install_property ( |
2126 | gobject_class, PROP_ZOOM_MULTIPLIER, |
2127 | g_param_spec_double ("zoom-multiplier", NULL((void*)0), NULL((void*)0), |
2128 | -G_MAXDOUBLE1.7976931348623157e+308, G_MAXDOUBLE1.7976931348623157e+308 -1.0, 0.05, |
2129 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2130 | |
2131 | /** |
2132 | * EocScrollView:scrollwheel-zoom: |
2133 | * |
2134 | * If %TRUE the scrollwheel will zoom the view, otherwise it will be |
2135 | * used for scrolling a zoomed image. |
2136 | */ |
2137 | g_object_class_install_property ( |
2138 | gobject_class, PROP_SCROLLWHEEL_ZOOM, |
2139 | g_param_spec_boolean ("scrollwheel-zoom", NULL((void*)0), NULL((void*)0), TRUE(!(0)), |
2140 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2141 | |
2142 | /** |
2143 | * EocScrollView:image: |
2144 | * |
2145 | * This is the currently display #EocImage. |
2146 | */ |
2147 | g_object_class_install_property ( |
2148 | gobject_class, PROP_IMAGE, |
2149 | g_param_spec_object ("image", NULL((void*)0), NULL((void*)0), EOC_TYPE_IMAGE(eoc_image_get_type ()), |
2150 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2151 | |
2152 | /** |
2153 | * EocScrollView:transparency-color: |
2154 | * |
2155 | * This is the color used to fill the transparent parts of an image |
2156 | * if :transparency-style is set to use a custom color. |
2157 | */ |
2158 | g_object_class_install_property ( |
2159 | gobject_class, PROP_TRANSP_COLOR, |
2160 | g_param_spec_boxed ("transparency-color", NULL((void*)0), NULL((void*)0), |
2161 | CDK_TYPE_RGBA(cdk_rgba_get_type ()), |
2162 | G_PARAM_WRITABLE | G_PARAM_STATIC_NAME)); |
2163 | |
2164 | /** |
2165 | * EocScrollView:transparency-style: |
2166 | * |
2167 | * Determines how to fill the shown image's transparent areas. |
2168 | */ |
2169 | g_object_class_install_property ( |
2170 | gobject_class, PROP_TRANSPARENCY_STYLE, |
2171 | g_param_spec_enum ("transparency-style", NULL((void*)0), NULL((void*)0), |
2172 | EOC_TYPE_TRANSPARENCY_STYLE(eoc_transparency_style_get_type()), |
2173 | EOC_TRANSP_CHECKED, |
2174 | G_PARAM_READWRITE | G_PARAM_STATIC_NAME)); |
2175 | |
2176 | view_signals [SIGNAL_ZOOM_CHANGED] = |
2177 | g_signal_new ("zoom_changed", |
2178 | EOC_TYPE_SCROLL_VIEW(eoc_scroll_view_get_type ()), |
2179 | G_SIGNAL_RUN_LAST, |
2180 | G_STRUCT_OFFSET (EocScrollViewClass, zoom_changed)((glong) __builtin_offsetof(EocScrollViewClass, zoom_changed) ), |
2181 | NULL((void*)0), NULL((void*)0), |
2182 | eoc_marshal_VOID__DOUBLEg_cclosure_marshal_VOID__DOUBLE, |
2183 | G_TYPE_NONE((GType) ((1) << (2))), 1, |
2184 | G_TYPE_DOUBLE((GType) ((15) << (2)))); |
2185 | |
2186 | widget_class->size_allocate = eoc_scroll_view_size_allocate; |
2187 | } |
2188 | |
2189 | static void |
2190 | view_on_drag_begin_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
2191 | CdkDragContext *context, |
2192 | gpointer user_data) |
2193 | { |
2194 | EocScrollView *view; |
2195 | EocImage *image; |
2196 | GdkPixbuf *thumbnail; |
2197 | gint width, height; |
2198 | |
2199 | view = EOC_SCROLL_VIEW (user_data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((eoc_scroll_view_get_type ())))))); |
2200 | image = view->priv->image; |
2201 | |
2202 | thumbnail = eoc_image_get_thumbnail (image); |
2203 | |
2204 | if (thumbnail) { |
2205 | width = gdk_pixbuf_get_width (thumbnail) / view->priv->scale; |
2206 | height = gdk_pixbuf_get_height (thumbnail) / view->priv->scale; |
2207 | ctk_drag_set_icon_pixbuf (context, thumbnail, width/2, height/2); |
2208 | g_object_unref (thumbnail); |
2209 | } |
2210 | } |
2211 | |
2212 | static void |
2213 | view_on_drag_data_get_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
2214 | CdkDragContext *drag_context G_GNUC_UNUSED__attribute__ ((__unused__)), |
2215 | CtkSelectionData *data, |
2216 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
2217 | guint time G_GNUC_UNUSED__attribute__ ((__unused__)), |
2218 | gpointer user_data) |
2219 | { |
2220 | EocScrollView *view; |
2221 | EocImage *image; |
2222 | gchar *uris[2]; |
2223 | GFile *file; |
2224 | |
2225 | view = EOC_SCROLL_VIEW (user_data)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((eoc_scroll_view_get_type ())))))); |
2226 | |
2227 | image = view->priv->image; |
2228 | |
2229 | file = eoc_image_get_file (image); |
2230 | uris[0] = g_file_get_uri (file); |
2231 | uris[1] = NULL((void*)0); |
2232 | |
2233 | ctk_selection_data_set_uris (data, uris); |
2234 | |
2235 | g_free (uris[0]); |
2236 | g_object_unref (file); |
2237 | } |
2238 | |
2239 | CtkWidget* |
2240 | eoc_scroll_view_new (void) |
2241 | { |
2242 | CtkWidget *widget; |
2243 | |
2244 | widget = g_object_new (EOC_TYPE_SCROLL_VIEW(eoc_scroll_view_get_type ()), |
2245 | "can-focus", TRUE(!(0)), |
2246 | "row-homogeneous", FALSE(0), |
2247 | "column-homogeneous", FALSE(0), |
2248 | NULL((void*)0)); |
2249 | |
2250 | |
2251 | return widget; |
2252 | } |
2253 | |
2254 | static gboolean |
2255 | view_on_button_press_event_cb (CtkWidget *widget, |
2256 | CdkEventButton *event, |
2257 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
2258 | { |
2259 | EocScrollView *view = EOC_SCROLL_VIEW (widget)((((EocScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((eoc_scroll_view_get_type ())))))); |
2260 | |
2261 | /* Ignore double-clicks and triple-clicks */ |
2262 | if (event->button == 3 && event->type == CDK_BUTTON_PRESS) |
2263 | { |
2264 | ctk_menu_popup_at_pointer (CTK_MENU (view->priv->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->priv->menu)), ((ctk_menu_get_type ())))))), |
2265 | (const CdkEvent*) event); |
2266 | |
2267 | return TRUE(!(0)); |
2268 | } |
2269 | |
2270 | return FALSE(0); |
2271 | } |
2272 | |
2273 | void |
2274 | eoc_scroll_view_set_popup (EocScrollView *view, |
2275 | CtkMenu *menu) |
2276 | { |
2277 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
2278 | g_return_if_fail (view->priv->menu == NULL)do { if ((view->priv->menu == ((void*)0))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__)), "view->priv->menu == NULL" ); return; } } while (0); |
2279 | |
2280 | view->priv->menu = g_object_ref (CTK_WIDGET (menu))((__typeof__ (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menu)), ((ctk_widget_get_type ())))))))) (g_object_ref) (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menu)), ((ctk_widget_get_type ())))))))); |
2281 | |
2282 | ctk_menu_attach_to_widget (CTK_MENU (view->priv->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->priv->menu)), ((ctk_menu_get_type ())))))), |
2283 | CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), |
2284 | NULL((void*)0)); |
2285 | |
2286 | g_signal_connect (G_OBJECT (view), "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) )))), ("button_press_event"), (((GCallback) (view_on_button_press_event_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) |
2287 | G_CALLBACK (view_on_button_press_event_cb), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) )))), ("button_press_event"), (((GCallback) (view_on_button_press_event_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
2288 | } |
2289 | |
2290 | static gboolean |
2291 | _eoc_cdk_rgba_equal0 (const CdkRGBA *a, const CdkRGBA *b) |
2292 | { |
2293 | if (a == NULL((void*)0) || b == NULL((void*)0)) |
2294 | return (a == b); |
2295 | |
2296 | return cdk_rgba_equal (a, b); |
2297 | } |
2298 | |
2299 | static gboolean |
2300 | _eoc_replace_cdk_rgba (CdkRGBA **dest, const CdkRGBA *src) |
2301 | { |
2302 | CdkRGBA *old = *dest; |
2303 | |
2304 | if (_eoc_cdk_rgba_equal0 (old, src)) |
2305 | return FALSE(0); |
2306 | |
2307 | if (old != NULL((void*)0)) |
2308 | cdk_rgba_free (old); |
2309 | |
2310 | *dest = (src) ? cdk_rgba_copy (src) : NULL((void*)0); |
2311 | |
2312 | return TRUE(!(0)); |
2313 | } |
2314 | |
2315 | static void |
2316 | _eoc_scroll_view_update_bg_color (EocScrollView *view) |
2317 | { |
2318 | EocScrollViewPrivate *priv = view->priv; |
2319 | |
2320 | if (priv->transp_style == EOC_TRANSP_BACKGROUND |
2321 | && priv->background_surface != NULL((void*)0)) { |
2322 | /* Delete the SVG background to have it recreated with |
2323 | * the correct color during the next SVG redraw */ |
2324 | cairo_surface_destroy (priv->background_surface); |
2325 | priv->background_surface = NULL((void*)0); |
2326 | } |
2327 | |
2328 | ctk_widget_queue_draw (priv->display); |
2329 | } |
2330 | |
2331 | void |
2332 | eoc_scroll_view_set_background_color (EocScrollView *view, |
2333 | const CdkRGBA *color) |
2334 | { |
2335 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
2336 | |
2337 | if (_eoc_replace_cdk_rgba (&view->priv->background_color, color)) |
2338 | _eoc_scroll_view_update_bg_color (view); |
2339 | } |
2340 | |
2341 | void |
2342 | eoc_scroll_view_override_bg_color (EocScrollView *view, |
2343 | const CdkRGBA *color) |
2344 | { |
2345 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
2346 | |
2347 | if (_eoc_replace_cdk_rgba (&view->priv->override_bg_color, color)) |
2348 | _eoc_scroll_view_update_bg_color (view); |
2349 | } |
2350 | |
2351 | void |
2352 | eoc_scroll_view_set_use_bg_color (EocScrollView *view, gboolean use) |
2353 | { |
2354 | EocScrollViewPrivate *priv; |
2355 | |
2356 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
2357 | |
2358 | priv = view->priv; |
2359 | |
2360 | if (use != priv->use_bg_color) { |
2361 | priv->use_bg_color = use; |
2362 | |
2363 | _eoc_scroll_view_update_bg_color (view); |
2364 | |
2365 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "use-background-color"); |
2366 | } |
2367 | } |
2368 | |
2369 | void |
2370 | eoc_scroll_view_set_scroll_wheel_zoom (EocScrollView *view, |
2371 | gboolean scroll_wheel_zoom) |
2372 | { |
2373 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
2374 | |
2375 | if (view->priv->scroll_wheel_zoom != scroll_wheel_zoom) { |
2376 | view->priv->scroll_wheel_zoom = scroll_wheel_zoom; |
2377 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "scrollwheel-zoom"); |
2378 | } |
2379 | } |
2380 | |
2381 | void |
2382 | eoc_scroll_view_set_zoom_multiplier (EocScrollView *view, |
2383 | gdouble zoom_multiplier) |
2384 | { |
2385 | g_return_if_fail (EOC_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = ((eoc_scroll_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("EOC", ((const char*) (__func__ )), "EOC_IS_SCROLL_VIEW (view)"); return; } } while (0); |
2386 | |
2387 | view->priv->zoom_multiplier = 1.0 + zoom_multiplier; |
2388 | |
2389 | g_object_notify (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), "zoom-multiplier"); |
2390 | } |