From c1a540c57e19acacb9a1e436da8cc794c4437157 Mon Sep 17 00:00:00 2001 From: Dimitris Triantafyllidis <39795232+dimitris-triantafyllidis@users.noreply.github.com> Date: Tue, 11 Oct 2022 17:04:18 +0300 Subject: [PATCH] [filebrowser] Add an option to show hidden files. (#1716) Add an option to show hidden files by looking up the "show-hidden" filebrowser property and modifying the relevant logic in "filebrowser.c". Co-authored-by: Dave Davenport --- doc/rofi.1 | 2 ++ doc/rofi.1.markdown | 2 ++ source/modes/filebrowser.c | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/rofi.1 b/doc/rofi.1 index 6f4ca817..865510fa 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1137,6 +1137,8 @@ configuration { sorting\-method: "name"; /** Group directories before files. */ directories\-first: true; + /** Show hidden files. */ + show-hidden: false; } } diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 9cff8e6c..976ca5b5 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -691,6 +691,8 @@ configuration { sorting-method: "name"; /** Group directories before files. */ directories-first: true; + /** Show hidden files. */ + show-hidden: false; } } ``` diff --git a/source/modes/filebrowser.c b/source/modes/filebrowser.c index dc793da6..03141777 100644 --- a/source/modes/filebrowser.c +++ b/source/modes/filebrowser.c @@ -112,10 +112,13 @@ struct { enum FBSortingTime sorting_time; /** If we want to display directories above files. */ gboolean directories_first; + /** If we want to show hidden files. */ + gboolean show_hidden; } file_browser_config = { .sorting_method = FB_SORT_NAME, .sorting_time = FB_MTIME, .directories_first = TRUE, + .show_hidden = FALSE, }; static void free_list(FileBrowserModePrivateData *pd) { @@ -247,7 +250,10 @@ static void get_file_browser(Mode *sw) { pd->array_length++; continue; } - if (rd->d_name[0] == '.') { + if (g_strcmp0(rd->d_name, ".") == 0) { + continue; + } + if (rd->d_name[0] == '.' && file_browser_config.show_hidden == FALSE) { continue; } @@ -367,7 +373,12 @@ static void file_browser_mode_init_config(Mode *sw) { if (p != NULL && p->type == P_BOOLEAN) { file_browser_config.directories_first = p->value.b; } - + + p = rofi_theme_find_property(wid, P_BOOLEAN, "show-hidden", TRUE); + if (p != NULL && p->type == P_BOOLEAN) { + file_browser_config.show_hidden = p->value.b; + } + if (found_error) { rofi_view_error_dialog(msg, FALSE);