diff options
author | Kalle Wallin <kaw@linux.se> | 2004-03-27 20:55:26 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2004-03-27 20:55:26 +0000 |
commit | 3f6b5f829a903e2a5bd3dfa8031c90cc122db958 (patch) | |
tree | e0e6988086a5e2590f8235a7e56991bc51e44422 | |
parent | c8caa261efdd583a18dad6729d9aa1ec1029e525 (diff) | |
download | mpd-3f6b5f829a903e2a5bd3dfa8031c90cc122db958.tar.gz mpd-3f6b5f829a903e2a5bd3dfa8031c90cc122db958.tar.xz mpd-3f6b5f829a903e2a5bd3dfa8031c90cc122db958.zip |
Include "config.h" before "support.h"
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@517 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | list_window.c | 1 | ||||
-rw-r--r-- | screen_play.c | 46 |
2 files changed, 46 insertions, 1 deletions
diff --git a/list_window.c b/list_window.c index fa1f94921..d976ce05c 100644 --- a/list_window.c +++ b/list_window.c @@ -4,6 +4,7 @@ #include <glib.h> #include <ncurses.h> +#include "config.h" #include "support.h" #include "command.h" #include "list_window.h" diff --git a/screen_play.c b/screen_play.c index 7c5cab1ff..5f93ad093 100644 --- a/screen_play.c +++ b/screen_play.c @@ -3,6 +3,8 @@ #include <glib.h> #include <ncurses.h> +#include "config.h" +#include "support.h" #include "libmpdclient.h" #include "mpc.h" #include "command.h" @@ -34,6 +36,48 @@ list_callback(int index, int *highlight, void *data) return mpc_get_song_name(song); } +static int +handle_save_playlist(screen_t *screen, mpd_client_t *c) +{ + char *filename, *filename_utf8; + + filename=screen_getstr(screen->status_window.w, "Save playlist as: "); + filename=trim(filename); + if( filename==NULL || filename[0]=='\0' ) + return -1; + /* convert filename to utf-8 */ + filename_utf8 = locale_to_utf8(filename); + /* send save command to mpd */ + mpd_sendSaveCommand(c->connection, filename_utf8); + mpd_finishCommand(c->connection); + free(filename_utf8); + /* handle errors */ + if( mpc_error(c)) + { + if( mpc_error_str(c) ) + { + char *str = utf8_to_locale(mpc_error_str(c)); + screen_status_message(str); + free(str); + } + else + screen_status_printf("Error: Unable to save playlist as %s", filename); + mpd_clearError(c->connection); + beep(); + return -1; + } + /* success */ + screen_status_printf("Saved %s", filename); + free(filename); + /* update the file list if it has been initalized */ + if( c->filelist ) + { + mpc_update_filelist(c); + list_window_check_selected(screen->filelist, c->filelist_length); + } + return 0; +} + void play_open(screen_t *screen, mpd_client_t *c) { @@ -93,7 +137,7 @@ play_cmd(screen_t *screen, mpd_client_t *c, command_t cmd) mpc_get_song_name(song)); return 1; case CMD_SAVE_PLAYLIST: - screen_status_printf("Sorry, playlist saving not implemented yet!"); + handle_save_playlist(screen, c); return 1; case CMD_LIST_FIND: case CMD_LIST_RFIND: |