summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f1621fd)
raw | patch | inline | side by side (parent: f1621fd)
author | Max Kellermann <max@duempel.org> | |
Wed, 1 Oct 2008 07:25:01 +0000 (09:25 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 1 Oct 2008 07:25:01 +0000 (09:25 +0200) |
Generate these special list entries on the fly.
src/screen_artist.c | patch | blob | history |
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 03b4fed421ab69165d61a4776f750f389e834875..81e5653092d7d3e14931a0f54dc93b8e2f872043 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
static char buf[BUFSIZE];
char *str, *str_utf8;
+ if (mode == LIST_ALBUMS) {
+ if (idx == 0)
+ return "[..]";
+ else if (idx == metalist_length - 1) {
+ str = utf8_to_locale(_("All tracks"));
+ g_snprintf(buf, BUFSIZE, "[%s]", str);
+ g_free(str);
+ return buf;
+ }
+
+ --idx;
+ }
+
if ((str_utf8 = (char *)g_list_nth_data(metalist, idx)) == NULL)
return NULL;
metalist = mpdclient_get_albums_utf8(c, m_artist);
/* sort list */
metalist = g_list_sort(metalist, compare_utf8);
- /* add a dummy entry for ".." */
- metalist = g_list_insert(metalist, g_strdup(".."), 0);
- /* add a dummy entry for all songs */
- metalist = g_list_insert(metalist, g_strdup(_("All tracks")), -1);
mode = LIST_ALBUMS;
} else {
/* retreive artists... */
mode = LIST_ARTISTS;
}
metalist_length = g_list_length(metalist);
+ if (mode == LIST_ALBUMS)
+ metalist_length += 2;
}
/* db updated */
} else {
/* select album */
selected = g_list_nth_data(metalist,
- browser.lw->selected);
+ browser.lw->selected - 1);
update_metalist(c, g_strdup(artist), g_strdup(selected));
list_window_push_state(browser.lw_state, browser.lw);
}
add_query(c, MPD_TABLE_ARTIST, artist);
else if (browser.lw->selected > 0) {
selected = g_list_nth_data(metalist,
- browser.lw->selected);
+ browser.lw->selected - 1);
if (selected == NULL)
return 1;