[eog/wip/baedert/gtkimageview] Use GtkImageView
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog/wip/baedert/gtkimageview] Use GtkImageView
- Date: Thu, 28 Jan 2016 18:45:47 +0000 (UTC)
commit 8086174af0cedaeff321487e9469465962c309df
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 27 15:33:00 2016 +0100
Use GtkImageView
src/eog-scroll-view.c | 1521 +++++++------------------------------------------
src/eog-scroll-view.h | 21 +-
src/eog-window.c | 47 +-
3 files changed, 242 insertions(+), 1347 deletions(-)
---
diff --git a/src/eog-scroll-view.c b/src/eog-scroll-view.c
index 3e78261..d5ae0d3 100644
--- a/src/eog-scroll-view.c
+++ b/src/eog-scroll-view.c
@@ -37,10 +37,8 @@
#define CHECK_MEDIUM 8
#define CHECK_BLACK "#000000"
-#define CHECK_DARK "#555555"
#define CHECK_GRAY "#808080"
#define CHECK_LIGHT "#cccccc"
-#define CHECK_WHITE "#ffffff"
/* Time used for the realing animation of the overlaid buttons */
#define OVERLAY_REVEAL_ANIM_TIME (500U) /* ms */
@@ -90,7 +88,6 @@ enum {
PROP_TRANSP_COLOR,
PROP_TRANSPARENCY_STYLE,
PROP_USE_BG_COLOR,
- PROP_ZOOM_MODE,
PROP_ZOOM_MULTIPLIER
};
@@ -98,10 +95,6 @@ enum {
struct _EogScrollViewPrivate {
/* some widgets we rely on */
GtkWidget *display;
- GtkAdjustment *hadj;
- GtkAdjustment *vadj;
- GtkWidget *hbar;
- GtkWidget *vbar;
GtkWidget *menu;
/* actual image */
@@ -111,8 +104,6 @@ struct _EogScrollViewPrivate {
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
- /* zoom mode, either ZOOM_MODE_FIT or ZOOM_MODE_FREE */
- EogZoomMode zoom_mode;
/* whether to allow zoom > 1.0 on zoom fit */
gboolean upscale;
@@ -153,20 +144,18 @@ struct _EogScrollViewPrivate {
/* the type of the cursor we are currently showing */
EogScrollViewCursor cursor;
+ GtkWidget *scrolled_window;
+
gboolean use_bg_color;
GdkRGBA *background_color;
GdkRGBA *override_bg_color;
cairo_surface_t *background_surface;
- GtkGesture *pan_gesture;
- GtkGesture *zoom_gesture;
- GtkGesture *rotate_gesture;
gdouble initial_zoom;
EogRotationState rotate_state;
EogPanAction pan_action;
- GtkWidget *overlay;
GtkWidget *left_revealer;
GtkWidget *right_revealer;
GtkWidget *bottom_revealer;
@@ -183,38 +172,16 @@ static void view_on_drag_data_get_cb (GtkWidget *widget,
GdkDragContext*drag_context,
GtkSelectionData *data, guint info,
guint time, gpointer user_data);
-static void _set_zoom_mode_internal (EogScrollView *view, EogZoomMode mode);
-static gboolean eog_scroll_view_get_image_coords (EogScrollView *view, gint *x,
- gint *y, gint *width,
- gint *height);
static gboolean _eog_gdk_rgba_equal0 (const GdkRGBA *a, const GdkRGBA *b);
-G_DEFINE_TYPE_WITH_PRIVATE (EogScrollView, eog_scroll_view, GTK_TYPE_GRID)
+G_DEFINE_TYPE_WITH_PRIVATE (EogScrollView, eog_scroll_view, GTK_TYPE_OVERLAY)
/*===================================
widget size changing handler &
util functions
---------------------------------*/
-static cairo_surface_t *
-create_surface_from_pixbuf (EogScrollView *view, GdkPixbuf *pixbuf)
-{
- cairo_surface_t *surface;
- cairo_t *cr;
-
- surface = gdk_window_create_similar_surface (gtk_widget_get_window (view->priv->display),
- CAIRO_CONTENT_COLOR | CAIRO_CONTENT_ALPHA,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
- cr = cairo_create (surface);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- return surface;
-}
-
/* Disconnects from the EogImage and removes references to it */
static void
free_image_resources (EogScrollView *view)
@@ -238,148 +205,12 @@ free_image_resources (EogScrollView *view)
priv->image = NULL;
}
- if (priv->pixbuf != NULL) {
- g_object_unref (priv->pixbuf);
- priv->pixbuf = NULL;
- }
-
if (priv->surface != NULL) {
cairo_surface_destroy (priv->surface);
priv->surface = NULL;
}
}
-/* Computes the size in pixels of the scaled image */
-static void
-compute_scaled_size (EogScrollView *view, double zoom, int *width, int *height)
-{
- EogScrollViewPrivate *priv;
-
- priv = view->priv;
-
- if (priv->pixbuf) {
- *width = floor (gdk_pixbuf_get_width (priv->pixbuf) * zoom + 0.5);
- *height = floor (gdk_pixbuf_get_height (priv->pixbuf) * zoom + 0.5);
- } else
- *width = *height = 0;
-}
-
-/* Computes the offsets for the new zoom value so that they keep the image
- * centered on the view.
- */
-static void
-compute_center_zoom_offsets (EogScrollView *view,
- double old_zoom, double new_zoom,
- int width, int height,
- double zoom_x_anchor, double zoom_y_anchor,
- int *xofs, int *yofs)
-{
- EogScrollViewPrivate *priv;
- int old_scaled_width, old_scaled_height;
- int new_scaled_width, new_scaled_height;
- double view_cx, view_cy;
-
- priv = view->priv;
-
- compute_scaled_size (view, old_zoom,
- &old_scaled_width, &old_scaled_height);
-
- if (old_scaled_width < width)
- view_cx = (zoom_x_anchor * old_scaled_width) / old_zoom;
- else
- view_cx = (priv->xofs + zoom_x_anchor * width) / old_zoom;
-
- if (old_scaled_height < height)
- view_cy = (zoom_y_anchor * old_scaled_height) / old_zoom;
- else
- view_cy = (priv->yofs + zoom_y_anchor * height) / old_zoom;
-
- compute_scaled_size (view, new_zoom,
- &new_scaled_width, &new_scaled_height);
-
- if (new_scaled_width < width)
- *xofs = 0;
- else {
- *xofs = floor (view_cx * new_zoom - zoom_x_anchor * width + 0.5);
- if (*xofs < 0)
- *xofs = 0;
- }
-
- if (new_scaled_height < height)
- *yofs = 0;
- else {
- *yofs = floor (view_cy * new_zoom - zoom_y_anchor * height + 0.5);
- if (*yofs < 0)
- *yofs = 0;
- }
-}
-
-/* Sets the scrollbar values based on the current scrolling offset */
-static void
-update_scrollbar_values (EogScrollView *view)
-{
- EogScrollViewPrivate *priv;
- int scaled_width, scaled_height;
- gdouble page_size,page_increment,step_increment;
- gdouble lower, upper;
- GtkAllocation allocation;
-
- priv = view->priv;
-
- if (!gtk_widget_get_visible (GTK_WIDGET (priv->hbar))
- && !gtk_widget_get_visible (GTK_WIDGET (priv->vbar)))
- return;
-
- compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
- gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);
-
- if (gtk_widget_get_visible (GTK_WIDGET (priv->hbar))) {
- /* Set scroll increments */
- page_size = MIN (scaled_width, allocation.width);
- page_increment = allocation.width / 2;
- step_increment = SCROLL_STEP_SIZE;
-
- /* Set scroll bounds and new offsets */
- lower = 0;
- upper = scaled_width;
- priv->xofs = CLAMP (priv->xofs, 0, upper - page_size);
-
- g_signal_handlers_block_matched (
- priv->hadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
-
- gtk_adjustment_configure (priv->hadj, priv->xofs, lower,
- upper, step_increment,
- page_increment, page_size);
-
- g_signal_handlers_unblock_matched (
- priv->hadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
- }
-
- if (gtk_widget_get_visible (GTK_WIDGET (priv->vbar))) {
- page_size = MIN (scaled_height, allocation.height);
- page_increment = allocation.height / 2;
- step_increment = SCROLL_STEP_SIZE;
-
- lower = 0;
- upper = scaled_height;
- priv->yofs = CLAMP (priv->yofs, 0, upper - page_size);
-
- g_signal_handlers_block_matched (
- priv->vadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
-
- gtk_adjustment_configure (priv->vadj, priv->yofs, lower,
- upper, step_increment,
- page_increment, page_size);
-
- g_signal_handlers_unblock_matched (
- priv->vadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
- }
-}
-
static void
eog_scroll_view_set_cursor (EogScrollView *view, EogScrollViewCursor new_cursor)
{
@@ -414,74 +245,6 @@ eog_scroll_view_set_cursor (EogScrollView *view, EogScrollViewCursor new_cursor)
}
}
-/* Changes visibility of the scrollbars based on the zoom factor and the
- * specified allocation, or the current allocation if NULL is specified.
- */
-static void
-check_scrollbar_visibility (EogScrollView *view, GtkAllocation *alloc)
-{
- EogScrollViewPrivate *priv;
- int bar_height;
- int bar_width;
- int img_width;
- int img_height;
- GtkRequisition req;
- int width, height;
- gboolean hbar_visible, vbar_visible;
-
- priv = view->priv;
-
- if (alloc) {
- width = alloc->width;
- height = alloc->height;
- } else {
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (GTK_WIDGET (view), &allocation);
- width = allocation.width;
- height = allocation.height;
- }
-
- compute_scaled_size (view, priv->zoom, &img_width, &img_height);
-
- /* this should work fairly well in this special case for scrollbars */
- gtk_widget_get_preferred_size (priv->hbar, &req, NULL);
- bar_height = req.height;
- gtk_widget_get_preferred_size (priv->vbar, &req, NULL);
- bar_width = req.width;
-
- eog_debug_message (DEBUG_WINDOW, "Widget Size allocate: %i, %i Bar: %i, %i\n",
- width, height, bar_width, bar_height);
-
- hbar_visible = vbar_visible = FALSE;
- if (priv->zoom_mode == EOG_ZOOM_MODE_SHRINK_TO_FIT)
- hbar_visible = vbar_visible = FALSE;
- else if (img_width <= width && img_height <= height)
- hbar_visible = vbar_visible = FALSE;
- else if (img_width > width && img_height > height)
- hbar_visible = vbar_visible = TRUE;
- else if (img_width > width) {
- hbar_visible = TRUE;
- if (img_height <= (height - bar_height))
- vbar_visible = FALSE;
- else
- vbar_visible = TRUE;
- }
- else if (img_height > height) {
- vbar_visible = TRUE;
- if (img_width <= (width - bar_width))
- hbar_visible = FALSE;
- else
- hbar_visible = TRUE;
- }
-
- if (hbar_visible != gtk_widget_get_visible (GTK_WIDGET (priv->hbar)))
- g_object_set (G_OBJECT (priv->hbar), "visible", hbar_visible, NULL);
-
- if (vbar_visible != gtk_widget_get_visible (GTK_WIDGET (priv->vbar)))
- g_object_set (G_OBJECT (priv->vbar), "visible", vbar_visible, NULL);
-}
-
#define DOUBLE_EQUAL_MAX_DIFF 1e-6
#define DOUBLE_EQUAL(a,b) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF)
@@ -512,11 +275,14 @@ is_zoomed_out (EogScrollView *view)
static gboolean
is_image_movable (EogScrollView *view)
{
- EogScrollViewPrivate *priv;
-
- priv = view->priv;
+ EogScrollViewPrivate *priv = view->priv;
+ GtkAdjustment *hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (priv->display));
+ GtkAdjustment *vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->display));
+ int widget_width = gtk_widget_get_allocated_width (priv->display);
+ int widget_height = gtk_widget_get_allocated_height (priv->display);
- return (gtk_widget_get_visible (priv->hbar) || gtk_widget_get_visible (priv->vbar));
+ return gtk_adjustment_get_upper (hadjustment) > widget_width ||
+ gtk_adjustment_get_upper (vadjustment) > widget_height;
}
/*===================================
@@ -598,78 +364,63 @@ create_background_surface (EogScrollView *view)
static void
scroll_to (EogScrollView *view, int x, int y, gboolean change_adjustments)
{
- EogScrollViewPrivate *priv;
- GtkAllocation allocation;
- int xofs, yofs;
- GdkWindow *window;
+ EogScrollViewPrivate *priv = view->priv;
+ GtkAdjustment *hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (priv->display));
+ GtkAdjustment *vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->display));
+
#if 0
int src_x, src_y;
int dest_x, dest_y;
int twidth, theight;
#endif
- priv = view->priv;
+ gtk_adjustment_set_value (hadjustment, x);
+ gtk_adjustment_set_value (vadjustment, x);
- /* Check bounds & Compute offsets */
- if (gtk_widget_get_visible (priv->hbar)) {
- x = CLAMP (x, 0, gtk_adjustment_get_upper (priv->hadj)
- - gtk_adjustment_get_page_size (priv->hadj));
- xofs = x - priv->xofs;
- } else
- xofs = 0;
-
- if (gtk_widget_get_visible (priv->vbar)) {
- y = CLAMP (y, 0, gtk_adjustment_get_upper (priv->vadj)
- - gtk_adjustment_get_page_size (priv->vadj));
- yofs = y - priv->yofs;
- } else
- yofs = 0;
-
- if (xofs == 0 && yofs == 0)
- return;
- priv->xofs = x;
- priv->yofs = y;
+ /* Check bounds & Compute offsets */
+ /*if (gtk_widget_get_visible (priv->hbar)) {*/
+ /*x = CLAMP (x, 0, gtk_adjustment_get_upper (priv->hadj)*/
+ /*- gtk_adjustment_get_page_size (priv->hadj));*/
+ /*xofs = x - priv->xofs;*/
+ /*} else*/
+ /*xofs = 0;*/
- if (!gtk_widget_is_drawable (priv->display))
- goto out;
+ /*if (gtk_widget_get_visible (priv->vbar)) {*/
+ /*y = CLAMP (y, 0, gtk_adjustment_get_upper (priv->vadj)*/
+ /*- gtk_adjustment_get_page_size (priv->vadj));*/
+ /*yofs = y - priv->yofs;*/
+ /*} else*/
+ /*yofs = 0;*/
- gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);
+ /*if (xofs == 0 && yofs == 0)*/
+ /*return;*/
- if (abs (xofs) >= allocation.width || abs (yofs) >= allocation.height) {
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
- goto out;
- }
+ /*priv->xofs = x;*/
+ /*priv->yofs = y;*/
- window = gtk_widget_get_window (GTK_WIDGET (priv->display));
+ /*if (!gtk_widget_is_drawable (priv->display))*/
+ /*goto out;*/
- /* Scroll the window area and process exposure synchronously. */
+ /*gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);*/
- if (!gtk_gesture_is_recognized (priv->zoom_gesture)) {
- gdk_window_scroll (window, -xofs, -yofs);
- gdk_window_process_updates (window, TRUE);
- }
+ /*if (abs (xofs) >= allocation.width || abs (yofs) >= allocation.height) {*/
+ /*gtk_widget_queue_draw (GTK_WIDGET (priv->display));*/
+ /*goto out;*/
+ /*}*/
- out:
- if (!change_adjustments)
- return;
+ /*window = gtk_widget_get_window (GTK_WIDGET (priv->display));*/
- g_signal_handlers_block_matched (
- priv->hadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
- g_signal_handlers_block_matched (
- priv->vadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
+ /* Scroll the window area and process exposure synchronously. */
- gtk_adjustment_set_value (priv->hadj, x);
- gtk_adjustment_set_value (priv->vadj, y);
+ /*if (!gtk_gesture_is_recognized (priv->zoom_gesture)) {*/
+ /*gdk_window_scroll (window, -xofs, -yofs);*/
+ /*gdk_window_process_updates (window, TRUE);*/
+ /*}*/
- g_signal_handlers_unblock_matched (
- priv->hadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
- g_signal_handlers_unblock_matched (
- priv->vadj, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, view);
+ /*out:*/
+ /*if (!change_adjustments)*/
+ /*return;*/
}
/* Scrolls the image view by the specified offsets. Notifies the adjustments
@@ -687,18 +438,18 @@ scroll_by (EogScrollView *view, int xofs, int yofs)
/* Callback used when an adjustment is changed */
-static void
-adjustment_changed_cb (GtkAdjustment *adj, gpointer data)
-{
- EogScrollView *view;
- EogScrollViewPrivate *priv;
+/*static void*/
+/*adjustment_changed_cb (GtkAdjustment *adj, gpointer data)*/
+/*{*/
+ /*EogScrollView *view;*/
+ /*EogScrollViewPrivate *priv;*/
- view = EOG_SCROLL_VIEW (data);
- priv = view->priv;
+ /*view = EOG_SCROLL_VIEW (data);*/
+ /*priv = view->priv;*/
- scroll_to (view, gtk_adjustment_get_value (priv->hadj),
- gtk_adjustment_get_value (priv->vadj), FALSE);
-}
+ /*scroll_to (view, gtk_adjustment_get_value (priv->hadj),*/
+ /*gtk_adjustment_get_value (priv->vadj), FALSE);*/
+/*}*/
/* Drags the image to the specified position */
@@ -724,9 +475,9 @@ set_minimum_zoom_factor (EogScrollView *view)
{
g_return_if_fail (EOG_IS_SCROLL_VIEW (view));
- view->priv->min_zoom = MAX (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf),
- MAX(1.0 / gdk_pixbuf_get_height (view->priv->pixbuf),
- MIN_ZOOM_FACTOR) );
+ /*view->priv->min_zoom = MAX (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf),*/
+ /*MAX(1.0 / gdk_pixbuf_get_height (view->priv->pixbuf),*/
+ /*MIN_ZOOM_FACTOR) );*/
return;
}
@@ -749,68 +500,15 @@ static void
set_zoom (EogScrollView *view, double zoom,
gboolean have_anchor, int anchorx, int anchory)
{
- EogScrollViewPrivate *priv;
- GtkAllocation allocation;
+ EogScrollViewPrivate *priv = view->priv;
int xofs, yofs;
double x_rel, y_rel;
- priv = view->priv;
-
- if (priv->pixbuf == NULL)
- return;
-
- if (zoom > MAX_ZOOM_FACTOR)
- zoom = MAX_ZOOM_FACTOR;
- else if (zoom < MIN_ZOOM_FACTOR)
- zoom = MIN_ZOOM_FACTOR;
-
- if (DOUBLE_EQUAL (priv->zoom, zoom))
- return;
- if (DOUBLE_EQUAL (priv->zoom, priv->min_zoom) && zoom < priv->zoom)
- return;
-
- eog_scroll_view_set_zoom_mode (view, EOG_ZOOM_MODE_FREE);
-
- gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);
-
- /* compute new xofs/yofs values */
- if (have_anchor) {
- x_rel = (double) anchorx / allocation.width;
- y_rel = (double) anchory / allocation.height;
- } else {
- x_rel = 0.5;
- y_rel = 0.5;
- }
-
- compute_center_zoom_offsets (view, priv->zoom, zoom,
- allocation.width, allocation.height,
- x_rel, y_rel,
- &xofs, &yofs);
-
- /* set new values */
- priv->xofs = xofs; /* (img_width * x_rel * zoom) - anchorx; */
- priv->yofs = yofs; /* (img_height * y_rel * zoom) - anchory; */
-
- if (priv->dragging) {
- priv->drag_anchor_x = anchorx;
- priv->drag_anchor_y = anchory;
- priv->drag_ofs_x = priv->xofs;
- priv->drag_ofs_y = priv->yofs;
- }
-#if 0
- g_print ("xofs: %i yofs: %i\n", priv->xofs, priv->yofs);
-#endif
- if (zoom <= priv->min_zoom)
- priv->zoom = priv->min_zoom;
- else
- priv->zoom = zoom;
+ zoom = MAX (MIN_ZOOM_FACTOR, zoom);
+ zoom = MIN (MAX_ZOOM_FACTOR, zoom);
- /* we make use of the new values here */
- check_scrollbar_visibility (view, NULL);
- update_scrollbar_values (view);
-
- /* repaint the whole image */
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
+ gtk_image_view_set_scale (GTK_IMAGE_VIEW (priv->display),
+ zoom);
g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom);
}
@@ -820,36 +518,14 @@ static void
set_zoom_fit (EogScrollView *view)
{
EogScrollViewPrivate *priv;
- GtkAllocation allocation;
- double new_zoom;
priv = view->priv;
- priv->zoom_mode = EOG_ZOOM_MODE_SHRINK_TO_FIT;
-
if (!gtk_widget_get_mapped (GTK_WIDGET (view)))
return;
- if (priv->pixbuf == NULL)
- return;
-
- gtk_widget_get_allocation (GTK_WIDGET(priv->display), &allocation);
-
- new_zoom = zoom_fit_scale (allocation.width, allocation.height,
- gdk_pixbuf_get_width (priv->pixbuf),
- gdk_pixbuf_get_height (priv->pixbuf),
- priv->upscale);
-
- if (new_zoom > MAX_ZOOM_FACTOR)
- new_zoom = MAX_ZOOM_FACTOR;
- else if (new_zoom < MIN_ZOOM_FACTOR)
- new_zoom = MIN_ZOOM_FACTOR;
-
- priv->zoom = new_zoom;
- priv->xofs = 0;
- priv->yofs = 0;
-
- g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom);
+ gtk_image_view_set_fit_allocation (GTK_IMAGE_VIEW (priv->display),
+ TRUE);
}
/*===================================
@@ -1064,519 +740,6 @@ eog_scroll_view_button_release_event (GtkWidget *widget, GdkEventButton *event,
return TRUE;
}
-/* Scroll event handler for the image view. We zoom with an event without
- * modifiers rather than scroll; we use the Shift modifier to scroll.
- * Rationale: images are not primarily vertical, and in EOG you scan scroll by
- * dragging the image with button 1 anyways.
- */
-static gboolean
-eog_scroll_view_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer data)
-{
- EogScrollView *view;
- EogScrollViewPrivate *priv;
- double zoom_factor;
- int xofs, yofs;
-
- view = EOG_SCROLL_VIEW (data);
- priv = view->priv;
-
- /* Compute zoom factor and scrolling offsets; we'll only use either of them */
- /* same as in gtkscrolledwindow.c */
- xofs = gtk_adjustment_get_page_increment (priv->hadj) / 2;
- yofs = gtk_adjustment_get_page_increment (priv->vadj) / 2;
-
- switch (event->direction) {
- case GDK_SCROLL_UP:
- zoom_factor = priv->zoom_multiplier;
- xofs = 0;
- yofs = -yofs;
- break;
-
- case GDK_SCROLL_LEFT:
- zoom_factor = 1.0 / priv->zoom_multiplier;
- xofs = -xofs;
- yofs = 0;
- break;
-
- case GDK_SCROLL_DOWN:
- zoom_factor = 1.0 / priv->zoom_multiplier;
- xofs = 0;
- yofs = yofs;
- break;
-
- case GDK_SCROLL_RIGHT:
- zoom_factor = priv->zoom_multiplier;
- xofs = xofs;
- yofs = 0;
- break;
-
- default:
- g_assert_not_reached ();
- return FALSE;
- }
-
- if (priv->scroll_wheel_zoom) {
- if (event->state & GDK_SHIFT_MASK)
- scroll_by (view, yofs, xofs);
- else if (event->state & GDK_CONTROL_MASK)
- scroll_by (view, xofs, yofs);
- else
- set_zoom (view, priv->zoom * zoom_factor,
- TRUE, event->x, event->y);
- } else {
- if (event->state & GDK_SHIFT_MASK)
- scroll_by (view, yofs, xofs);
- else if (event->state & GDK_CONTROL_MASK)
- set_zoom (view, priv->zoom * zoom_factor,
- TRUE, event->x, event->y);
- else
- scroll_by (view, xofs, yofs);
- }
-
- return TRUE;
-}
-
-/* Motion event handler for the image view */
-static gboolean
-eog_scroll_view_motion_event (GtkWidget *widget, GdkEventMotion *event, gpointer data)
-{
- EogScrollView *view;
- EogScrollViewPrivate *priv;
- gint x, y;
- GdkModifierType mods;
-
- view = EOG_SCROLL_VIEW (data);
- priv = view->priv;
-
- if (gtk_gesture_is_recognized (priv->zoom_gesture))
- return TRUE;
-
- if (!priv->dragging)
- return FALSE;
-
- if (event->is_hint)
- gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (priv->display)),
event->device, &x, &y, &mods);
- else {
- x = event->x;
- y = event->y;
- }
-
- drag_to (view, x, y);
- return TRUE;
-}
-
-static void
-display_map_event (GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- EogScrollView *view;
- EogScrollViewPrivate *priv;
-
- view = EOG_SCROLL_VIEW (data);
- priv = view->priv;
-
- eog_debug (DEBUG_WINDOW);
-
- set_zoom_fit (view);
- check_scrollbar_visibility (view, NULL);
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
-}
-
-static void
-eog_scroll_view_size_allocate (GtkWidget *widget, GtkAllocation *alloc)
-{
- EogScrollView *view;
-
- view = EOG_SCROLL_VIEW (widget);
- check_scrollbar_visibility (view, alloc);
-
- GTK_WIDGET_CLASS (eog_scroll_view_parent_class)->size_allocate (widget
- ,alloc);
-}
-
-static void
-display_size_change (GtkWidget *widget, GdkEventConfigure *event, gpointer data)
-{
- EogScrollView *view;
- EogScrollViewPrivate *priv;
-
- view = EOG_SCROLL_VIEW (data);
- priv = view->priv;
-
- if (priv->zoom_mode == EOG_ZOOM_MODE_SHRINK_TO_FIT) {
- GtkAllocation alloc;
-
- alloc.width = event->width;
- alloc.height = event->height;
-
- set_zoom_fit (view);
- check_scrollbar_visibility (view, &alloc);
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
- } else {
- int scaled_width, scaled_height;
- int x_offset = 0;
- int y_offset = 0;
-
- compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
-
- if (priv->xofs + event->width > scaled_width)
- x_offset = scaled_width - event->width - priv->xofs;
-
- if (priv->yofs + event->height > scaled_height)
- y_offset = scaled_height - event->height - priv->yofs;
-
- scroll_by (view, x_offset, y_offset);
- }
-
- update_scrollbar_values (view);
-}
-
-
-static gboolean
-eog_scroll_view_focus_in_event (GtkWidget *widget,
- GdkEventFocus *event,
- gpointer data)
-{
- g_signal_stop_emission_by_name (G_OBJECT (widget), "focus_in_event");
- return FALSE;
-}
-
-static gboolean
-eog_scroll_view_focus_out_event (GtkWidget *widget,
- GdkEventFocus *event,
- gpointer data)
-{
- g_signal_stop_emission_by_name (G_OBJECT (widget), "focus_out_event");
- return FALSE;
-}
-
-static gboolean
-display_draw (GtkWidget *widget, cairo_t *cr, gpointer data)
-{
- const GdkRGBA *background_color = NULL;
- EogScrollView *view;
- EogScrollViewPrivate *priv;
- GtkAllocation allocation;
- int scaled_width, scaled_height;
- int xofs, yofs;
-
- g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), FALSE);
- g_return_val_if_fail (EOG_IS_SCROLL_VIEW (data), FALSE);
-
- view = EOG_SCROLL_VIEW (data);
-
- priv = view->priv;
-
- if (priv->pixbuf == NULL)
- return TRUE;
-
- eog_scroll_view_get_image_coords (view, &xofs, &yofs,
- &scaled_width, &scaled_height);
-
- eog_debug_message (DEBUG_WINDOW, "zoom %.2f, xofs: %i, yofs: %i scaled w: %i h: %i\n",
- priv->zoom, xofs, yofs, scaled_width, scaled_height);
-
- /* Paint the background */
- gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);
- cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
- if (priv->transp_style != EOG_TRANSP_BACKGROUND)
- cairo_rectangle (cr, MAX (0, xofs), MAX (0, yofs),
- scaled_width, scaled_height);
- if (priv->override_bg_color != NULL)
- background_color = priv->override_bg_color;
- else if (priv->use_bg_color)
- background_color = priv->background_color;
- if (background_color != NULL)
- cairo_set_source_rgba (cr,
- background_color->red,
- background_color->green,
- background_color->blue,
- background_color->alpha);
- else
- cairo_set_source (cr, gdk_window_get_background_pattern (gtk_widget_get_window
(priv->display)));
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_fill (cr);
-
- if (gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
- if (priv->background_surface == NULL) {
- priv->background_surface = create_background_surface (view);
- }
- cairo_set_source_surface (cr, priv->background_surface, xofs, yofs);
- cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
- cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height);
- cairo_fill (cr);
- }
-
- /* Make sure the image is only drawn as large as needed.
- * This is especially necessary for SVGs where there might
- * be more image data available outside the image boundaries.
- */
- cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height);
- cairo_clip (cr);
-
-#ifdef HAVE_RSVG
- if (eog_image_is_svg (view->priv->image)) {
- cairo_matrix_t matrix, translate, scale, original;
- EogTransform *transform = eog_image_get_transform (priv->image);
- cairo_matrix_init_identity (&matrix);
- if (transform) {
- cairo_matrix_t affine;
- double image_offset_x = 0., image_offset_y = 0.;
-
- eog_transform_get_affine (transform, &affine);
- cairo_matrix_multiply (&matrix, &affine, &matrix);
-
- switch (eog_transform_get_transform_type (transform)) {
- case EOG_TRANSFORM_ROT_90:
- case EOG_TRANSFORM_FLIP_HORIZONTAL:
- image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf);
- break;
- case EOG_TRANSFORM_ROT_270:
- case EOG_TRANSFORM_FLIP_VERTICAL:
- image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf);
- break;
- case EOG_TRANSFORM_ROT_180:
- case EOG_TRANSFORM_TRANSPOSE:
- case EOG_TRANSFORM_TRANSVERSE:
- image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf);
- image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf);
- break;
- case EOG_TRANSFORM_NONE:
- default:
- break;
- }
- cairo_matrix_init_translate (&translate, image_offset_x, image_offset_y);
- cairo_matrix_multiply (&matrix, &matrix, &translate);
- }
- cairo_matrix_init_scale (&scale, priv->zoom, priv->zoom);
- cairo_matrix_multiply (&matrix, &matrix, &scale);
- cairo_matrix_init_translate (&translate, xofs, yofs);
- cairo_matrix_multiply (&matrix, &matrix, &translate);
-
- cairo_get_matrix (cr, &original);
- cairo_matrix_multiply (&matrix, &matrix, &original);
- cairo_set_matrix (cr, &matrix);
-
- rsvg_handle_render_cairo (eog_image_get_svg (priv->image), cr);
-
- } else
-#endif /* HAVE_RSVG */
- {
- cairo_scale (cr, priv->zoom, priv->zoom);
- cairo_set_source_surface (cr, priv->surface, xofs/priv->zoom, yofs/priv->zoom);
- cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
- if (is_zoomed_in (view))
- cairo_pattern_set_filter (cairo_get_source (cr), priv->interp_type_in);
- else if (is_zoomed_out (view))
- cairo_pattern_set_filter (cairo_get_source (cr), priv->interp_type_out);
-
- cairo_paint (cr);
- }
-
- return TRUE;
-}
-
-static void
-zoom_gesture_begin_cb (GtkGestureZoom *gesture,
- GdkEventSequence *sequence,
- EogScrollView *view)
-{
- gdouble center_x, center_y;
- EogScrollViewPrivate *priv;
-
- priv = view->priv;
-
- /* Displace dragging point to gesture center */
- gtk_gesture_get_bounding_box_center (GTK_GESTURE (gesture),
- ¢er_x, ¢er_y);
- priv->drag_anchor_x = center_x;
- priv->drag_anchor_y = center_y;
- priv->drag_ofs_x = priv->xofs;
- priv->drag_ofs_y = priv->yofs;
- priv->dragging = TRUE;
- priv->initial_zoom = priv->zoom;
-
- gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
-}
-
-static void
-zoom_gesture_update_cb (GtkGestureZoom *gesture,
- GdkEventSequence *sequence,
- EogScrollView *view)
-{
- gdouble center_x, center_y, scale;
- EogScrollViewPrivate *priv;
-
- priv = view->priv;
- scale = gtk_gesture_zoom_get_scale_delta (gesture);
- gtk_gesture_get_bounding_box_center (GTK_GESTURE (gesture),
- ¢er_x, ¢er_y);
-
- drag_to (view, center_x, center_y);
- set_zoom (view, priv->initial_zoom * scale, TRUE,
- center_x, center_y);
-}
-
-static void
-zoom_gesture_end_cb (GtkGestureZoom *gesture,
- GdkEventSequence *sequence,
- EogScrollView *view)
-{
- EogScrollViewPrivate *priv;
-
- priv = view->priv;
- priv->dragging = FALSE;
- eog_scroll_view_set_cursor (view, EOG_SCROLL_VIEW_CURSOR_NORMAL);
-}
-
-static void
-rotate_gesture_begin_cb (GtkGesture *gesture,
- GdkEventSequence *sequence,
- EogScrollView *view)
-{
- EogScrollViewPrivate *priv;
-
- priv = view->priv;
- priv->rotate_state = EOG_TRANSFORM_NONE;
-}
-
-static void
-pan_gesture_pan_cb (GtkGesturePan *gesture,
- GtkPanDirection direction,
- gdouble offset,
- EogScrollView *view)
-{
- EogScrollViewPrivate *priv;
-
- if (eog_scroll_view_scrollbars_visible (view)) {
- gtk_gesture_set_state (GTK_GESTURE (gesture),
- GTK_EVENT_SEQUENCE_DENIED);
- return;
- }
-
-#define PAN_ACTION_DISTANCE 200
-
- priv = view->priv;
- priv->pan_action = EOG_PAN_ACTION_NONE;
- gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
-
- if (offset > PAN_ACTION_DISTANCE) {
- if (direction == GTK_PAN_DIRECTION_LEFT ||
- gtk_widget_get_direction (GTK_WIDGET (view)) == GTK_TEXT_DIR_RTL)
- priv->pan_action = EOG_PAN_ACTION_NEXT;
- else
- priv->pan_action = EOG_PAN_ACTION_PREV;
- }
-#undef PAN_ACTION_DISTANCE
-}
-
-static void
-pan_gesture_end_cb (GtkGesture *gesture,
- GdkEventSequence *sequence,
- EogScrollView *view)
-{
- EogScrollViewPrivate *priv;
-
- if (!gtk_gesture_handles_sequence (gesture, sequence))
- return;
-
- priv = view->priv;
-
- if (priv->pan_action == EOG_PAN_ACTION_PREV)
- g_signal_emit (view, view_signals [SIGNAL_PREVIOUS_IMAGE], 0);
- else if (priv->pan_action == EOG_PAN_ACTION_NEXT)
- g_signal_emit (view, view_signals [SIGNAL_NEXT_IMAGE], 0);
-
- priv->pan_action = EOG_PAN_ACTION_NONE;
-}
-
-static gboolean
-scroll_view_check_angle (gdouble angle,
- gdouble min,
- gdouble max,
- gdouble threshold)
-{
- if (min < max) {
- return (angle > min - threshold &&
- angle < max + threshold);
- } else {
- return (angle < max + threshold ||
- angle > min - threshold);
- }
-}
-
-static EogRotationState
-scroll_view_get_rotate_state (EogScrollView *view,
- gdouble delta)
-{
- EogScrollViewPrivate *priv;
-
- priv = view->priv;
-
-#define THRESHOLD (G_PI / 16)
- switch (priv->rotate_state) {
- case EOG_ROTATION_0:
- if (scroll_view_check_angle (delta, G_PI * 7 / 4,
- G_PI / 4, THRESHOLD))
- return priv->rotate_state;
- break;
- case EOG_ROTATION_90:
- if (scroll_view_check_angle (delta, G_PI / 4,
- G_PI * 3 / 4, THRESHOLD))
- return priv->rotate_state;
- break;
- case EOG_ROTATION_180:
- if (scroll_view_check_angle (delta, G_PI * 3 / 4,
- G_PI * 5 / 4, THRESHOLD))
- return priv->rotate_state;
- break;
- case EOG_ROTATION_270:
- if (scroll_view_check_angle (delta, G_PI * 5 / 4,
- G_PI * 7 / 4, THRESHOLD))
- return priv->rotate_state;
- break;
- default:
- g_assert_not_reached ();
- }
-
-#undef THRESHOLD
-
- if (scroll_view_check_angle (delta, G_PI / 4, G_PI * 3 / 4, 0))
- return EOG_ROTATION_90;
- else if (scroll_view_check_angle (delta, G_PI * 3 / 4, G_PI * 5 / 4, 0))
- return EOG_ROTATION_180;
- else if (scroll_view_check_angle (delta, G_PI * 5 / 4, G_PI * 7 / 4, 0))
- return EOG_ROTATION_270;
-
- return EOG_ROTATION_0;
-}
-
-static void
-rotate_gesture_angle_changed_cb (GtkGestureRotate *rotate,
- gdouble angle,
- gdouble delta,
- EogScrollView *view)
-{
- EogRotationState rotate_state;
- EogScrollViewPrivate *priv;
- gint angle_diffs [N_EOG_ROTATIONS][N_EOG_ROTATIONS] = {
- { 0, 90, 180, 270 },
- { 270, 0, 90, 180 },
- { 180, 270, 0, 90 },
- { 90, 180, 270, 0 }
- };
- gint rotate_angle;
-
- priv = view->priv;
- rotate_state = scroll_view_get_rotate_state (view, delta);
-
- if (priv->rotate_state == rotate_state)
- return;
-
- rotate_angle = angle_diffs[priv->rotate_state][rotate_state];
- g_signal_emit (view, view_signals [SIGNAL_ROTATION_CHANGED], 0, (gdouble) rotate_angle);
- priv->rotate_state = rotate_state;
-}
-
/*==================================
image loading callbacks
@@ -1589,29 +752,19 @@ static void
update_pixbuf (EogScrollView *view, GdkPixbuf *pixbuf)
{
EogScrollViewPrivate *priv;
-
priv = view->priv;
- if (priv->pixbuf != NULL) {
- g_object_unref (priv->pixbuf);
- priv->pixbuf = NULL;
- }
-
- priv->pixbuf = pixbuf;
- if (priv->surface) {
- cairo_surface_destroy (priv->surface);
- }
- priv->surface = create_surface_from_pixbuf (view, priv->pixbuf);
+ gtk_image_view_set_pixbuf (GTK_IMAGE_VIEW (priv->display),
+ pixbuf,
+ 0);
}
static void
image_changed_cb (EogImage *img, gpointer data)
{
update_pixbuf (EOG_SCROLL_VIEW (data), eog_image_get_pixbuf (img));
-
- _set_zoom_mode_internal (EOG_SCROLL_VIEW (data),
- EOG_ZOOM_MODE_SHRINK_TO_FIT);
+ set_zoom_fit (EOG_SCROLL_VIEW (data));
}
/*===================================
@@ -1641,12 +794,7 @@ eog_scroll_view_set_zoom_upscale (EogScrollView *view, gboolean upscale)
priv = view->priv;
if (priv->upscale != upscale) {
- priv->upscale = upscale;
-
- if (priv->zoom_mode == EOG_ZOOM_MODE_SHRINK_TO_FIT) {
- set_zoom_fit (view);
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
- }
+ // XXX ??
}
}
@@ -1693,14 +841,14 @@ _transp_background_changed (EogScrollView *view)
{
EogScrollViewPrivate *priv = view->priv;
- if (priv->pixbuf != NULL && gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
- if (priv->background_surface) {
- cairo_surface_destroy (priv->background_surface);
- /* Will be recreated if needed during redraw */
- priv->background_surface = NULL;
- }
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
- }
+ /*if (priv->pixbuf != NULL && gdk_pixbuf_get_has_alpha (priv->pixbuf)) {*/
+ /*if (priv->background_surface) {*/
+ /*cairo_surface_destroy (priv->background_surface);*/
+ /*Will be recreated if needed during redraw */
+ /*priv->background_surface = NULL;*/
+ /*}*/
+ /*gtk_widget_queue_draw (GTK_WIDGET (priv->display));*/
+ /*}*/
}
@@ -1729,7 +877,7 @@ eog_scroll_view_set_transparency (EogScrollView *view,
EogScrollViewPrivate *priv;
g_return_if_fail (EOG_IS_SCROLL_VIEW (view));
-
+
priv = view->priv;
if (priv->transp_style != style) {
@@ -1759,30 +907,7 @@ eog_scroll_view_zoom_in (EogScrollView *view, gboolean smooth)
priv = view->priv;
- if (smooth) {
- zoom = priv->zoom * priv->zoom_multiplier;
- }
- else {
- int i;
- int index = -1;
-
- for (i = 0; i < n_zoom_levels; i++) {
- if (preferred_zoom_levels [i] - priv->zoom
- > DOUBLE_EQUAL_MAX_DIFF) {
- index = i;
- break;
- }
- }
-
- if (index == -1) {
- zoom = priv->zoom;
- }
- else {
- zoom = preferred_zoom_levels [i];
- }
- }
- set_zoom (view, zoom, FALSE, 0, 0);
-
+ /* TODO: Implement */
}
void
@@ -1795,28 +920,7 @@ eog_scroll_view_zoom_out (EogScrollView *view, gboolean smooth)
priv = view->priv;
- if (smooth) {
- zoom = priv->zoom / priv->zoom_multiplier;
- }
- else {
- int i;
- int index = -1;
-
- for (i = n_zoom_levels - 1; i >= 0; i--) {
- if (priv->zoom - preferred_zoom_levels [i]
- > DOUBLE_EQUAL_MAX_DIFF) {
- index = i;
- break;
- }
- }
- if (index == -1) {
- zoom = priv->zoom;
- }
- else {
- zoom = preferred_zoom_levels [i];
- }
- }
- set_zoom (view, zoom, FALSE, 0, 0);
+ /* TODO: Implement */
}
static void
@@ -1825,8 +929,6 @@ eog_scroll_view_zoom_fit (EogScrollView *view)
g_return_if_fail (EOG_IS_SCROLL_VIEW (view));
set_zoom_fit (view);
- check_scrollbar_visibility (view, NULL);
- gtk_widget_queue_draw (GTK_WIDGET (view->priv->display));
}
void
@@ -1840,9 +942,12 @@ eog_scroll_view_set_zoom (EogScrollView *view, double zoom)
double
eog_scroll_view_get_zoom (EogScrollView *view)
{
+ EogScrollViewPrivate *priv;
g_return_val_if_fail (EOG_IS_SCROLL_VIEW (view), 0.0);
- return view->priv->zoom;
+ priv = view->priv;
+
+ return gtk_image_view_get_scale (GTK_IMAGE_VIEW (priv->display));
}
gboolean
@@ -1878,7 +983,7 @@ display_next_frame_cb (EogImage *image, gint delay, gpointer data)
update_pixbuf (view, eog_image_get_pixbuf (image));
- gtk_widget_queue_draw (GTK_WIDGET (priv->display));
+ gtk_widget_queue_draw (GTK_WIDGET (priv->display));
}
void
@@ -1898,19 +1003,15 @@ eog_scroll_view_set_image (EogScrollView *view, EogImage *image)
free_image_resources (view);
}
g_assert (priv->image == NULL);
- g_assert (priv->pixbuf == NULL);
/* priv->progressive_state = PROGRESSIVE_NONE; */
if (image != NULL) {
eog_image_data_ref (image);
- if (priv->pixbuf == NULL) {
- update_pixbuf (view, eog_image_get_pixbuf (image));
- /* priv->progressive_state = PROGRESSIVE_NONE; */
- _set_zoom_mode_internal (view,
- EOG_ZOOM_MODE_SHRINK_TO_FIT);
+ update_pixbuf (view, eog_image_get_pixbuf (image));
+ set_zoom_fit (view);
+
- }
#if 0
else if ((is_zoomed_in (view) && priv->interp_type_in != CAIRO_FILTER_NEAREST) ||
(is_zoomed_out (view) && priv->interp_type_out != CAIRO_FILTER_NEAREST))
@@ -1925,7 +1026,7 @@ eog_scroll_view_set_image (EogScrollView *view, EogImage *image)
(GCallback) image_changed_cb, view);
if (eog_image_is_animation (image) == TRUE ) {
eog_image_start_animation (image);
- priv->frame_changed_id = g_signal_connect (image, "next-frame",
+ priv->frame_changed_id = g_signal_connect (image, "next-frame",
(GCallback) display_next_frame_cb, view);
}
}
@@ -1958,16 +1059,15 @@ eog_scroll_view_get_image (EogScrollView *view)
return img;
}
+
gboolean
eog_scroll_view_scrollbars_visible (EogScrollView *view)
{
- if (!gtk_widget_get_visible (GTK_WIDGET (view->priv->hbar)) &&
- !gtk_widget_get_visible (GTK_WIDGET (view->priv->vbar)))
- return FALSE;
-
return TRUE;
}
+
+
/*===================================
object creation/freeing
---------------------------------*/
@@ -2063,7 +1163,7 @@ _enter_overlay_event_cb (GtkWidget *widget,
}
static gboolean
-_motion_notify_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
+eog_scroll_view_motion_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
{
EogScrollView *view = EOG_SCROLL_VIEW (user_data);
EogScrollViewPrivate *priv = view->priv;
@@ -2080,7 +1180,12 @@ _motion_notify_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
/* reset timeout */
_set_overlay_timeout(view);
- return FALSE;
+ if (!priv->dragging)
+ return GDK_EVENT_PROPAGATE;
+
+ drag_to (view, event->x, event->y);
+
+ return GDK_EVENT_STOP;
}
static void
@@ -2094,17 +1199,13 @@ eog_scroll_view_init (EogScrollView *view)
priv->zoom = 1.0;
priv->min_zoom = MIN_ZOOM_FACTOR;
- priv->zoom_mode = EOG_ZOOM_MODE_SHRINK_TO_FIT;
priv->upscale = FALSE;
- //priv->uta = NULL;
priv->interp_type_in = CAIRO_FILTER_BILINEAR;
priv->interp_type_out = CAIRO_FILTER_BILINEAR;
priv->scroll_wheel_zoom = FALSE;
priv->zoom_multiplier = IMAGE_VIEW_ZOOM_MULTIPLIER;
priv->image = NULL;
- priv->pixbuf = NULL;
priv->surface = NULL;
- /* priv->progressive_state = PROGRESSIVE_NONE; */
priv->transp_style = EOG_TRANSP_BACKGROUND;
g_warn_if_fail (gdk_rgba_parse(&priv->transp_color, CHECK_BLACK));
priv->cursor = EOG_SCROLL_VIEW_CURSOR_NORMAL;
@@ -2112,26 +1213,7 @@ eog_scroll_view_init (EogScrollView *view)
priv->override_bg_color = NULL;
priv->background_surface = NULL;
- priv->hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 100, 0, 10, 10, 100));
- g_signal_connect (priv->hadj, "value_changed",
- G_CALLBACK (adjustment_changed_cb),
- view);
-
- priv->hbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, priv->hadj);
- priv->vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 100, 0, 10, 10, 100));
- g_signal_connect (priv->vadj, "value_changed",
- G_CALLBACK (adjustment_changed_cb),
- view);
-
- priv->vbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, priv->vadj);
-
- priv->overlay = gtk_overlay_new ();
- gtk_grid_attach (GTK_GRID (view), priv->overlay, 0, 0, 1, 1);
-
- priv->display = g_object_new (GTK_TYPE_DRAWING_AREA,
- "can-focus", TRUE,
- NULL);
-
+ priv->display = gtk_image_view_new ();
gtk_widget_add_events (GTK_WIDGET (priv->display),
GDK_EXPOSURE_MASK
| GDK_TOUCHPAD_GESTURE_MASK
@@ -2142,49 +1224,34 @@ eog_scroll_view_init (EogScrollView *view)
| GDK_TOUCH_MASK
| GDK_SCROLL_MASK
| GDK_KEY_PRESS_MASK);
- g_signal_connect (G_OBJECT (priv->display), "configure_event",
- G_CALLBACK (display_size_change), view);
- g_signal_connect (G_OBJECT (priv->display), "draw",
- G_CALLBACK (display_draw), view);
- g_signal_connect (G_OBJECT (priv->display), "map_event",
- G_CALLBACK (display_map_event), view);
- g_signal_connect (G_OBJECT (priv->display), "button_press_event",
- G_CALLBACK (eog_scroll_view_button_press_event),
- view);
- g_signal_connect (G_OBJECT (priv->display), "motion_notify_event",
- G_CALLBACK (eog_scroll_view_motion_event), view);
- g_signal_connect (G_OBJECT (priv->display), "button_release_event",
- G_CALLBACK (eog_scroll_view_button_release_event),
- view);
- g_signal_connect (G_OBJECT (priv->display), "scroll_event",
- G_CALLBACK (eog_scroll_view_scroll_event), view);
- g_signal_connect (G_OBJECT (priv->display), "focus_in_event",
- G_CALLBACK (eog_scroll_view_focus_in_event), NULL);
- g_signal_connect (G_OBJECT (priv->display), "focus_out_event",
- G_CALLBACK (eog_scroll_view_focus_out_event), NULL);
-
- g_signal_connect (G_OBJECT (view), "key_press_event",
- G_CALLBACK (display_key_press_event), view);
-
- gtk_drag_source_set (priv->display, GDK_BUTTON1_MASK,
- target_table, G_N_ELEMENTS (target_table),
- GDK_ACTION_COPY | GDK_ACTION_MOVE |
- GDK_ACTION_LINK | GDK_ACTION_ASK);
- g_signal_connect (G_OBJECT (priv->display), "drag-data-get",
- G_CALLBACK (view_on_drag_data_get_cb), view);
- g_signal_connect (G_OBJECT (priv->display), "drag-begin",
- G_CALLBACK (view_on_drag_begin_cb), view);
-
- gtk_container_add (GTK_CONTAINER (priv->overlay), priv->display);
-
- gtk_widget_set_hexpand (priv->display, TRUE);
- gtk_widget_set_vexpand (priv->display, TRUE);
- gtk_grid_attach (GTK_GRID (view), priv->hbar,
- 0, 1, 1, 1);
- gtk_widget_set_hexpand (priv->hbar, TRUE);
- gtk_grid_attach (GTK_GRID (view), priv->vbar,
- 1, 0, 1, 1);
- gtk_widget_set_vexpand (priv->vbar, TRUE);
+
+ g_signal_connect (G_OBJECT (view), "key-press-event",
+ G_CALLBACK (display_key_press_event), view);
+
+ /*gtk_drag_source_set (priv->display, GDK_BUTTON1_MASK,*/
+ /*target_table, G_N_ELEMENTS (target_table),*/
+ /*GDK_ACTION_COPY | GDK_ACTION_MOVE |*/
+ /*GDK_ACTION_LINK | GDK_ACTION_ASK);*/
+ /*g_signal_connect (G_OBJECT (priv->display), "drag-data-get",*/
+ /*G_CALLBACK (view_on_drag_data_get_cb), view);*/
+ /*g_signal_connect (G_OBJECT (priv->display), "drag-begin",*/
+ /*G_CALLBACK (view_on_drag_begin_cb), view);*/
+
+ g_signal_connect (priv->display, "button-press-event",
+ G_CALLBACK (eog_scroll_view_button_press_event), view);
+ g_signal_connect (priv->display, "button-release-event",
+ G_CALLBACK (eog_scroll_view_button_release_event), view);
+
+ /* Display overlay buttons on mouse movement */
+ g_signal_connect (priv->display,
+ "motion-notify-event",
+ G_CALLBACK (eog_scroll_view_motion_event),
+ view);
+
+ priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_container_add (GTK_CONTAINER (priv->scrolled_window), priv->display);
+ gtk_container_add (GTK_CONTAINER (view), priv->scrolled_window);
+
g_settings_bind (settings, EOG_CONF_VIEW_USE_BG_COLOR, view,
"use-background-color", G_SETTINGS_BIND_DEFAULT);
@@ -2207,141 +1274,101 @@ eog_scroll_view_init (EogScrollView *view)
g_object_unref (settings);
- priv->zoom_gesture = gtk_gesture_zoom_new (GTK_WIDGET (view));
- g_signal_connect (priv->zoom_gesture, "begin",
- G_CALLBACK (zoom_gesture_begin_cb), view);
- g_signal_connect (priv->zoom_gesture, "update",
- G_CALLBACK (zoom_gesture_update_cb), view);
- g_signal_connect (priv->zoom_gesture, "end",
- G_CALLBACK (zoom_gesture_end_cb), view);
- g_signal_connect (priv->zoom_gesture, "cancel",
- G_CALLBACK (zoom_gesture_end_cb), view);
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->zoom_gesture),
- GTK_PHASE_CAPTURE);
-
- priv->rotate_gesture = gtk_gesture_rotate_new (GTK_WIDGET (view));
- gtk_gesture_group (priv->rotate_gesture, priv->zoom_gesture);
- g_signal_connect (priv->rotate_gesture, "angle-changed",
- G_CALLBACK (rotate_gesture_angle_changed_cb), view);
- g_signal_connect (priv->rotate_gesture, "begin",
- G_CALLBACK (rotate_gesture_begin_cb), view);
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->rotate_gesture),
- GTK_PHASE_CAPTURE);
-
- priv->pan_gesture = gtk_gesture_pan_new (GTK_WIDGET (view),
- GTK_ORIENTATION_HORIZONTAL);
- g_signal_connect (priv->pan_gesture, "pan",
- G_CALLBACK (pan_gesture_pan_cb), view);
- g_signal_connect (priv->pan_gesture, "end",
- G_CALLBACK (pan_gesture_end_cb), view);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->pan_gesture),
- TRUE);
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->pan_gesture),
- GTK_PHASE_CAPTURE);
-
/* left revealer */
- priv->left_revealer = gtk_revealer_new ();
- gtk_revealer_set_transition_type (GTK_REVEALER (priv->left_revealer),
- GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
- gtk_revealer_set_transition_duration (GTK_REVEALER (priv->left_revealer),
- OVERLAY_REVEAL_ANIM_TIME);
- gtk_widget_set_halign (priv->left_revealer, GTK_ALIGN_START);
- gtk_widget_set_valign (priv->left_revealer, GTK_ALIGN_CENTER);
- gtk_widget_set_margin_start(priv->left_revealer, 12);
- gtk_widget_set_margin_end(priv->left_revealer, 12);
- gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay),
- priv->left_revealer);
+ priv->left_revealer = gtk_revealer_new ();
+ gtk_revealer_set_transition_type (GTK_REVEALER (priv->left_revealer),
+ GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
+ gtk_revealer_set_transition_duration (GTK_REVEALER (priv->left_revealer),
+ OVERLAY_REVEAL_ANIM_TIME);
+ gtk_widget_set_halign (priv->left_revealer, GTK_ALIGN_START);
+ gtk_widget_set_valign (priv->left_revealer, GTK_ALIGN_CENTER);
+ gtk_widget_set_margin_start(priv->left_revealer, 12);
+ gtk_widget_set_margin_end(priv->left_revealer, 12);
+ gtk_overlay_add_overlay (GTK_OVERLAY (view), priv->left_revealer);
/* right revealer */
- priv->right_revealer = gtk_revealer_new ();
- gtk_revealer_set_transition_type (GTK_REVEALER (priv->right_revealer),
- GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
- gtk_revealer_set_transition_duration (GTK_REVEALER (priv->right_revealer),
- OVERLAY_REVEAL_ANIM_TIME);
- gtk_widget_set_halign (priv->right_revealer, GTK_ALIGN_END);
- gtk_widget_set_valign (priv->right_revealer, GTK_ALIGN_CENTER);
- gtk_widget_set_margin_start (priv->right_revealer, 12);
- gtk_widget_set_margin_end (priv->right_revealer, 12);
- gtk_overlay_add_overlay(GTK_OVERLAY (priv->overlay),
- priv->right_revealer);
+ priv->right_revealer = gtk_revealer_new ();
+ gtk_revealer_set_transition_type (GTK_REVEALER (priv->right_revealer),
+ GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
+ gtk_revealer_set_transition_duration (GTK_REVEALER (priv->right_revealer),
+ OVERLAY_REVEAL_ANIM_TIME);
+ gtk_widget_set_halign (priv->right_revealer, GTK_ALIGN_END);
+ gtk_widget_set_valign (priv->right_revealer, GTK_ALIGN_CENTER);
+ gtk_widget_set_margin_start (priv->right_revealer, 12);
+ gtk_widget_set_margin_end (priv->right_revealer, 12);
+ gtk_overlay_add_overlay(GTK_OVERLAY (view), priv->right_revealer);
/* bottom revealer */
- priv->bottom_revealer = gtk_revealer_new ();
- gtk_revealer_set_transition_type (GTK_REVEALER (priv->bottom_revealer),
- GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
- gtk_revealer_set_transition_duration (GTK_REVEALER (priv->bottom_revealer),
- OVERLAY_REVEAL_ANIM_TIME);
- gtk_widget_set_halign (priv->bottom_revealer, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (priv->bottom_revealer, GTK_ALIGN_END);
- gtk_widget_set_margin_bottom (priv->bottom_revealer, 12);
- gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay),
- priv->bottom_revealer);
+ priv->bottom_revealer = gtk_revealer_new ();
+ gtk_revealer_set_transition_type (GTK_REVEALER (priv->bottom_revealer),
+ GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
+ gtk_revealer_set_transition_duration (GTK_REVEALER (priv->bottom_revealer),
+ OVERLAY_REVEAL_ANIM_TIME);
+ gtk_widget_set_halign (priv->bottom_revealer, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (priv->bottom_revealer, GTK_ALIGN_END);
+ gtk_widget_set_margin_bottom (priv->bottom_revealer, 12);
+ gtk_overlay_add_overlay (GTK_OVERLAY (view), priv->bottom_revealer);
/* overlaid buttons */
- GtkWidget *button = gtk_button_new_from_icon_name ("go-next-symbolic",
- GTK_ICON_SIZE_BUTTON);
+ GtkWidget *button = gtk_button_new_from_icon_name ("go-next-symbolic",
+ GTK_ICON_SIZE_BUTTON);
- gtk_container_add(GTK_CONTAINER (priv->right_revealer), button);
- gtk_actionable_set_action_name(GTK_ACTIONABLE (button), "win.go-next");
- gtk_widget_set_tooltip_text (button,
- _("Go to the next image of the gallery"));
- gtk_style_context_add_class (gtk_widget_get_style_context (button),
- GTK_STYLE_CLASS_OSD);
+ gtk_container_add(GTK_CONTAINER (priv->right_revealer), button);
+ gtk_actionable_set_action_name(GTK_ACTIONABLE (button), "win.go-next");
+ gtk_widget_set_tooltip_text (button,
+ _("Go to the next image of the gallery"));
+ gtk_style_context_add_class (gtk_widget_get_style_context (button),
+ GTK_STYLE_CLASS_OSD);
- button = gtk_button_new_from_icon_name("go-previous-symbolic",
- GTK_ICON_SIZE_BUTTON);
+ button = gtk_button_new_from_icon_name("go-previous-symbolic",
+ GTK_ICON_SIZE_BUTTON);
- gtk_container_add(GTK_CONTAINER (priv->left_revealer), button);
- gtk_actionable_set_action_name (GTK_ACTIONABLE(button),
- "win.go-previous");
- gtk_widget_set_tooltip_text (button,
- _("Go to the previous image of the gallery"));
- gtk_style_context_add_class (gtk_widget_get_style_context (button),
- GTK_STYLE_CLASS_OSD);
+ gtk_container_add(GTK_CONTAINER (priv->left_revealer), button);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE(button),
+ "win.go-previous");
+ gtk_widget_set_tooltip_text (button,
+ _("Go to the previous image of the gallery"));
+ gtk_style_context_add_class (gtk_widget_get_style_context (button),
+ GTK_STYLE_CLASS_OSD);
/* group rotate buttons into a box */
- GtkWidget* bottomBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_style_context_add_class (gtk_widget_get_style_context (bottomBox),
- GTK_STYLE_CLASS_LINKED);
-
- button = gtk_button_new_from_icon_name ("object-rotate-left-symbolic",
- GTK_ICON_SIZE_BUTTON);
- gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
- "win.rotate-270");
- gtk_widget_set_tooltip_text (button,
- _("Rotate the image 90 degrees to the left"));
- gtk_style_context_add_class (gtk_widget_get_style_context (button),
- GTK_STYLE_CLASS_OSD);
-
- gtk_container_add (GTK_CONTAINER (bottomBox), button);
-
- button = gtk_button_new_from_icon_name ("object-rotate-right-symbolic",
- GTK_ICON_SIZE_BUTTON);
- gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
- "win.rotate-90");
- gtk_widget_set_tooltip_text (button,
- _("Rotate the image 90 degrees to the right"));
- gtk_style_context_add_class (gtk_widget_get_style_context (button),
- GTK_STYLE_CLASS_OSD);
- gtk_container_add (GTK_CONTAINER (bottomBox), button);
-
- gtk_container_add (GTK_CONTAINER (priv->bottom_revealer), bottomBox);
+ GtkWidget* bottomBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_style_context_add_class (gtk_widget_get_style_context (bottomBox),
+ GTK_STYLE_CLASS_LINKED);
+
+ button = gtk_button_new_from_icon_name ("object-rotate-left-symbolic",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
+ "win.rotate-270");
+ gtk_widget_set_tooltip_text (button,
+ _("Rotate the image 90 degrees to the left"));
+ gtk_style_context_add_class (gtk_widget_get_style_context (button),
+ GTK_STYLE_CLASS_OSD);
+
+ gtk_container_add (GTK_CONTAINER (bottomBox), button);
+
+ button = gtk_button_new_from_icon_name ("object-rotate-right-symbolic",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
+ "win.rotate-90");
+ gtk_widget_set_tooltip_text (button,
+ _("Rotate the image 90 degrees to the right"));
+ gtk_style_context_add_class (gtk_widget_get_style_context (button),
+ GTK_STYLE_CLASS_OSD);
+ gtk_container_add (GTK_CONTAINER (bottomBox), button);
+
+ gtk_container_add (GTK_CONTAINER (priv->bottom_revealer), bottomBox);
- /* Display overlay buttons on mouse movement */
- g_signal_connect (priv->display,
- "motion-notify-event",
- G_CALLBACK (_motion_notify_cb),
- view);
/* Don't hide overlay buttons when above */
- gtk_widget_add_events (GTK_WIDGET (priv->overlay),
- GDK_ENTER_NOTIFY_MASK);
- g_signal_connect (priv->overlay,
- "enter-notify-event",
- G_CALLBACK (_enter_overlay_event_cb),
- view);
+ gtk_widget_add_events (GTK_WIDGET (view),
+ GDK_ENTER_NOTIFY_MASK);
+ g_signal_connect (view,
+ "enter-notify-event",
+ G_CALLBACK (_enter_overlay_event_cb),
+ view);
}
static void
@@ -2379,21 +1406,6 @@ eog_scroll_view_dispose (GObject *object)
free_image_resources (view);
- if (priv->zoom_gesture) {
- g_object_unref (priv->zoom_gesture);
- priv->zoom_gesture = NULL;
- }
-
- if (priv->rotate_gesture) {
- g_object_unref (priv->rotate_gesture);
- priv->rotate_gesture = NULL;
- }
-
- if (priv->pan_gesture) {
- g_object_unref (priv->pan_gesture);
- priv->pan_gesture = NULL;
- }
-
G_OBJECT_CLASS (eog_scroll_view_parent_class)->dispose (object);
}
@@ -2435,9 +1447,6 @@ eog_scroll_view_get_property (GObject *object, guint property_id,
case PROP_TRANSPARENCY_STYLE:
g_value_set_enum (value, priv->transp_style);
break;
- case PROP_ZOOM_MODE:
- g_value_set_enum (value, priv->zoom_mode);
- break;
case PROP_ZOOM_MULTIPLIER:
g_value_set_double (value, priv->zoom_multiplier);
break;
@@ -2484,9 +1493,6 @@ eog_scroll_view_set_property (GObject *object, guint property_id,
case PROP_TRANSPARENCY_STYLE:
eog_scroll_view_set_transparency (view, g_value_get_enum (value));
break;
- case PROP_ZOOM_MODE:
- eog_scroll_view_set_zoom_mode (view, g_value_get_enum (value));
- break;
case PROP_ZOOM_MULTIPLIER:
eog_scroll_view_set_zoom_multiplier (view, g_value_get_double (value));
break;
@@ -2595,7 +1601,7 @@ eog_scroll_view_class_init (EogScrollViewClass *klass)
g_param_spec_boxed ("transparency-color", NULL, NULL,
GDK_TYPE_RGBA,
G_PARAM_WRITABLE | G_PARAM_STATIC_NAME));
-
+
/**
* EogScrollView:transparency-style:
*
@@ -2608,13 +1614,6 @@ eog_scroll_view_class_init (EogScrollViewClass *klass)
EOG_TRANSP_CHECKED,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
- g_object_class_install_property (
- gobject_class, PROP_ZOOM_MODE,
- g_param_spec_enum ("zoom-mode", NULL, NULL,
- EOG_TYPE_ZOOM_MODE,
- EOG_ZOOM_MODE_SHRINK_TO_FIT,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
-
view_signals [SIGNAL_ZOOM_CHANGED] =
g_signal_new ("zoom_changed",
EOG_TYPE_SCROLL_VIEW,
@@ -2651,7 +1650,6 @@ eog_scroll_view_class_init (EogScrollViewClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- widget_class->size_allocate = eog_scroll_view_size_allocate;
}
static void
@@ -2711,8 +1709,6 @@ eog_scroll_view_new (void)
widget = g_object_new (EOG_TYPE_SCROLL_VIEW,
"can-focus", TRUE,
- "row-homogeneous", FALSE,
- "column-homogeneous", FALSE,
NULL);
return widget;
@@ -2882,84 +1878,6 @@ eog_scroll_view_set_zoom_multiplier (EogScrollView *view,
g_object_notify (G_OBJECT (view), "zoom-multiplier");
}
-/* Helper to cause a redraw even if the zoom mode is unchanged */
-static void
-_set_zoom_mode_internal (EogScrollView *view, EogZoomMode mode)
-{
- gboolean notify = (mode != view->priv->zoom_mode);
-
-
- if (mode == EOG_ZOOM_MODE_SHRINK_TO_FIT)
- eog_scroll_view_zoom_fit (view);
- else
- view->priv->zoom_mode = mode;
-
- if (notify)
- g_object_notify (G_OBJECT (view), "zoom-mode");
-}
-
-
-void
-eog_scroll_view_set_zoom_mode (EogScrollView *view, EogZoomMode mode)
-{
- g_return_if_fail (EOG_IS_SCROLL_VIEW (view));
-
- if (view->priv->zoom_mode == mode)
- return;
-
- _set_zoom_mode_internal (view, mode);
-}
-
-EogZoomMode
-eog_scroll_view_get_zoom_mode (EogScrollView *view)
-{
- g_return_val_if_fail (EOG_IS_SCROLL_VIEW (view),
- EOG_ZOOM_MODE_SHRINK_TO_FIT);
-
- return view->priv->zoom_mode;
-}
-
-static gboolean
-eog_scroll_view_get_image_coords (EogScrollView *view, gint *x, gint *y,
- gint *width, gint *height)
-{
- EogScrollViewPrivate *priv = view->priv;
- GtkAllocation allocation;
- gint scaled_width, scaled_height, xofs, yofs;
-
- compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
-
- if (G_LIKELY (width))
- *width = scaled_width;
- if (G_LIKELY (height))
- *height = scaled_height;
-
- /* If only width and height are needed stop here. */
- if (x == NULL && y == NULL)
- return TRUE;
-
- gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);
-
- /* Compute image offsets with respect to the window */
-
- if (scaled_width <= allocation.width)
- xofs = (allocation.width - scaled_width) / 2;
- else
- xofs = -priv->xofs;
-
- if (scaled_height <= allocation.height)
- yofs = (allocation.height - scaled_height) / 2;
- else
- yofs = -priv->yofs;
-
- if (G_LIKELY (x))
- *x = xofs;
- if (G_LIKELY (y))
- *y = yofs;
-
- return TRUE;
-}
-
/**
* eog_scroll_view_event_is_over_image:
* @view: An #EogScrollView that has an image loaded.
@@ -2977,29 +1895,22 @@ gboolean
eog_scroll_view_event_is_over_image (EogScrollView *view, const GdkEvent *ev)
{
EogScrollViewPrivate *priv;
- GdkWindow *window;
gdouble evx, evy;
- gint x, y, width, height;
g_return_val_if_fail (EOG_IS_SCROLL_VIEW (view), FALSE);
g_return_val_if_fail (gtk_widget_get_realized(GTK_WIDGET(view)), FALSE);
g_return_val_if_fail (ev != NULL, FALSE);
priv = view->priv;
- window = gtk_widget_get_window (GTK_WIDGET (priv->display));
-
- if (G_UNLIKELY (priv->pixbuf == NULL
- || window != ((GdkEventAny*) ev)->window))
- return FALSE;
if (G_UNLIKELY (!gdk_event_get_coords (ev, &evx, &evy)))
return FALSE;
- if (!eog_scroll_view_get_image_coords (view, &x, &y, &width, &height))
- return FALSE;
+ /*if (!eog_scroll_view_get_image_coords (view, &x, &y, &width, &height))*/
+ /*return FALSE;*/
- if (evx < x || evy < y || evx > (x + width) || evy > (y + height))
- return FALSE;
+ /*if (evx < x || evy < y || evx > (x + width) || evy > (y + height))*/
+ /*return FALSE;*/
return TRUE;
}
diff --git a/src/eog-scroll-view.h b/src/eog-scroll-view.h
index 2b3c1da..3b958c8 100644
--- a/src/eog-scroll-view.h
+++ b/src/eog-scroll-view.h
@@ -18,13 +18,13 @@ typedef struct _EogScrollViewPrivate EogScrollViewPrivate;
struct _EogScrollView {
- GtkGrid base_instance;
+ GtkOverlay base_instance;
EogScrollViewPrivate *priv;
};
struct _EogScrollViewClass {
- GtkGridClass parent_class;
+ GtkOverlayClass parent_class;
void (* zoom_changed) (EogScrollView *view, double zoom);
void (* rotation_changed) (EogScrollView *view, double degrees);
@@ -47,21 +47,6 @@ typedef enum {
EOG_TRANSP_COLOR
} EogTransparencyStyle;
-/**
- * EogZoomMode:
- * @EOG_ZOOM_MODE_FREE: Use the currently set zoom factor to display the image
- * (see eog_scroll_view_set_zoom()).
- * @EOG_ZOOM_MODE_SHRINK_TO_FIT: If an image is to large for the window,
- * zoom out until the image is fully visible.
- * This will never zoom in on smaller images.
- *
- * Used to determine the zooming behaviour of an #EogScrollView.
- */
-typedef enum {
- EOG_ZOOM_MODE_FREE,
- EOG_ZOOM_MODE_SHRINK_TO_FIT
-} EogZoomMode;
-
GType eog_scroll_view_get_type (void) G_GNUC_CONST;
GtkWidget* eog_scroll_view_new (void);
@@ -74,8 +59,6 @@ EogImage* eog_scroll_view_get_image (EogScrollView *view);
void eog_scroll_view_set_scroll_wheel_zoom (EogScrollView *view, gboolean scroll_wheel_zoom);
void eog_scroll_view_set_zoom_upscale (EogScrollView *view, gboolean upscale);
void eog_scroll_view_set_zoom_multiplier (EogScrollView *view, gdouble multiplier);
-void eog_scroll_view_set_zoom_mode (EogScrollView *view, EogZoomMode mode);
-EogZoomMode eog_scroll_view_get_zoom_mode (EogScrollView *view);
void eog_scroll_view_set_antialiasing_in (EogScrollView *view, gboolean state);
void eog_scroll_view_set_antialiasing_out (EogScrollView *view, gboolean state);
void eog_scroll_view_set_transparency_color (EogScrollView *view, GdkRGBA *color);
diff --git a/src/eog-window.c b/src/eog-window.c
index eef981f..bd99cc3 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -225,11 +225,11 @@ static gboolean
_eog_zoom_shrink_to_boolean (GBinding *binding, const GValue *source,
GValue *target, gpointer user_data)
{
- EogZoomMode mode = g_value_get_enum (source);
- gboolean is_fit;
+ /*EogZoomMode mode = g_value_get_enum (source);*/
+ /*gboolean is_fit;*/
- is_fit = (mode == EOG_ZOOM_MODE_SHRINK_TO_FIT);
- g_value_set_variant (target, g_variant_new_boolean (is_fit));
+ /*is_fit = (mode == EOG_ZOOM_MODE_SHRINK_TO_FIT);*/
+ /*g_value_set_variant (target, g_variant_new_boolean (is_fit));*/
return TRUE;
}
@@ -3830,22 +3830,22 @@ eog_window_action_toggle_zoom_fit (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
- EogWindowPrivate *priv;
- EogZoomMode mode;
+ /*EogWindowPrivate *priv;*/
+ /*EogZoomMode mode;*/
- g_return_if_fail (EOG_IS_WINDOW (user_data));
+ /*g_return_if_fail (EOG_IS_WINDOW (user_data));*/
- eog_debug (DEBUG_WINDOW);
+ /*eog_debug (DEBUG_WINDOW);*/
- priv = EOG_WINDOW (user_data)->priv;
+ /*priv = EOG_WINDOW (user_data)->priv;*/
- mode = g_variant_get_boolean (state)
- ? EOG_ZOOM_MODE_SHRINK_TO_FIT : EOG_ZOOM_MODE_FREE;
+ /*mode = g_variant_get_boolean (state)*/
+ /*? EOG_ZOOM_MODE_SHRINK_TO_FIT : EOG_ZOOM_MODE_FREE;*/
- if (priv->view) {
- eog_scroll_view_set_zoom_mode (EOG_SCROLL_VIEW (priv->view),
- mode);
- }
+ /*if (priv->view) {*/
+ /*eog_scroll_view_set_zoom_mode (EOG_SCROLL_VIEW (priv->view),*/
+ /*mode);*/
+ /*}*/
}
static void
@@ -4226,8 +4226,8 @@ eog_window_zoom_button_toggled_cb (GtkToggleButton *button, gpointer user_data)
} else {
zoom_image = gtk_image_new_from_icon_name ("zoom-in-symbolic",
GTK_ICON_SIZE_BUTTON);
- eog_scroll_view_set_zoom_mode (EOG_SCROLL_VIEW (priv->view),
- EOG_ZOOM_MODE_SHRINK_TO_FIT);
+ /*eog_scroll_view_set_zoom_mode (EOG_SCROLL_VIEW (priv->view),*/
+ /*EOG_ZOOM_MODE_SHRINK_TO_FIT);*/
gtk_widget_set_tooltip_text (GTK_WIDGET (button),
_("Shrink or enlarge the current image"));
}
@@ -4420,12 +4420,13 @@ eog_window_construct_ui (EogWindow *window)
action = g_action_map_lookup_action (G_ACTION_MAP (window),
"toggle-zoom-fit");
if (action != NULL) {
- /* Binding will be destroyed when the objects finalize */
- g_object_bind_property_full (priv->view, "zoom-mode",
- action, "state",
- G_BINDING_SYNC_CREATE,
- _eog_zoom_shrink_to_boolean,
- NULL, NULL, NULL);
+ /*Binding will be destroyed when the objects finalize */
+ /* XXX WTF is that action even doing? */
+ /*g_object_bind_property_full (priv->view, "zoom-mode",*/
+ /*action, "state",*/
+ /*G_BINDING_SYNC_CREATE,*/
+ /*_eog_zoom_shrink_to_boolean,*/
+ /*NULL, NULL, NULL);*/
g_object_bind_property_full (action, "state",
zoom_button, "active",
G_BINDING_SYNC_CREATE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]