Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra keybinding review of changes. #1638

Open
wants to merge 5 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions source/modes/filebrowser.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ static ModeMode file_browser_mode_result(Mode *sw, int mretv, char **input,
FileBrowserModePrivateData *pd =
(FileBrowserModePrivateData *)mode_get_private_data(sw);

/* bitwise-and allows for multiple MENU_ values to be stored in one
value, and then decoded out into seperate values within the relevant
mode file
e.g. mretv == MENU_CUSTOM_INPUT means selecting a directory,
mretv == MENU_CUSTOM_INPUT | MENU_CUSTOM_ACTION results in
going up to parent directory thanks to special_command bool */
gboolean special_command =
((mretv & MENU_CUSTOM_ACTION) == MENU_CUSTOM_ACTION);
if (mretv & MENU_NEXT) {
Expand Down Expand Up @@ -473,22 +479,36 @@ static ModeMode file_browser_mode_result(Mode *sw, int mretv, char **input,
}
}
retv = RELOAD_DIALOG;
} else if ((mretv & MENU_CUSTOM_INPUT) && *input) {
char *p = rofi_expand_path(*input);
char *dir = g_filename_from_utf8(p, -1, NULL, NULL, NULL);
g_free(p);
if (g_file_test(dir, G_FILE_TEST_EXISTS)) {
if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
} else if ((mretv & MENU_CUSTOM_INPUT)) {
// go up to parent directory
if (special_command) {
GFile *new = g_file_get_parent(pd->current_dir);
if (new) {
g_object_unref(pd->current_dir);
pd->current_dir = g_file_new_for_path(dir);
g_free(dir);
pd->current_dir = new;
free_list(pd);
get_file_browser(sw);
return RESET_DIALOG;
}
return RESET_DIALOG;
}
// else, if text field has valid pathname, select it
if (*input) {
char *p = rofi_expand_path(*input);
char *dir = g_filename_from_utf8(p, -1, NULL, NULL, NULL);
g_free(p);
if (g_file_test(dir, G_FILE_TEST_EXISTS)) {
if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
g_object_unref(pd->current_dir);
pd->current_dir = g_file_new_for_path(dir);
g_free(dir);
free_list(pd);
get_file_browser(sw);
return RESET_DIALOG;
}
}
g_free(dir);
retv = RELOAD_DIALOG;
}
g_free(dir);
retv = RELOAD_DIALOG;
} else if ((mretv & MENU_ENTRY_DELETE) == MENU_ENTRY_DELETE) {
retv = RELOAD_DIALOG;
}
Expand Down
1 change: 0 additions & 1 deletion source/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,6 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
// Nothing entered and nothing selected.
state->retv = MENU_CUSTOM_INPUT;
}

state->quit = TRUE;
break;
}
Expand Down