diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-11-13 09:40:10 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-11-13 09:41:37 +0100 |
commit | 73dd5bf1a08c0c6ca1d1312e4e966267a1afda08 (patch) | |
tree | dbb23b9b1fda8217b67f71f07521d76613c225e2 /fastiv.c | |
parent | 7dba21c6d885605dd83fb1bea828b0c5e723b0d1 (diff) | |
download | fiv-73dd5bf1a08c0c6ca1d1312e4e966267a1afda08.tar.gz fiv-73dd5bf1a08c0c6ca1d1312e4e966267a1afda08.tar.xz fiv-73dd5bf1a08c0c6ca1d1312e4e966267a1afda08.zip |
Improve key handling
Iteration should be limited to the view.
g_signal_connect_after() did not work as I hoped it would.
Diffstat (limited to 'fastiv.c')
-rw-r--r-- | fastiv.c | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -280,6 +280,26 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, on_open(); return TRUE; + case GDK_KEY_Tab: + case GDK_KEY_Return: + gtk_stack_set_visible_child(GTK_STACK(g.stack), + gtk_stack_get_visible_child(GTK_STACK(g.stack)) == + g.view_scroller + ? g.browser_scroller + : g.view_scroller); + return TRUE; + } + } + return FALSE; +} + +static gboolean +on_key_press_view(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, + G_GNUC_UNUSED gpointer data) +{ + switch (event->state & gtk_accelerator_get_default_mod_mask()) { + case 0: + switch (event->keyval) { case GDK_KEY_Left: case GDK_KEY_Up: case GDK_KEY_Page_Up: @@ -292,15 +312,6 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, case GDK_KEY_space: on_next(); return TRUE; - - case GDK_KEY_Tab: - case GDK_KEY_Return: - gtk_stack_set_visible_child(GTK_STACK(g.stack), - gtk_stack_get_visible_child(GTK_STACK(g.stack)) == - g.view_scroller - ? g.browser_scroller - : g.view_scroller); - return TRUE; } } return FALSE; @@ -364,6 +375,8 @@ main(int argc, char *argv[]) g.view = g_object_new(FASTIV_TYPE_VIEW, NULL); gtk_widget_set_vexpand(g.view, TRUE); gtk_widget_set_hexpand(g.view, TRUE); + g_signal_connect(g.view, "key-press-event", + G_CALLBACK(on_key_press_view), NULL); gtk_container_add(GTK_CONTAINER(g.view_scroller), g.view); gtk_widget_show_all(g.view_scroller); |