summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d67b8aa)
raw | patch | inline | side by side (parent: d67b8aa)
author | Kalle Wallin <kaw@linux.se> | |
Sat, 27 Mar 2004 16:36:01 +0000 (16:36 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sat, 27 Mar 2004 16:36:01 +0000 (16:36 +0000) |
command.c | patch | blob | history | |
command.h | patch | blob | history | |
screen_file.c | patch | blob | history | |
screen_help.c | patch | blob | history |
diff --git a/command.c b/command.c
index 73623b95534840c46b11e51f9fb498b4a3f59a1a..d254c4e031b840dcd9c5ac6030a85b5560373363 100644 (file)
--- a/command.c
+++ b/command.c
{ { 'r', 0, 0 }, CMD_REPEAT, "Toggle repeat mode" },
{ { 'z', 0, 0 }, CMD_RANDOM, "Toggle random mode" },
{ { 'S', 0, 0 }, CMD_SAVE_PLAYLIST, "Save playlist" },
- { { 'D', 0, 0 }, CMD_DELETE_PLAYLIST, "Delete playlist" },
{ { UP, 0, 0 }, CMD_LIST_PREVIOUS, "Move: Up" },
{ { DWN, 0, 0 }, CMD_LIST_NEXT, "Move: Down" },
diff --git a/command.h b/command.h
index 1672316f7f2d353abb5cd217f2a70aa16c955684..485b7534731c05b14e73c8f2d2709dd5278bf734 100644 (file)
--- a/command.h
+++ b/command.h
CMD_VOLUME_UP,
CMD_VOLUME_DOWN,
CMD_SAVE_PLAYLIST,
- CMD_DELETE_PLAYLIST,
CMD_TOGGLE_FIND_WRAP,
CMD_LIST_PREVIOUS,
CMD_LIST_NEXT,
diff --git a/screen_file.c b/screen_file.c
index b792d6ad906e02435caff3344ab5065b069ee021..762752e0acbb7dfd8f5272e734b3ea7bf7460976 100644 (file)
--- a/screen_file.c
+++ b/screen_file.c
+#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
return 0;
}
+static int
+handle_delete(screen_t *screen, mpd_client_t *c)
+{
+ list_window_t *lw = screen->filelist;
+ filelist_entry_t *entry;
+ mpd_InfoEntity *entity;
+ mpd_PlaylistFile *plf;
+ char *str, buf[BUFSIZE];
+ int key;
+
+ entry = ( filelist_entry_t *) g_list_nth_data(c->filelist, lw->selected);
+ if( entry==NULL || entry->entity==NULL )
+ return -1;
+
+ entity = entry->entity;
+
+ if( entity->type!=MPD_INFO_ENTITY_TYPE_PLAYLISTFILE )
+ {
+ screen_status_printf("You can only delete playlists!");
+ beep();
+ return -1;
+ }
+
+ plf = entity->info.playlistFile;
+ str = utf8_to_locale(basename(plf->path));
+ snprintf(buf, BUFSIZE, "Delete playlist %s [y/n] ? ", str);
+ free(str);
+ key = tolower(screen_getch(screen->status_window.w, buf));
+ if( key!='y' )
+ {
+ screen_status_printf("Aborted!");
+ return 0;
+ }
+
+ mpd_sendRmCommand(c->connection, plf->path);
+ mpd_finishCommand(c->connection);
+ if( mpc_error(c))
+ {
+ str = utf8_to_locale(mpc_error_str(c));
+ screen_status_printf("Error: %s", str);
+ free(str);
+ beep();
+ return -1;
+ }
+ screen_status_printf("Playlist deleted!");
+ mpc_update_filelist(c);
+ list_window_check_selected(lw, c->filelist_length);
+ return 0;
+}
+
+
static int
handle_play_cmd(screen_t *screen, mpd_client_t *c)
{
}
static int
-select_entry(screen_t *screen, mpd_client_t *c)
+handle_select(screen_t *screen, mpd_client_t *c)
{
list_window_t *w = screen->filelist;
filelist_entry_t *entry;
handle_play_cmd(screen, c);
return 1;
case CMD_SELECT:
- if( select_entry(screen, c) == 0 )
+ if( handle_select(screen, c) == 0 )
{
/* continue and select next item... */
cmd = CMD_LIST_NEXT;
}
break;
- case CMD_DELETE_PLAYLIST:
- screen_status_printf("Sorry, command not implemented yet!");
+ case CMD_DELETE:
+ handle_delete(screen, c);
return 1;
break;
case CMD_LIST_FIND:
diff --git a/screen_help.c b/screen_help.c
index 34a007c0af1a53dbce9c36f7238d1e11ae90b53b..de5bfe3e28147c233a385519fab1a67a8cad37a0 100644 (file)
--- a/screen_help.c
+++ b/screen_help.c
{ 0, CMD_NONE, " ------------------------" },
{ 0, CMD_PLAY, "Enter directory/Load playlist" },
{ 0, CMD_SELECT, "Add/remove song from playlist" },
- { 0, CMD_DELETE_PLAYLIST, "Delete playlist" },
+ { 0, CMD_DELETE, "Delete playlist" },
{ 0, CMD_NONE, " " },
{ 0, CMD_NONE, " " },
{ 1, CMD_NONE, " " PACKAGE " version " VERSION },