From 2c0e28e8778af86952a4d9abf26cb49e6b996397 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Wed, 30 Dec 2009 00:21:29 +0100 Subject: [PATCH] Added scrolling --- config.def.h | 1 + zathura.c | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index bdf411c..e087209 100644 --- a/config.def.h +++ b/config.def.h @@ -4,6 +4,7 @@ static const int DEFAULT_HEIGHT = 600; static const float ZOOM_STEP = 10; static const float ZOOM_MIN = 10; static const float ZOOM_MAX = 400; +static const float SCROLL_STEP = 40; /* completion */ static const char FORMAT_COMMAND[] = "%s"; diff --git a/zathura.c b/zathura.c index 2bebf06..6c5cc28 100644 --- a/zathura.c +++ b/zathura.c @@ -661,7 +661,25 @@ sc_rotate(Argument* argument) void sc_scroll(Argument* argument) { + GtkAdjustment* adjustment; + if( (argument->n == LEFT) || (argument->n == RIGHT) ) + adjustment = gtk_scrolled_window_get_hadjustment(Zathura.UI.view); + else + adjustment = gtk_scrolled_window_get_vadjustment(Zathura.UI.view); + + gdouble view_size = gtk_adjustment_get_page_size(adjustment); + gdouble value = gtk_adjustment_get_value(adjustment); + gdouble max = gtk_adjustment_get_upper(adjustment) - view_size; + + if( (argument->n == LEFT) || (argument->n == DOWN)) + gtk_adjustment_set_value(adjustment, (value - SCROLL_STEP) < 0 ? 0 : (value - SCROLL_STEP)); + else if (argument->n == TOP) + gtk_adjustment_set_value(adjustment, 0); + else if(argument->n == BOTTOM) + gtk_adjustment_set_value(adjustment, max); + else + gtk_adjustment_set_value(adjustment, (value + SCROLL_STEP) > max ? max : (value + SCROLL_STEP)); } void @@ -1251,9 +1269,11 @@ cb_destroy(GtkWidget* widget, gpointer data) gboolean cb_draw(GtkWidget* widget, gpointer data) { - intptr_t t = (intptr_t) t; - int page_id = (int) t; -printf("%d\n", page_id); + intptr_t t = (intptr_t) data; + int page_id = (int) (t << 32); + + printf("%d\n", page_id); + if(page_id < 0 || page_id > Zathura.PDF.number_of_pages) return FALSE;