Code

screen_utils: automatically append "[y/n]"
authorMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 20:09:39 +0000 (21:09 +0100)
committerMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 20:09:39 +0000 (21:09 +0100)
src/screen_file.c
src/screen_lyrics.c
src/screen_queue.c
src/screen_utils.c

index 06cb5ea6124a1d1878ce2fa86ef6346dfe3e5e31..2af1655d3b3eca3e89c425c831ce3d7182a77865 100644 (file)
@@ -210,7 +210,7 @@ handle_delete(struct mpdclient *c)
 
                const struct mpd_playlist *playlist = mpd_entity_get_playlist(entity);
                char *str = utf8_to_locale(g_basename(mpd_playlist_get_path(playlist)));
-               char *buf = g_strdup_printf(_("Delete playlist %s [%s/%s] ? "), str, YES, NO);
+               char *buf = g_strdup_printf(_("Delete playlist %s?"), str);
                g_free(str);
                bool delete = screen_get_yesno(buf, false);
                g_free(buf);
index 0bce7c4c54bdd702afcbc74a435c37f546c34824..11786c1a9e778ee503983645e468a8b63760a4fd 100644 (file)
@@ -363,11 +363,9 @@ lyrics_edit(void)
        }
 
        if (options.text_editor_ask) {
-               char *buf = g_strdup_printf(
-                   _("Do you really want to start an editor and edit these lyrics [%s/%s]? "),
-                                           YES, NO);
-               bool really = screen_get_yesno(buf, false);
-               g_free(buf);
+               const char *prompt =
+                       _("Do you really want to start an editor and edit these lyrics?");
+               bool really = screen_get_yesno(prompt, false);
                if (!really) {
                        screen_status_message(_("Aborted"));
                        return;
index d364c910a5c0ae8e0c91f8ff707e1414361e305d..45505eee015fd51252eb4e29c2200269bc099dd4 100644 (file)
@@ -279,8 +279,7 @@ playlist_save(struct mpdclient *c, char *name, char *defaultname)
                if (mpd_connection_get_error(connection) == MPD_ERROR_SERVER &&
                    mpd_connection_get_server_error(connection) == MPD_SERVER_ERROR_EXIST &&
                    mpd_connection_clear_error(connection)) {
-                       char *buf = g_strdup_printf(_("Replace %s [%s/%s] ? "),
-                                                   filename, YES, NO);
+                       char *buf = g_strdup_printf(_("Replace %s?"), filename);
                        bool replace = screen_get_yesno(buf, false);
                        g_free(buf);
 
index 8f69930d64126752b048164fcd1a8d7e9d0df379..6c5ce43368c5310058534d9df608b613a1736ac6 100644 (file)
@@ -72,12 +72,15 @@ screen_getch(const char *prompt)
 }
 
 bool
-screen_get_yesno(const char *prompt, bool def)
+screen_get_yesno(const char *_prompt, bool def)
 {
        /* NOTE: if one day a translator decides to use a multi-byte character
           for one of the yes/no keys, we'll have to parse it properly */
 
+       char *prompt = g_strdup_printf(_("%s [%s/%s] "), _prompt, YES, NO);
        int key = tolower(screen_getch(prompt));
+       g_free(prompt);
+
        if (key == YES[0])
                return true;
        else if (key == NO[0])