summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8caa26)
raw | patch | inline | side by side (parent: c8caa26)
author | Kalle Wallin <kaw@linux.se> | |
Sat, 27 Mar 2004 20:55:26 +0000 (20:55 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sat, 27 Mar 2004 20:55:26 +0000 (20:55 +0000) |
list_window.c | patch | blob | history | |
screen_play.c | patch | blob | history |
diff --git a/list_window.c b/list_window.c
index fa1f949215fca34b5a9922b3616f96cef4765988..d976ce05c351372b1f87efea8427f4f31dc3d89b 100644 (file)
--- a/list_window.c
+++ b/list_window.c
#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 7c5cab1ff080503e259c3956d08a3897593267ac..5f93ad09331e0108cb57f05af4b7488d292b39c9 100644 (file)
--- a/screen_play.c
+++ b/screen_play.c
#include <glib.h>
#include <ncurses.h>
+#include "config.h"
+#include "support.h"
#include "libmpdclient.h"
#include "mpc.h"
#include "command.h"
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)
{
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: