Add more key bindings
This commit is contained in:
parent
cfe3dc55c6
commit
1db233648f
@ -551,19 +551,44 @@ static gboolean
|
|||||||
fastiv_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
|
fastiv_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
|
||||||
{
|
{
|
||||||
FastivView *self = FASTIV_VIEW(widget);
|
FastivView *self = FASTIV_VIEW(widget);
|
||||||
if (event->state & ~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask())
|
|
||||||
return FALSE;
|
|
||||||
if (!self->image)
|
if (!self->image)
|
||||||
return FALSE;
|
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) {
|
switch (event->keyval) {
|
||||||
case GDK_KEY_1:
|
case GDK_KEY_0:
|
||||||
return set_scale(self, 1.0);
|
return set_scale(self, 1.0);
|
||||||
case GDK_KEY_plus:
|
case GDK_KEY_plus:
|
||||||
return set_scale(self, self->scale * SCALE_STEP);
|
return set_scale(self, self->scale * SCALE_STEP);
|
||||||
case GDK_KEY_minus:
|
case GDK_KEY_minus:
|
||||||
return set_scale(self, self->scale / SCALE_STEP);
|
return set_scale(self, self->scale / SCALE_STEP);
|
||||||
case GDK_KEY_F:
|
}
|
||||||
|
}
|
||||||
|
if (state != 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
switch (event->keyval) {
|
||||||
|
case GDK_KEY_1:
|
||||||
|
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_x: // Inspired by gThumb.
|
||||||
return set_scale_to_fit(self, !self->scale_to_fit);
|
return set_scale_to_fit(self, !self->scale_to_fit);
|
||||||
|
|
||||||
case GDK_KEY_i:
|
case GDK_KEY_i:
|
||||||
|
4
fastiv.c
4
fastiv.c
@ -423,6 +423,10 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
|
|||||||
case GDK_KEY_n:
|
case GDK_KEY_n:
|
||||||
spawn_path(g.directory);
|
spawn_path(g.directory);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
case GDK_KEY_q:
|
||||||
|
case GDK_KEY_w:
|
||||||
|
gtk_widget_destroy(g.window);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user