From 02f7a54e67260ee7995c6cd9bf40ae784b60203d Mon Sep 17 00:00:00 2001 From: nirav Date: Wed, 5 Sep 2018 00:35:24 +0530 Subject: Added image panning support, refactoring --- image.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'image.c') diff --git a/image.c b/image.c index 5489259..17a2093 100644 --- a/image.c +++ b/image.c @@ -1,4 +1,5 @@ #include "image.h" +#include "window.h" #include GtkWidget *new_image() @@ -7,9 +8,8 @@ GtkWidget *new_image() return image; } -int load_image(char *file_name, int win_width, int win_height) +int load_image(char *file_name) { - printf("loading: %s\n", file_name); GError *error = NULL; if (pixbuf != NULL) g_object_unref(pixbuf); @@ -21,7 +21,7 @@ int load_image(char *file_name, int win_width, int win_height) gdk_pixbuf_get_height(GDK_PIXBUF(pixbuf)); aspect_ratio = (double)pixbuf_width / (double)pixbuf_height; curr_zoom = 1.0; - fit_image(win_width, win_height); + fit_image(); return 1; } @@ -37,8 +37,11 @@ void update_pixbuf() gtk_image_set_from_pixbuf(GTK_IMAGE(image), GDK_PIXBUF(curr_pixbuf)); } -void fit_image(int win_width, int win_height) +void fit_image() { + gint win_width, win_height; + get_curr_win_size(&win_width, &win_height); + curr_scale_mod = fit; if (pixbuf == NULL || win_width < 1 || win_height < 1) return; if (win_width < pixbuf_width && win_height > pixbuf_height) { @@ -69,6 +72,7 @@ void fit_image(int win_width, int win_height) void zoom(int type) { + curr_scale_mod = zoomed; if (pixbuf == NULL) return; if (type == 0) { -- cgit v1.2.3