diff --git a/src/screen_artist.c b/src/screen_artist.c
index 01fbc9c1fbc35184f6d0ff5200446ff19bbfb711..c6173d0b3cd5c241ed5c1fa9ee54499000cdea54 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 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.
* 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 "i18n.h"
#include "options.h"
#include "screen.h"
#include "screen_utils.h"
#include "screen_browser.h"
#include "screen.h"
#include "screen_utils.h"
#include "screen_browser.h"
-#include "gcc.h"
+#include "filelist.h"
#include <ctype.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdlib.h>
/* list_window callback */
static const char *
/* 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 char** sc, G_GNUC_UNUSED void *data)
{
GPtrArray *list = data;
static char buf[BUFSIZE];
{
GPtrArray *list = data;
static char buf[BUFSIZE];
wrefresh(browser.lw->w);
}
wrefresh(browser.lw->w);
}
-static void
-artist_repaint_if_active(void)
-{
- if (screen_is_visible(&screen_artist))
- artist_repaint();
-}
-
-/* the playlist have been updated -> fix highlights */
-static void
-playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
-{
- browser_playlist_changed(&browser, c, event, data);
-
- artist_repaint_if_active();
-}
-
static GPtrArray *
g_list_to_ptr_array(GList *in)
{
static GPtrArray *
g_list_to_ptr_array(GList *in)
{
for (i = 0; i < array->len; ++i) {
char *value = g_ptr_array_index(array, i);
for (i = 0; i < array->len; ++i) {
char *value = g_ptr_array_index(array, i);
- free(value);
+ g_free(value);
}
g_ptr_array_free(array, TRUE);
}
static void
}
g_ptr_array_free(array, TRUE);
}
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 (artist_list != NULL) {
string_array_free(artist_list);
}
if (browser.filelist) {
}
if (browser.filelist) {
- if (c != NULL)
- mpdclient_remove_playlist_callback(c, playlist_changed_callback);
filelist_free(browser.filelist);
browser.filelist = NULL;
}
filelist_free(browser.filelist);
browser.filelist = NULL;
}
if (album[0] == 0)
browser.filelist =
mpdclient_filelist_search(c, TRUE,
if (album[0] == 0)
browser.filelist =
mpdclient_filelist_search(c, TRUE,
- MPD_TABLE_ARTIST,
+ MPD_TAG_ARTIST,
artist);
else
browser.filelist =
mpdclient_filelist_search(c, TRUE,
artist);
else
browser.filelist =
mpdclient_filelist_search(c, TRUE,
- MPD_TABLE_ALBUM,
+ MPD_TAG_ALBUM,
album);
if (browser.filelist == NULL)
album);
if (browser.filelist == NULL)
- browser.filelist = filelist_new(NULL);
+ browser.filelist = filelist_new();
/* add a dummy entry for ".." */
filelist_prepend(browser.filelist, NULL);
/* add a dummy entry for ".." */
filelist_prepend(browser.filelist, NULL);
- /* install playlist callback and fix highlights */
+#ifndef NCMPC_MINI
+ /* fix highlights */
sync_highlights(c, browser.filelist);
sync_highlights(c, browser.filelist);
- mpdclient_install_playlist_callback(c, playlist_changed_callback);
+#endif
}
static void
}
static void
}
}
}
}
-/* db updated */
-static void
-browse_callback(mpdclient_t *c, int event, mpd_unused gpointer data)
-{
- switch(event) {
- case BROWSE_DB_UPDATED:
- reload_lists(c);
- break;
- default:
- break;
- }
-
- artist_repaint_if_active();
-}
-
static void
init(WINDOW *w, int cols, int rows)
{
static void
init(WINDOW *w, int cols, int rows)
{
}
static void
}
static void
-open(mpdclient_t *c)
+open(struct mpdclient *c)
{
{
- static gboolean callback_installed = FALSE;
-
if (artist_list == NULL && album_list == NULL &&
browser.filelist == NULL)
reload_lists(c);
if (artist_list == NULL && album_list == NULL &&
browser.filelist == NULL)
reload_lists(c);
- if (!callback_installed) {
- mpdclient_install_browse_callback(c, browse_callback);
- callback_installed = TRUE;
- }
}
static void
}
static void
}
static void
}
static void
-add_query(mpdclient_t *c, int table, char *_filter)
+screen_artist_update(struct mpdclient *c)
+{
+ if (browser.filelist == NULL)
+ return;
+
+ if (c->events & MPD_IDLE_DATABASE)
+ /* the db has changed -> update the list */
+ reload_lists(c);
+
+#ifndef NCMPC_MINI
+ if (c->events & (MPD_IDLE_DATABASE | MPD_IDLE_PLAYLIST))
+ sync_highlights(c, browser.filelist);
+#endif
+
+ if (c->events & (MPD_IDLE_DATABASE
+#ifndef NCMPC_MINI
+ | MPD_IDLE_PLAYLIST
+#endif
+ ))
+ artist_repaint();
+}
+
+static void
+add_query(struct mpdclient *c, enum mpd_tag_type table, char *_filter)
{
char *str;
{
char *str;
- mpdclient_filelist_t *addlist;
+ struct filelist *addlist;
assert(filter != NULL);
str = utf8_to_locale(_filter);
assert(filter != NULL);
str = utf8_to_locale(_filter);
- if (table== MPD_TABLE_ALBUM)
+ if (table == MPD_TAG_ALBUM)
screen_status_printf("Adding album %s...", str);
else
screen_status_printf("Adding %s...", str);
screen_status_printf("Adding album %s...", str);
else
screen_status_printf("Adding %s...", str);
}
static bool
}
static bool
-artist_cmd(mpdclient_t *c, command_t cmd)
+artist_cmd(struct mpdclient *c, command_t cmd)
{
char *selected;
char *old;
{
char *selected;
char *old;
case CMD_ADD:
switch(mode) {
case LIST_ARTISTS:
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_TAG_ARTIST, selected);
+ cmd = CMD_LIST_NEXT; /* continue and select next item... */
+ }
break;
break;
-
+ }
case LIST_ALBUMS:
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_TAG_ARTIST, artist);
+ else if (i > 0)
+ {
+ selected = g_ptr_array_index(album_list,
+ browser.lw->selected - 1);
+ add_query(c, MPD_TAG_ALBUM, selected);
+ cmd = CMD_LIST_NEXT; /* continue and select next item... */
+ }
}
break;
}
break;
+ }
case LIST_SONGS:
/* handled by browser_cmd() */
case LIST_SONGS:
/* handled by browser_cmd() */
/* continue and update... */
case CMD_SCREEN_UPDATE:
reload_lists(c);
/* continue and update... */
case CMD_SCREEN_UPDATE:
reload_lists(c);
- screen_status_printf(_("Screen updated!"));
return false;
case CMD_LIST_FIND:
return false;
case CMD_LIST_FIND:
/* handled by browser_cmd() */
break;
}
/* handled by browser_cmd() */
break;
}
+ case CMD_LIST_JUMP:
+ switch (mode) {
+ case LIST_ARTISTS:
+ screen_jump(browser.lw, artist_lw_callback, artist_list);
+ artist_repaint();
+ return true;
+
+ case LIST_ALBUMS:
+ screen_jump(browser.lw, artist_lw_callback, album_list);
+ artist_repaint();
+ return true;
+
+ case LIST_SONGS:
+ /* handled by browser_cmd() */
+ break;
+ }
break;
break;
.open = open,
.resize = resize,
.paint = paint,
.open = open,
.resize = resize,
.paint = paint,
+ .update = screen_artist_update,
.cmd = artist_cmd,
.get_title = get_title,
};
.cmd = artist_cmd,
.get_title = get_title,
};