summaryrefslogtreecommitdiff
path: root/apps
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 /apps
parent3a22322ab77d38af3bea611f9dbb8f65b309d547 (diff)
downloadrockbox-71934d4c16fa1925833ef6e65ccb33b358398bd0.tar.gz
rockbox-71934d4c16fa1925833ef6e65ccb33b358398bd0.zip
move confirm delete prompt to misc.c
Change-Id: Iadb1c7199caa5070f555eb4d329efb02e3193289
Diffstat (limited to 'apps')
-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,
831 case ACTION_BMS_DELETE: 831 case ACTION_BMS_DELETE:
832 if (item >= 0) 832 if (item >= 0)
833 { 833 {
834 const char *lines[]={ 834 if (confirm_delete_yesno("") == YESNO_YES)
835 ID2P(LANG_REALLY_DELETE)
836 };
837 const char *yes_lines[]={
838 ID2P(LANG_DELETING)
839 };
840
841 const struct text_message message={lines, 1};
842 const struct text_message yes_message={yes_lines, 1};
843
844 if(gui_syncyesno_run(&message, &yes_message, NULL)==YESNO_YES)
845 { 835 {
846 delete_bookmark(bookmark_file_name, item); 836 delete_bookmark(bookmark_file_name, item);
847 bookmarks->reload = true; 837 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)
1133 return rdbufend >= 0 ? num_read : -1; 1133 return rdbufend >= 0 ? num_read : -1;
1134} 1134}
1135 1135
1136int confirm_delete_yesno(const char *name)
1137{
1138 const char *lines[] = { ID2P(LANG_REALLY_DELETE), name };
1139 const char *yes_lines[] = { ID2P(LANG_DELETING), name };
1140 const struct text_message message = { lines, 2 };
1141 const struct text_message yes_message = { yes_lines, 2 };
1142 return gui_syncyesno_run(&message, &yes_message, NULL);
1143}
1136 1144
1137char* skip_whitespace(char* const str) 1145char* skip_whitespace(char* const str)
1138{ 1146{
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);
143int hex_to_rgb(const char* hex, int* color); 143int hex_to_rgb(const char* hex, int* color);
144#endif 144#endif
145 145
146int confirm_delete_yesno(const char *name);
147
146char* strrsplt(char* str, int c); 148char* strrsplt(char* str, int c);
147char* skip_whitespace(char* const str); 149char* skip_whitespace(char* const str);
148 150
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 @@
63#include "viewport.h" 63#include "viewport.h"
64#include "pathfuncs.h" 64#include "pathfuncs.h"
65#include "shortcuts.h" 65#include "shortcuts.h"
66#include "misc.h"
66 67
67static int context; 68static int context;
68static const char *selected_file = NULL; 69static const char *selected_file = NULL;
@@ -898,15 +899,6 @@ static int confirm_overwrite(void)
898 return gui_syncyesno_run(&message, NULL, NULL); 899 return gui_syncyesno_run(&message, NULL, NULL);
899} 900}
900 901
901static int confirm_delete(const char *file)
902{
903 const char *lines[] = { ID2P(LANG_REALLY_DELETE), file };
904 const char *yes_lines[] = { ID2P(LANG_DELETING), file };
905 const struct text_message message = { lines, 2 };
906 const struct text_message yes_message = { yes_lines, 2 };
907 return gui_syncyesno_run(&message, &yes_message, NULL);
908}
909
910static bool check_new_name(const char *basename) 902static bool check_new_name(const char *basename)
911{ 903{
912 /* at least prevent escapes out of the base directory from keyboard- 904 /* at least prevent escapes out of the base directory from keyboard-
@@ -1001,7 +993,7 @@ static int delete_file_dir(void)
1001{ 993{
1002 const char *to_delete=selected_file; 994 const char *to_delete=selected_file;
1003 const int to_delete_attr=selected_file_attr; 995 const int to_delete_attr=selected_file_attr;
1004 if (confirm_delete(to_delete) != YESNO_YES) { 996 if (confirm_delete_yesno(to_delete) != YESNO_YES) {
1005 return 1; 997 return 1;
1006 } 998 }
1007 999
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)
454 { 454 {
455 int selection = gui_synclist_get_sel_pos(lists); 455 int selection = gui_synclist_get_sel_pos(lists);
456 456
457 if (!yesno_pop(ID2P(LANG_REALLY_DELETE))) 457 if (confirm_delete_yesno("") != YESNO_YES)
458 { 458 {
459 gui_synclist_set_title(lists, lists->title, lists->title_icon); 459 gui_synclist_set_title(lists, lists->title, lists->title_icon);
460 return ACTION_REDRAW; 460 return ACTION_REDRAW;