summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-11-24 23:09:26 -0500
committerWilliam Wilgus <wilgus.william@gmail.com>2022-11-24 23:09:26 -0500
commit71934d4c16fa1925833ef6e65ccb33b358398bd0 (patch)
treed8d6db20acaf15473b7aa2607a46e56fb07d4085
parent3a22322ab77d38af3bea611f9dbb8f65b309d547 (diff)
downloadrockbox-71934d4c16.tar.gz
rockbox-71934d4c16.zip
move confirm delete prompt to misc.c
Change-Id: Iadb1c7199caa5070f555eb4d329efb02e3193289
-rw-r--r--apps/bookmark.c12
-rw-r--r--apps/misc.c8
-rw-r--r--apps/misc.h2
-rw-r--r--apps/onplay.c12
-rw-r--r--apps/shortcuts.c2
5 files changed, 14 insertions, 22 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 30b8d0338d..16bfe1cd2b 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -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;
diff --git a/apps/misc.c b/apps/misc.c
index 690fb0117f..caf2ce5cd4 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -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)
{
diff --git a/apps/misc.h b/apps/misc.h
index b0e93dfade..af520a7fd1 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -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);
diff --git a/apps/onplay.c b/apps/onplay.c
index f8d13abf3f..7cc52fca46 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -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;
}
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 752ca977e6..e52e38eb06 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -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;