diff --git a/src/screen_queue.c b/src/screen_queue.c
index 79a112b60468e889615ec525dcf1f7b484b5d25d..50e70c4a51ddcb3a321db52455cdb3d2f9afc440 100644 (file)
--- a/src/screen_queue.c
+++ b/src/screen_queue.c
/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
* Project homepage: http://musicpd.org
*
* This program is free software; you can redistribute it and/or modify
#include "screen_queue.h"
#include "screen_interface.h"
#include "screen_file.h"
-#include "screen_message.h"
+#include "screen_status.h"
#include "screen_find.h"
#include "config.h"
#include "i18n.h"
filename=g_strstrip(filename);
} else
#endif
- filename=g_strdup(name);
+ filename=g_strdup(name);
if (filename == NULL)
return -1;
/* send save command to mpd */
connection = mpdclient_get_connection(c);
- if (connection == NULL)
+ if (connection == NULL) {
+ g_free(filename);
return -1;
+ }
filename_utf8 = locale_to_utf8(filename);
if (!mpd_run_save(connection, filename_utf8)) {
mpd_connection_get_server_error(connection) == MPD_SERVER_ERROR_EXIST &&
mpd_connection_clear_error(connection)) {
char *buf;
- int key;
+ bool replace;
buf = g_strdup_printf(_("Replace %s [%s/%s] ? "),
filename, YES, NO);
- key = tolower(screen_getch(buf));
+ replace = screen_get_yesno(buf, false);
g_free(buf);
- if (key != YES[0]) {
+ if (!replace) {
g_free(filename_utf8);
g_free(filename);
screen_status_printf(_("Aborted"));
handle_add_to_playlist(struct mpdclient *c)
{
gchar *path;
-#ifndef NCMPC_MINI
GCompletion *gcmp;
+#ifndef NCMPC_MINI
GList *list = NULL;
GList *dir_list = NULL;
completion_callback_data_t data;
wrln_completion_callback_data = &data;
wrln_pre_completion_callback = add_pre_completion_cb;
wrln_post_completion_callback = add_post_completion_cb;
+#else
+ gcmp = NULL;
#endif
/* get path */
path = screen_readln(_("Add"),
NULL,
NULL,
-#ifdef NCMPC_MINI
- NULL
-#else
- gcmp
-#endif
- );
+ gcmp);
/* destroy completion data */
#ifndef NCMPC_MINI
static void
screen_queue_update(struct mpdclient *c)
{
- if (c->events & MPD_IDLE_PLAYLIST)
+ if (c->events & MPD_IDLE_QUEUE)
screen_queue_restore_selection();
+ else
+ /* the queue size may have changed, even if we havn't
+ received the QUEUE idle event yet */
+ list_window_set_length(lw, playlist_length(playlist));
if (((c->events & MPD_IDLE_PLAYER) != 0 &&
screen_queue_song_change(c->status)) ||
- c->events & MPD_IDLE_PLAYLIST)
+ c->events & MPD_IDLE_QUEUE)
/* the queue or the current song has changed, we must
paint the new version */
screen_queue_repaint();
break;
#endif
case CMD_SCREEN_SWAP:
- screen_swap(c, playlist_get(&c->playlist, lw->selected));
+ if (playlist_length(&c->playlist) > 0)
+ screen_swap(c, playlist_get(&c->playlist, lw->selected));
+ else
+ screen_swap(c, NULL);
return true;
default:
case CMD_SHUFFLE:
list_window_get_range(lw, &range);
- if (range.end < range.start + 1)
+ if (range.end <= range.start + 1)
/* No range selection, shuffle all list. */
break;
lw->selected--;
lw->range_base--;
+ if (lw->range_selection)
+ list_window_scroll_to(lw, lw->range_base);
+ list_window_scroll_to(lw, lw->selected);
+
screen_queue_save_selection();
return true;
lw->selected++;
lw->range_base++;
+ if (lw->range_selection)
+ list_window_scroll_to(lw, lw->range_base);
+ list_window_scroll_to(lw, lw->selected);
+
screen_queue_save_selection();
return true;