From ee5f63e50b1eeeac7ffafd755b249b3a056bd34c Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Wed, 26 Jan 2022 04:42:16 +0100 Subject: Adjust keyboard shortcuts --- fiv.c | 74 ++++++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/fiv.c b/fiv.c index 41aa7e5..f505e40 100644 --- a/fiv.c +++ b/fiv.c @@ -72,50 +72,62 @@ struct key_section { }; static struct key help_keys_general[] = { - {"F1 question", "Show this list of shortcuts"}, - {"F11 f", "Toggle fullscreen view"}, + {"F1", "Show help"}, + {"F10", "Open menu"}, + {"question", "Keyboard shortcuts"}, + {"q q", "Quit"}, + {"w", "Quit"}, + {} +}; + +static struct key help_keys_navigation[] = { + {"l", "Open location..."}, + {"n", "Open a new window"}, + {"Left", "Go back in history"}, + {"Right", "Go forward in history"}, + {} +}; + +static struct key help_keys_view[] = { + {"F11 f", "Toggle fullscreen"}, {"d", "Toggle dark theme variant"}, - {"q q", "Exit the program"}, - {"Escape w", "Exit the program"}, {} }; static struct key_group help_keys_browser[] = { {"General", help_keys_general}, + {"General: Navigation", help_keys_navigation}, + {"General: View", help_keys_view}, + {"Navigation", (struct key[]) { + {"Up", "Go to parent directory"}, + {"Home", "Go home"}, + {"Return", "Open selected item"}, + {} + }}, {"View", (struct key[]) { {"F9", "Toggle navigation sidebar"}, - {"F5 r r", "Refresh"}, + {"F5 r r", "Reload"}, {"h h", "Toggle hiding unsupported files"}, {"plus", "Larger thumbnails"}, {"minus", "Smaller thumbnails"}, {} }}, - {"Navigation", (struct key[]) { - {"l", "Open location..."}, - {"n", "Open a new window"}, - {"Left", "Go back in history"}, - {"Right", "Go forward in history"}, - {"Up", "Go to parent directory"}, - {"Home", "Go home"}, - {"Return", "Open selected item"}, - {} - }}, {} }; -static struct key_group help_keys_view[] = { +static struct key_group help_keys_viewer[] = { {"General", help_keys_general}, - {"View", (struct key[]) { - {"F8", "Toggle toolbar"}, - {"F5 r r", "Reload"}, - {} - }}, + {"General: Navigation", help_keys_navigation}, + {"General: View", help_keys_view}, {"Navigation", (struct key[]) { - {"l", "Open location..."}, - {"n", "Open a new window"}, {"Left Up Page_Up", "Previous image"}, {"Right Down Page_Down", "Next image"}, - {"Return Left", "Return to browser"}, + {"Escape Return", "Return to browser"}, + {} + }}, + {"View", (struct key[]) { + {"F8", "Toggle toolbar"}, + {"F5 r r", "Reload"}, {} }}, {"Zoom", (struct key[]) { @@ -165,7 +177,7 @@ static struct key_group help_keys_view[] = { static struct key_section help_keys[] = { {"Browser", "browser", help_keys_browser}, - {"View", "view", help_keys_view}, + {"Viewer", "viewer", help_keys_viewer}, {} }; @@ -1028,7 +1040,7 @@ show_help_shortcuts(void) g_object_set(window, "section-name", gtk_stack_get_visible_child(GTK_STACK(g.stack)) == g.view_box - ? "view" + ? "viewer" : "browser", NULL); gtk_widget_show(window); @@ -1069,7 +1081,10 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, fiv_sidebar_show_enter_location(FIV_SIDEBAR(g.browser_sidebar)); return TRUE; case GDK_KEY_n: - spawn_uri(g.directory); + if (gtk_stack_get_visible_child(GTK_STACK(g.stack)) == g.view_box) + spawn_uri(g.uri); + else + spawn_uri(g.directory); return TRUE; case GDK_KEY_o: on_open(); @@ -1109,7 +1124,6 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, break; case 0: switch (event->keyval) { - case GDK_KEY_Escape: case GDK_KEY_q: gtk_widget_destroy(g.window); return TRUE; @@ -1176,6 +1190,7 @@ on_key_press_view(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, on_next(); return TRUE; + case GDK_KEY_Escape: case GDK_KEY_Return: switch_to_browser(); fiv_browser_select(FIV_BROWSER(g.browser), g.uri); @@ -1218,6 +1233,9 @@ on_key_press_browser_paned(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, break; case 0: switch (event->keyval) { + case GDK_KEY_Escape: + fiv_browser_select(FIV_BROWSER(g.browser), NULL); + return TRUE; case GDK_KEY_h: gtk_button_clicked(GTK_BUTTON(g.funnel)); return TRUE; -- cgit v1.2.3-70-g09d2