aboutsummaryrefslogtreecommitdiff
path: root/fastiv-view.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-11-29 22:44:51 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-11-29 22:45:36 +0100
commit1db233648fee07903f030adb4c94d8d76d4c3f8b (patch)
tree07d77d99b797d6b1f228eb973983186cc0d6f0b5 /fastiv-view.c
parentcfe3dc55c6e1133b0fbe342e63965aec2437a7c3 (diff)
downloadfiv-1db233648fee07903f030adb4c94d8d76d4c3f8b.tar.gz
fiv-1db233648fee07903f030adb4c94d8d76d4c3f8b.tar.xz
fiv-1db233648fee07903f030adb4c94d8d76d4c3f8b.zip
Add more key bindings
Diffstat (limited to 'fastiv-view.c')
-rw-r--r--fastiv-view.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/fastiv-view.c b/fastiv-view.c
index 3b845e4..bd00f82 100644
--- a/fastiv-view.c
+++ b/fastiv-view.c
@@ -551,19 +551,44 @@ static gboolean
fastiv_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
{
FastivView *self = FASTIV_VIEW(widget);
- if (event->state & ~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask())
- return FALSE;
if (!self->image)
return FALSE;
+ // It should not matter that GDK_KEY_plus involves holding Shift.
+ guint state = event->state & gtk_accelerator_get_default_mod_mask() &
+ ~GDK_SHIFT_MASK;
+
+ // The standard, intuitive bindings.
+ if (state == GDK_CONTROL_MASK) {
+ switch (event->keyval) {
+ case GDK_KEY_0:
+ return set_scale(self, 1.0);
+ case GDK_KEY_plus:
+ return set_scale(self, self->scale * SCALE_STEP);
+ case GDK_KEY_minus:
+ return set_scale(self, self->scale / SCALE_STEP);
+ }
+ }
+ if (state != 0)
+ return FALSE;
+
switch (event->keyval) {
case GDK_KEY_1:
- return set_scale(self, 1.0);
+ case GDK_KEY_2:
+ case GDK_KEY_3:
+ case GDK_KEY_4:
+ case GDK_KEY_5:
+ case GDK_KEY_6:
+ case GDK_KEY_7:
+ case GDK_KEY_8:
+ case GDK_KEY_9:
+ return set_scale(self, event->keyval - GDK_KEY_0);
case GDK_KEY_plus:
return set_scale(self, self->scale * SCALE_STEP);
case GDK_KEY_minus:
return set_scale(self, self->scale / SCALE_STEP);
- case GDK_KEY_F:
+
+ case GDK_KEY_x: // Inspired by gThumb.
return set_scale_to_fit(self, !self->scale_to_fit);
case GDK_KEY_i: