Commit e4792cb2 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Remove duplicate code

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 7585888e
...@@ -137,60 +137,54 @@ cb_view_vadjustment_value_changed(GtkAdjustment* adjustment, gpointer data) ...@@ -137,60 +137,54 @@ cb_view_vadjustment_value_changed(GtkAdjustment* adjustment, gpointer data)
statusbar_page_number_update(zathura); statusbar_page_number_update(zathura);
} }
void static void
cb_view_hadjustment_changed(GtkAdjustment* adjustment, gpointer data) cb_view_adjustment_changed(GtkAdjustment* adjustment, zathura_t* zathura,
bool width)
{ {
zathura_t* zathura = data;
g_return_if_fail(zathura != NULL);
zathura_adjust_mode_t adjust_mode =
zathura_document_get_adjust_mode(zathura->document);
/* Do nothing in index mode */ /* Do nothing in index mode */
if (girara_mode_get(zathura->ui.session) == zathura->modes.index) { if (girara_mode_get(zathura->ui.session) == zathura->modes.index) {
return; return;
} }
/* Don't scroll we're focusing the inputbar. */ const zathura_adjust_mode_t adjust_mode =
zathura_document_get_adjust_mode(zathura->document);
/* Don't scroll, we're focusing the inputbar. */
if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) { if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) {
return; return;
} }
/* save the viewport size */ /* Save the viewport size */
unsigned int view_width = (unsigned int)floor(gtk_adjustment_get_page_size(adjustment)); unsigned int size = (unsigned int)floor(gtk_adjustment_get_page_size(adjustment));
zathura_document_set_viewport_width(zathura->document, view_width); if (width == true) {
zathura_document_set_viewport_width(zathura->document, size);
} else {
zathura_document_set_viewport_height(zathura->document, size);
}
/* reset the adjustment, in case bounds have changed */ /* reset the adjustment, in case bounds have changed */
double ratio = zathura_document_get_position_x(zathura->document); const double ratio = width == true ?
zathura_document_get_position_x(zathura->document) :
zathura_document_get_position_x(zathura->document);
zathura_adjustment_set_value_from_ratio(adjustment, ratio); zathura_adjustment_set_value_from_ratio(adjustment, ratio);
} }
void void
cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data) cb_view_hadjustment_changed(GtkAdjustment* adjustment, gpointer data)
{ {
zathura_t* zathura = data; zathura_t* zathura = data;
g_return_if_fail(zathura != NULL); g_return_if_fail(zathura != NULL);
zathura_adjust_mode_t adjust_mode = cb_view_adjustment_changed(adjustment, zathura, true);
zathura_document_get_adjust_mode(zathura->document); }
/* Do nothing in index mode */
if (girara_mode_get(zathura->ui.session) == zathura->modes.index) {
return;
}
/* Don't scroll we're focusing the inputbar. */
if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) {
return;
}
/* save the viewport size */ void
unsigned int view_height = (unsigned int)floor(gtk_adjustment_get_page_size(adjustment)); cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data)
zathura_document_set_viewport_height(zathura->document, view_height); {
zathura_t* zathura = data;
g_return_if_fail(zathura != NULL);
/* reset the adjustment, in case bounds have changed */ cb_view_adjustment_changed(adjustment, zathura, false);
double ratio = zathura_document_get_position_y(zathura->document);
zathura_adjustment_set_value_from_ratio(adjustment, ratio);
} }
void void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment