move confirm delete prompt to misc.c

Change-Id: Iadb1c7199caa5070f555eb4d329efb02e3193289
This commit is contained in:
William Wilgus 2022-11-24 23:09:26 -05:00
parent 3a22322ab7
commit 71934d4c16
5 changed files with 14 additions and 22 deletions

View file

@ -831,17 +831,7 @@ static int select_bookmark(const char* bookmark_file_name,
case ACTION_BMS_DELETE:
if (item >= 0)
{
const char *lines[]={
ID2P(LANG_REALLY_DELETE)
};
const char *yes_lines[]={
ID2P(LANG_DELETING)
};
const struct text_message message={lines, 1};
const struct text_message yes_message={yes_lines, 1};
if(gui_syncyesno_run(&message, &yes_message, NULL)==YESNO_YES)
if (confirm_delete_yesno("") == YESNO_YES)
{
delete_bookmark(bookmark_file_name, item);
bookmarks->reload = true;

View file

@ -1133,6 +1133,14 @@ int read_line(int fd, char* buffer, int buffer_size)
return rdbufend >= 0 ? num_read : -1;
}
int confirm_delete_yesno(const char *name)
{
const char *lines[] = { ID2P(LANG_REALLY_DELETE), name };
const char *yes_lines[] = { ID2P(LANG_DELETING), name };
const struct text_message message = { lines, 2 };
const struct text_message yes_message = { yes_lines, 2 };
return gui_syncyesno_run(&message, &yes_message, NULL);
}
char* skip_whitespace(char* const str)
{

View file

@ -143,6 +143,8 @@ void setvol(void);
int hex_to_rgb(const char* hex, int* color);
#endif
int confirm_delete_yesno(const char *name);
char* strrsplt(char* str, int c);
char* skip_whitespace(char* const str);

View file

@ -63,6 +63,7 @@
#include "viewport.h"
#include "pathfuncs.h"
#include "shortcuts.h"
#include "misc.h"
static int context;
static const char *selected_file = NULL;
@ -898,15 +899,6 @@ static int confirm_overwrite(void)
return gui_syncyesno_run(&message, NULL, NULL);
}
static int confirm_delete(const char *file)
{
const char *lines[] = { ID2P(LANG_REALLY_DELETE), file };
const char *yes_lines[] = { ID2P(LANG_DELETING), file };
const struct text_message message = { lines, 2 };
const struct text_message yes_message = { yes_lines, 2 };
return gui_syncyesno_run(&message, &yes_message, NULL);
}
static bool check_new_name(const char *basename)
{
/* at least prevent escapes out of the base directory from keyboard-
@ -1001,7 +993,7 @@ static int delete_file_dir(void)
{
const char *to_delete=selected_file;
const int to_delete_attr=selected_file_attr;
if (confirm_delete(to_delete) != YESNO_YES) {
if (confirm_delete_yesno(to_delete) != YESNO_YES) {
return 1;
}

View file

@ -454,7 +454,7 @@ static int shortcut_menu_get_action(int action, struct gui_synclist *lists)
{
int selection = gui_synclist_get_sel_pos(lists);
if (!yesno_pop(ID2P(LANG_REALLY_DELETE)))
if (confirm_delete_yesno("") != YESNO_YES)
{
gui_synclist_set_title(lists, lists->title, lists->title_icon);
return ACTION_REDRAW;