diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-03-31 23:18:47 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-04-05 00:09:53 +0200 |
commit | c64686480500cbcd744f029f4bd5bd5d3003e989 (patch) | |
tree | 0fd670bae40b5266aa7cf43801ecaf1b5057b84e /fiv.c | |
parent | c2196df141017872fd8480de4bc8e6a8b6a6a95b (diff) | |
download | fiv-c64686480500cbcd744f029f4bd5bd5d3003e989.tar.gz fiv-c64686480500cbcd744f029f4bd5bd5d3003e989.tar.xz fiv-c64686480500cbcd744f029f4bd5bd5d3003e989.zip |
Add directory tree traversal functionality
Thus far merely bound to the [ and ] keys in the browser.
Diffstat (limited to 'fiv.c')
-rw-r--r-- | fiv.c | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -120,8 +120,10 @@ static struct key_group help_keys_browser[] = { {"General: Navigation", help_keys_navigation}, {"General: View", help_keys_view}, {"Navigation", (struct key[]) { - {"<Alt>Up", "Go to parent directory"}, {"<Alt>Home", "Go home"}, + {"<Alt>Up", "Go to parent directory"}, + {"bracketleft", "Go to previous directory in tree"}, + {"bracketright", "Go to next directory in tree"}, {"Return", "Open selected item"}, {"<Alt>Return", "Show file information"}, {} @@ -1089,6 +1091,30 @@ on_view_drag_data_received(G_GNUC_UNUSED GtkWidget *widget, } static void +on_dir_previous(void) +{ + GFile *directory = fiv_io_model_get_previous_directory(g.model); + if (directory) { + gchar *uri = g_file_get_uri(directory); + g_object_unref(directory); + load_directory(uri); + g_free(uri); + } +} + +static void +on_dir_next(void) +{ + GFile *directory = fiv_io_model_get_next_directory(g.model); + if (directory) { + gchar *uri = g_file_get_uri(directory); + g_object_unref(directory); + load_directory(uri); + g_free(uri); + } +} + +static void on_toolbar_zoom(G_GNUC_UNUSED GtkButton *button, gpointer user_data) { FivThumbnailSize size = FIV_THUMBNAIL_SIZE_COUNT; @@ -1422,6 +1448,13 @@ on_key_press_browser_paned(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, !gtk_widget_is_visible(g.browser_sidebar)); return TRUE; + case GDK_KEY_bracketleft: + on_dir_previous(); + return TRUE; + case GDK_KEY_bracketright: + on_dir_next(); + return TRUE; + case GDK_KEY_Escape: fiv_browser_select(FIV_BROWSER(g.browser), NULL); return TRUE; |