diff --git a/src/screen_artist.c b/src/screen_artist.c
index 52b7eeee8727753ec4ffd92d9edf3d998f8e4dff..3b14e6bd7a90b0db0b45154bed930e25909fba31 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
-/*
- * (c) 2005 by Kalle Wallin <kaw@linux.se>
- *
+/* ncmpc (Ncurses MPD Client)
+ * (c) 2004-2009 The Music Player Daemon Project
+ * Project homepage: http://musicpd.org
+
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
#include "i18n.h"
#include "options.h"
#include "screen.h"
#include "screen_utils.h"
#include "screen_browser.h"
-#include "gcc.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include <ncurses.h>
#define BUFSIZE 1024
/* list_window callback */
static const char *
-artist_lw_callback(unsigned idx, mpd_unused int *highlight, mpd_unused void *data)
+artist_lw_callback(unsigned idx, G_GNUC_UNUSED bool *highlight,
+ G_GNUC_UNUSED void *data)
{
GPtrArray *list = data;
static char buf[BUFSIZE];
artist_repaint();
}
+#ifndef NCMPC_MINI
/* the playlist have been updated -> fix highlights */
static void
playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
artist_repaint_if_active();
}
+#endif
static GPtrArray *
g_list_to_ptr_array(GList *in)
}
static void
-free_lists(struct mpdclient *c)
+free_lists(G_GNUC_UNUSED struct mpdclient *c)
{
if (artist_list != NULL) {
string_array_free(artist_list);
}
if (browser.filelist) {
+#ifndef NCMPC_MINI
if (c != NULL)
mpdclient_remove_playlist_callback(c, playlist_changed_callback);
+#endif
filelist_free(browser.filelist);
browser.filelist = NULL;
}
assert(album_list == NULL);
assert(browser.filelist == NULL);
- list = mpdclient_get_artists_utf8(c);
+ list = mpdclient_get_artists(c);
/* sort list */
list = g_list_sort(list, compare_utf8);
assert(album_list == NULL);
assert(browser.filelist == NULL);
- list = mpdclient_get_albums_utf8(c, artist);
+ list = mpdclient_get_albums(c, artist);
/* sort list */
list = g_list_sort(list, compare_utf8);
if (album[0] == 0)
browser.filelist =
- mpdclient_filelist_search_utf8(c, TRUE,
- MPD_TABLE_ARTIST,
- artist);
+ mpdclient_filelist_search(c, TRUE,
+ MPD_TABLE_ARTIST,
+ artist);
else
browser.filelist =
- mpdclient_filelist_search_utf8(c, TRUE,
- MPD_TABLE_ALBUM,
- album);
+ mpdclient_filelist_search(c, TRUE,
+ MPD_TABLE_ALBUM,
+ album);
if (browser.filelist == NULL)
browser.filelist = filelist_new(NULL);
/* add a dummy entry for ".." */
filelist_prepend(browser.filelist, NULL);
+#ifndef NCMPC_MINI
/* install playlist callback and fix highlights */
sync_highlights(c, browser.filelist);
mpdclient_install_playlist_callback(c, playlist_changed_callback);
+#endif
}
static void
/* db updated */
static void
-browse_callback(mpdclient_t *c, int event, mpd_unused gpointer data)
+browse_callback(mpdclient_t *c, int event, G_GNUC_UNUSED gpointer data)
{
switch(event) {
case BROWSE_DB_UPDATED:
}
static void
-open(mpd_unused screen_t *screen, mpdclient_t *c)
+open(mpdclient_t *c)
{
static gboolean callback_installed = FALSE;
screen_status_printf("Adding %s...", str);
g_free(str);
- addlist = mpdclient_filelist_search_utf8(c, TRUE, table, _filter);
+ addlist = mpdclient_filelist_search(c, TRUE, table, _filter);
if (addlist) {
mpdclient_filelist_add_all(c, addlist);
filelist_free(addlist);
}
static int
-artist_lw_cmd(struct screen *screen, struct mpdclient *c, command_t cmd)
+artist_lw_cmd(struct mpdclient *c, command_t cmd)
{
switch (mode) {
case LIST_ARTISTS:
return list_window_cmd(browser.lw, metalist_length(), cmd);
case LIST_SONGS:
- return browser_cmd(&browser, screen, c, cmd);
+ return browser_cmd(&browser, c, cmd);
}
assert(0);
return -1;
}
-static int
-artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
+static bool
+artist_cmd(mpdclient_t *c, command_t cmd)
{
char *selected;
char *old;
case CMD_ADD:
switch(mode) {
case LIST_ARTISTS:
- selected = g_ptr_array_index(artist_list,
- browser.lw->selected);
- add_query(c, MPD_TABLE_ARTIST, selected);
- cmd = CMD_LIST_NEXT; /* continue and select next item... */
+ {
+ unsigned i;
+ for(i = browser.lw->selected_start; i <= browser.lw->selected_end; ++i)
+ {
+ selected = g_ptr_array_index(artist_list, i);
+ add_query(c, MPD_TABLE_ARTIST, selected);
+ cmd = CMD_LIST_NEXT; /* continue and select next item... */
+ }
break;
-
+ }
case LIST_ALBUMS:
- if (browser.lw->selected == album_list->len + 1)
- add_query(c, MPD_TABLE_ARTIST, artist);
- else if (browser.lw->selected > 0) {
- selected = g_ptr_array_index(album_list,
- browser.lw->selected - 1);
- add_query(c, MPD_TABLE_ALBUM, selected);
- cmd = CMD_LIST_NEXT; /* continue and select next item... */
+ {
+ unsigned i;
+ for(i = browser.lw->selected_start; i <= browser.lw->selected_end; ++i)
+ {
+ if(i == album_list->len + 1)
+ add_query(c, MPD_TABLE_ARTIST, artist);
+ else if (i > 0)
+ {
+ selected = g_ptr_array_index(album_list,
+ browser.lw->selected - 1);
+ add_query(c, MPD_TABLE_ALBUM, selected);
+ cmd = CMD_LIST_NEXT; /* continue and select next item... */
+ }
}
break;
+ }
case LIST_SONGS:
/* handled by browser_cmd() */
/* continue and update... */
case CMD_SCREEN_UPDATE:
reload_lists(c);
- screen_status_printf(_("Screen updated!"));
- return 0;
+ return false;
case CMD_LIST_FIND:
case CMD_LIST_RFIND:
case CMD_LIST_RFIND_NEXT:
switch (mode) {
case LIST_ARTISTS:
- screen_find(screen,
- browser.lw, artist_list->len,
+ screen_find(browser.lw, artist_list->len,
cmd, artist_lw_callback, artist_list);
artist_repaint();
- return 1;
+ return true;
case LIST_ALBUMS:
- screen_find(screen,
- browser.lw, album_list->len + 2,
+ screen_find(browser.lw, album_list->len + 2,
cmd, artist_lw_callback, album_list);
artist_repaint();
- return 1;
+ return true;
case LIST_SONGS:
/* handled by browser_cmd() */
break;
}
- if (artist_lw_cmd(screen, c, cmd)) {
- artist_repaint();
- return 1;
+ if (artist_lw_cmd(c, cmd)) {
+ if (screen_is_visible(&screen_artist))
+ artist_repaint();
+ return true;
}
- return 0;
+ return false;
}
const struct screen_functions screen_artist = {