Make scaling accessible from the keyboard

This commit is contained in:
Přemysl Eric Janouch 2021-11-13 09:50:04 +01:00
parent 73dd5bf1a0
commit a1db89d91c
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -169,6 +169,8 @@ fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
return TRUE; return TRUE;
} }
#define SCALE_STEP 1.4
static gboolean static gboolean
fastiv_view_scroll_event(GtkWidget *widget, GdkEventScroll *event) fastiv_view_scroll_event(GtkWidget *widget, GdkEventScroll *event)
{ {
@ -178,11 +180,11 @@ fastiv_view_scroll_event(GtkWidget *widget, GdkEventScroll *event)
switch (event->direction) { switch (event->direction) {
case GDK_SCROLL_UP: case GDK_SCROLL_UP:
self->scale *= 1.4; self->scale *= SCALE_STEP;
gtk_widget_queue_resize(widget); gtk_widget_queue_resize(widget);
return TRUE; return TRUE;
case GDK_SCROLL_DOWN: case GDK_SCROLL_DOWN:
self->scale /= 1.4; self->scale /= SCALE_STEP;
gtk_widget_queue_resize(widget); gtk_widget_queue_resize(widget);
return TRUE; return TRUE;
default: default:
@ -202,6 +204,14 @@ fastiv_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
self->scale = 1; self->scale = 1;
gtk_widget_queue_resize(widget); gtk_widget_queue_resize(widget);
return TRUE; return TRUE;
case GDK_KEY_plus:
self->scale *= SCALE_STEP;
gtk_widget_queue_resize(widget);
return TRUE;
case GDK_KEY_minus:
self->scale /= SCALE_STEP;
gtk_widget_queue_resize(widget);
return TRUE;
} }
return FALSE; return FALSE;
} }