Commit 93e2edf4 authored by Moritz Lipp's avatar Moritz Lipp
Browse files

sc_scroll

parent 55eaca8e
......@@ -62,7 +62,6 @@ config_load_default(void)
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_f, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_b, NULL, sc_scroll, NORMAL, FULL_UP, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_space, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "%", sc_scroll, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_n, NULL, sc_search, NORMAL, FORWARD, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_N, NULL, sc_search, NORMAL, BACKWARD, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_0, NULL, sc_switch_goto_mode, NORMAL, 0, NULL);
......
......@@ -111,6 +111,52 @@ sc_rotate(girara_session_t* session, girara_argument_t* argument)
bool
sc_scroll(girara_session_t* session, girara_argument_t* argument)
{
GtkAdjustment* adjustment = NULL;
if( (argument->n == LEFT) || (argument->n == RIGHT) )
adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view));
else
adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.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;
gdouble scroll_step = 40;
gdouble new_value;
switch(argument->n)
{
case FULL_UP:
new_value = (value - view_size) < 0 ? 0 : (value - view_size);
break;
case FULL_DOWN:
new_value = (value + view_size) > max ? max : (value + view_size);
break;
case HALF_UP:
new_value = (value - (view_size / 2)) < 0 ? 0 : (value - (view_size / 2));
break;
case HALF_DOWN:
new_value = (value + (view_size / 2)) > max ? max : (value + (view_size / 2));
break;
case LEFT:
case UP:
new_value = (value - scroll_step) < 0 ? 0 : (value - scroll_step);
break;
case RIGHT:
case DOWN:
new_value = (value + scroll_step) > max ? max : (value + scroll_step);
break;
case TOP:
new_value = 0;
break;
case BOTTOM:
new_value = max;
break;
default:
new_value = 0;
}
gtk_adjustment_set_value(adjustment, new_value);
return false;
}
......
Supports Markdown
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