Use SBS title in delete confirmation screens

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 399230e9ecfa0309e1f1993d0b62d3af0dcb3f95
Author: Christian Soffke <[email protected]>
Date:   Tue Dec 30 12:36:31 2025 +0100

    Use SBS title in delete confirmation screens
    
    When deleting files or directories, you will now see
    the path's basename in the previously empty title of
    an SBS, making it a bit easier to immediately know
    whether you've selected the correct item.
    
    Matching titles were also added everywhere else that
    confirm_delete_yesno is used.
    
    The full path of the item is still displayed below,
    and continues to scroll, so that themes without a
    title, such as the default cabbiev2, will look the
    same.
    
    Change-Id: I32422cfbbf6e680f58456237380176617789cac3

diff --git a/apps/bookmark.c b/apps/bookmark.c
index 6024aeb2aa..f00ace7c41 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -1083,7 +1083,7 @@ static int select_bookmark(const char* bookmark_file_name,
         case ACTION_BMS_DELETE:
             if (item >= 0)
             {
-                if (confirm_delete_yesno("") == YESNO_YES)
+                if (confirm_delete_yesno("", str(LANG_BOOKMARK_CONTEXT_MENU)) == YESNO_YES)
                 {
                     delete_bookmark(bookmark_file_name, item);
                     bookmarks->reload = true;
diff --git a/apps/fileop.c b/apps/fileop.c
index 3f1ad6bd48..e24761be58 100644
--- a/apps/fileop.c
+++ b/apps/fileop.c
@@ -582,9 +582,8 @@ int delete_fileobject(const char *selected_file)
 
     /* Note: delete_fileobject() will happily delete whatever
      * path is passed (after confirmation) */
-    if (confirm_delete_yesno(param.path) != YESNO_YES) {
+    if (confirm_delete_yesno(param.path, param.toplevel_name) != YESNO_YES)
         return FORC_CANCELLED;
-    }
 
     if (param.is_dir) {
         int rc = check_count_fileobjects(&param);
diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c
index c1e722da10..bb0132e79b 100644
--- a/apps/gui/yesno.c
+++ b/apps/gui/yesno.c
@@ -31,6 +31,7 @@
 #include "appevents.h"
 #include "splash.h"
 #include "backlight.h"
+#include "statusbar-skinned.h"
 
 struct gui_yesno
 {
@@ -216,6 +217,7 @@ static void gui_yesno_ui_update(unsigned short id, void *event_data, void *user_
  *   no_message - displayed when YESNO_NO is choosen
 */
 enum yesno_res gui_syncyesno_run_w_tmo(int ticks, enum yesno_res tmo_default_res,
+                                       const char * title,
                                        const struct text_message * main_message,
                                        const struct text_message * yes_message,
                                        const struct text_message * no_message)
@@ -242,6 +244,9 @@ enum yesno_res gui_syncyesno_run_w_tmo(int ticks, enum yesno_res tmo_default_res
         yn[i].display=&screens[i];
         screens[i].scroll_stop();
         viewportmanager_theme_enable(i, true, &(yn[i].vp));
+        if (sb_set_title_text(title, Icon_NOICON, i))
+            send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
+
         yn[i].vp_lines = viewport_get_nb_lines(&(yn[i].vp));
     }
 
@@ -363,8 +368,18 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
                                  const struct text_message * yes_message,
                                  const struct text_message * no_message)
 {
-    return gui_syncyesno_run_w_tmo(TIMEOUT_BLOCK, YESNO_TMO,
-                             main_message, yes_message, no_message);
+    return gui_syncyesno_run_w_tmo(TIMEOUT_BLOCK, YESNO_TMO, NULL,
+                                   main_message, yes_message, no_message);
+}
+
+extern enum yesno_res gui_syncyesno_run_w_title(
+                                 const char * title,
+                                 const struct text_message * main_message,
+                                 const struct text_message * yes_message,
+                                 const struct text_message * no_message)
+{
+    return gui_syncyesno_run_w_tmo(TIMEOUT_BLOCK, YESNO_TMO, title,
+                                   main_message, yes_message, no_message);
 }
 
 static bool yesno_pop_lines(const char *lines[], int line_cnt)
diff --git a/apps/gui/yesno.h b/apps/gui/yesno.h
index 3c3876238b..a6188f844b 100644
--- a/apps/gui/yesno.h
+++ b/apps/gui/yesno.h
@@ -50,11 +50,19 @@ extern enum yesno_res gui_syncyesno_run(
                            const struct text_message * yes_message,
                            const struct text_message * no_message);
 
+/* Sets SBS title for the screen. Title may be NULL. */
+extern enum yesno_res gui_syncyesno_run_w_title(
+                           const char *title,
+                           const struct text_message * main_message,
+                           const struct text_message * yes_message,
+                           const struct text_message * no_message);
+
 extern enum yesno_res gui_syncyesno_run_w_tmo(
-                                     int ticks, enum yesno_res tmo_default_res,
-                                     const struct text_message * main_message,
-                                     const struct text_message * yes_message,
-                                     const struct text_message * no_message);
+                           int ticks, enum yesno_res tmo_default_res,
+                           const char *title,
+                           const struct text_message * main_message,
+                           const struct text_message * yes_message,
+                           const struct text_message * no_message);
 
 bool yesno_pop(const char* text);
 bool yesno_pop_confirm(const char* text);
diff --git a/apps/hosted/android/yesno.c b/apps/hosted/android/yesno.c
index 5fc99ae571..4153865144 100644
--- a/apps/hosted/android/yesno.c
+++ b/apps/hosted/android/yesno.c
@@ -119,6 +119,7 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
 }
 
 enum yesno_res gui_syncyesno_run_w_tmo(int ticks, enum yesno_res tmo_default_res,
+                                       const char *title,
                                        const struct text_message * main_message,
                                        const struct text_message * yes_message,
                                        const struct text_message * no_message)
@@ -126,6 +127,16 @@ enum yesno_res gui_syncyesno_run_w_tmo(int ticks, enum yesno_res tmo_default_res
     /* FIXME: create a prompt with timeout for android */
     (void)ticks;
     (void)tmo_default_res;
+    (void)title; /* Note: title ignored on Android */
+    return gui_syncyesno_run(main_message, yes_message, no_message);
+}
+
+enum yesno_res gui_syncyesno_run_w_title(const char *title,
+                                         const struct text_message * main_message,
+                                         const struct text_message * yes_message,
+                                         const struct text_message * no_message)
+{
+    (void)title; /* Note: title ignored on Android */
     return gui_syncyesno_run(main_message, yes_message, no_message);
 }
 
diff --git a/apps/misc.c b/apps/misc.c
index ea4bed923c..778e524b91 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -1277,13 +1277,13 @@ char* skip_whitespace(char* const str)
 
 #if !defined(CHECKWPS) && !defined(DBTOOL)
 
-int confirm_delete_yesno(const char *name)
+int confirm_delete_yesno(const char *name, const char *title)
 {
     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);
+    return gui_syncyesno_run_w_title(title, &message, &yes_message, NULL);
 }
 
 /*  time_split_units()
diff --git a/apps/misc.h b/apps/misc.h
index f28acd9ec1..fd326c5a7d 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -174,7 +174,9 @@ void adjust_volume_ex(int steps, enum volume_adjust_mode mode);
 int hex_to_rgb(const char* hex, int* color);
 #endif
 
-int confirm_delete_yesno(const char *name);
+/* Note: Don't rely on title being visible. It is not
+         displayed on Android, or if SBS has no title. */
+int confirm_delete_yesno(const char *name, const char *title);
 
 char* strrsplt(char* str, int c);
 char* skip_whitespace(char* const str);
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 47429c4616..88f2590c3e 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -646,7 +646,8 @@ static void close_playlist_viewer(void)
             if (viewer.num_tracks && yesno_pop(ID2P(LANG_SAVE_CHANGES)))
                 save_playlist_screen(viewer.playlist);
             else if (!viewer.num_tracks &&
-                     confirm_delete_yesno(viewer.playlist->filename) == YESNO_YES)
+                     confirm_delete_yesno(viewer.playlist->filename,
+                                          viewer.title) == YESNO_YES)
             {
                 remove(viewer.playlist->filename);
                 reload_directory();
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 49bb0d45f1..fece4c5030 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -633,7 +633,7 @@ static int shortcut_menu_get_action(int action, struct gui_synclist *lists)
     {
         int selection = gui_synclist_get_sel_pos(lists);
 
-        if (confirm_delete_yesno("") != YESNO_YES)
+        if (confirm_delete_yesno("", str(LANG_SHORTCUTS)) != YESNO_YES)
         {
             gui_synclist_set_title(lists, lists->title, lists->title_icon);
             if (global_settings.talk_menu)
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 9d59a5283d..443f18b7a4 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -5253,7 +5253,8 @@ static void tagcache_thread(void)
                                       ID2P(LANG_TAGCACHE_UPDATE)};
         static const struct text_message message = {lines, 2};
 
-        if (gui_syncyesno_run_w_tmo(HZ * 5, YESNO_YES, &message, NULL, NULL) == YESNO_YES)
+        if (gui_syncyesno_run_w_tmo(HZ * 5, YESNO_YES, str(LANG_TAGCACHE),
+                                    &message, NULL, NULL) == YESNO_YES)
 #endif
         {
             allocate_tempbuf();
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.