From 86d464488b8fdaa9481401b056c5acee311fe1cb Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Sun, 13 Feb 2005 22:04:03 +0000 Subject: [PATCH] Enable playlist saving on the browse screen git-svn-id: https://svn.musicpd.org/ncmpc/trunk@2949 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/screen_file.c | 23 +++++++++++++++++++++++ src/screen_help.c | 1 + src/screen_play.c | 11 ++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/screen_file.c b/src/screen_file.c index 1e13cc4..002e9cd 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -284,6 +284,26 @@ load_playlist(screen_t *screen, mpdclient_t *c, filelist_entry_t *entry) return 0; } +static int +handle_save(screen_t *screen, mpdclient_t *c) +{ + filelist_entry_t *entry; + char *defaultname = NULL; + + + entry=( filelist_entry_t *) g_list_nth_data(filelist->list,lw->selected); + if( entry && entry->entity ) + { + mpd_InfoEntity *entity = entry->entity; + if( entity->type==MPD_INFO_ENTITY_TYPE_PLAYLISTFILE ) + { + mpd_PlaylistFile *plf = entity->info.playlistFile; + defaultname = plf->path; + } + } + return playlist_save(screen, c, NULL, defaultname); +} + static int handle_delete(screen_t *screen, mpdclient_t *c) { @@ -649,6 +669,9 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) case CMD_DELETE: handle_delete(screen, c); break; + case CMD_SAVE_PLAYLIST: + handle_save(screen, c); + break; case CMD_SCREEN_UPDATE: screen->painted = 0; lw->clear = 1; diff --git a/src/screen_help.c b/src/screen_help.c index 66acc3d..8c5e512 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -110,6 +110,7 @@ static help_text_row_t help_text[] = { 2, CMD_NONE, NULL }, { 0, CMD_PLAY, N_("Enter directory/Select and play song") }, { 0, CMD_SELECT, NULL }, + { 0, CMD_SAVE_PLAYLIST, NULL }, { 0, CMD_DELETE, N_("Delete playlist") }, { 0, CMD_SCREEN_UPDATE, NULL }, diff --git a/src/screen_play.c b/src/screen_play.c index cdb8320..b86c876 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -114,8 +114,9 @@ center_playing_item(screen_t *screen, mpdclient_t *c) return 0; } -static int -handle_save_playlist(screen_t *screen, mpdclient_t *c, char *name) + +int +playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname) { gchar *filename; gint error; @@ -153,7 +154,7 @@ handle_save_playlist(screen_t *screen, mpdclient_t *c, char *name) /* query the user for a filename */ filename = screen_readln(screen->status_window.w, _("Save playlist as: "), - NULL, + defaultname, NULL, gcmp); @@ -192,7 +193,7 @@ handle_save_playlist(screen_t *screen, mpdclient_t *c, char *name) g_free(filename); return -1; } - error = handle_save_playlist(screen, c, filename); + error = playlist_save(screen, c, filename, NULL); g_free(filename); return error; } @@ -422,7 +423,7 @@ play_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) mpdclient_cmd_delete(c, lw->selected); return 1; case CMD_SAVE_PLAYLIST: - handle_save_playlist(screen, c, NULL); + playlist_save(screen, c, NULL, NULL); return 1; case CMD_ADD: handle_add_to_playlist(screen, c); -- 2.30.2