From c32c6f5ad024cf4ca396b867d82693501e341659 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 9 Mar 2010 19:14:19 +0100 Subject: Implemented zoom buttons. --- window_main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'window_main.c') diff --git a/window_main.c b/window_main.c index ff5200f..bd1de4f 100644 --- a/window_main.c +++ b/window_main.c @@ -27,6 +27,7 @@ gboolean layout_dragging = FALSE; gdouble layout_dragx, layout_dragy; enum zoom_mode_t zoom_mode = ZOOM_BESTFIT; +gdouble zoom_factor = 1.0; GtkWindow *window; GtkImage *image = NULL; @@ -186,8 +187,21 @@ static void set_image_pixbuf() { set_image_pixbuf_resized(pb, win_width, win_height, width, height, ratio); g_object_unref(pb); - } else if(zoom_mode == ZOOM_NORMAL || zoom_mode == ZOOM_CUSTOM) { + } else if(zoom_mode == ZOOM_NORMAL) { set_image_pixbuf_normal(orig_pixbuf, win_width, win_height, gdk_pixbuf_get_width(orig_pixbuf), gdk_pixbuf_get_height(orig_pixbuf)); + } else if(zoom_mode == ZOOM_CUSTOM) { + pb = zoom_pixbuf(orig_pixbuf, zoom_factor); + if(!pb) + return; + + width = gdk_pixbuf_get_width(pb); + height = gdk_pixbuf_get_height(pb); + + set_image_pixbuf_normal(pb, win_width, win_height, width, height); + + set_resize_msg(zoom_factor); + + g_object_unref(pb); } } @@ -921,6 +935,18 @@ void on_zoom_mode_toggled(GtkToggleToolButton *toolbutton, gpointer user_data) { } } +void on_zoom_in_clicked(GtkToolButton *toolbutton, gpointer user_data) { + zoom_mode = ZOOM_CUSTOM; + zoom_factor *= 1.25; + set_image_pixbuf(); +} + +void on_zoom_out_clicked(GtkToolButton *toolbutton, gpointer user_data) { + zoom_mode = ZOOM_CUSTOM; + zoom_factor *= .80; + set_image_pixbuf(); +} + gboolean on_layout_button_press_event(GtkWindow *widget, GdkEventButton *event, gpointer user_data) { GtkAdjustment *hadj, *vadj; -- cgit v1.2.3