diff --git a/shortcuts.c b/shortcuts.c index 72acb44..1758bcc 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -94,14 +94,7 @@ sc_goto(girara_session_t* session, girara_argument_t* argument, unsigned int t) return true; } - unsigned int number_of_pages = zathura->document->number_of_pages; - - if (t > 0 && t <= number_of_pages) { - // TODO: Calculate offset - /*GtkAdjustment* adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->UI.session->gtk.view));*/ - /*unsigned int offset = zathura->document->pages[t - 1]->offset * zathura->document->scale;*/ - /*gtk_adjustment_set_value(adjustment, offset);*/ - } + page_set(zathura, t - 1); } return false; diff --git a/zathura.c b/zathura.c index 76c78fd..70037df 100644 --- a/zathura.c +++ b/zathura.c @@ -313,8 +313,15 @@ page_set(zathura_t* zathura, unsigned int page_id) goto error_out; } + page_offset_t* offset = page_calculate_offset(page); + if (offset == NULL) { + goto error_out; + } + GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); - cb_view_vadjustment_value_changed(view_vadjustment, zathura); + GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); + gtk_adjustment_set_value(view_hadjustment, offset->x); + gtk_adjustment_set_value(view_vadjustment, offset->y); /* update page number */ zathura->document->current_page_number = page_id;