[filebrowser] Add option to return 1 on cancel.

Fixes: #1732
This commit is contained in:
Dave Davenport 2023-01-06 11:54:43 +01:00
parent d786129fd1
commit 5a29565fc8
3 changed files with 33 additions and 2 deletions

View File

@ -1155,12 +1155,26 @@ configuration {
directories-first: true;
/** Show hidden files. */
show-hidden: false;
/** return 1 on cancel. */
cancel-returns-1: true;
}
}
.fi
.RE
.PP
These options can also be passed on the commandline, for example:
.PP
.RS
.nf
rofi -filebrowser-cancel-returns-1 true -show filebrowser
.fi
.RE
.PP
The \fB\fCshow-hidden\fR can also be triggered with the \fB\fCkb-delete-entry\fR keybinding.

View File

@ -710,10 +710,18 @@ configuration {
directories-first: true;
/** Show hidden files. */
show-hidden: false;
/** return 1 on cancel. */
cancel-returns-1: true;
}
}
```
These options can also be passed on the commandline, for example:
```bash
rofi -filebrowser-cancel-returns-1 true -show filebrowser
```
The `show-hidden` can also be triggered with the `kb-delete-entry` keybinding.
### Other

View File

@ -374,12 +374,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);
@ -450,6 +450,15 @@ static ModeMode file_browser_mode_result(Mode *sw, int mretv, char **input,
FileBrowserModePrivateData *pd =
(FileBrowserModePrivateData *)mode_get_private_data(sw);
if ((mretv & MENU_CANCEL) == MENU_CANCEL) {
ThemeWidget *wid = rofi_config_find_widget(sw->name, NULL, TRUE);
Property *p =
rofi_theme_find_property(wid, P_BOOLEAN, "cancel-returns-1", TRUE);
if (p && p->type == P_BOOLEAN && p->value.b == TRUE) {
rofi_set_return_code(1);
}
return MODE_EXIT;
}
gboolean special_command =
((mretv & MENU_CUSTOM_ACTION) == MENU_CUSTOM_ACTION);
if (mretv & MENU_NEXT) {