summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-21 21:36:32 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-21 21:47:56 +0100
commit454f852f361477b0f365a9705574a700339497ac (patch)
tree24bf5f0a2239527c74d35fcf95b8c0dbfc284ada /playlist.c
parentf89029d063c855b03adbcd20d09380fd42cb11c9 (diff)
parent4d12a12570876810d0376d31b280674b5c49054a (diff)
Merge branch 'master' into devel
Conflicts: Makefile.am configure.ac deadbeef.h main.c plugins/oss/Makefile.am plugins/oss/oss.c
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/playlist.c b/playlist.c
index 79701b88..bdeb5ca3 100644
--- a/playlist.c
+++ b/playlist.c
@@ -1576,9 +1576,10 @@ pl_format_elapsed (const char *ret, char *elapsed, int size) {
}
int
-pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
+pl_format_title (playItem_t *it, int idx, char *s, int size, int id, const char *fmt) {
char dur[50];
char elp[50];
+ char fno[50];
const char *artist = NULL;
const char *album = NULL;
const char *track = NULL;
@@ -1589,10 +1590,18 @@ pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
const char *genre = NULL;
const char *comment = NULL;
const char *copyright = NULL;
+ const char *filename = NULL;
if (id != -1) {
const char *text = NULL;
switch (id) {
+ case DB_COLUMN_FILENUMBER:
+ if (idx == -1) {
+ idx = pl_get_idx_of (it);
+ }
+ snprintf (fno, sizeof (fno), "%d", idx+1);
+ text = fno;
+ break;
case DB_COLUMN_PLAYING:
return pl_format_item_queue (it, s, size);
case DB_COLUMN_ARTIST_ALBUM:
@@ -1692,6 +1701,16 @@ pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
n--;
}
}
+ else if (*fmt == 'f') {
+ filename = it->fname + strlen (it->fname) - 1;
+ while (filename > it->fname && (*filename) != '/') {
+ filename--;
+ }
+ if (*filename == '/') {
+ filename++;
+ }
+ meta = filename;
+ }
else {
*s++ = *fmt;
n--;
@@ -1714,6 +1733,9 @@ pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
void
pl_sort (int iter, int id, const char *format, int ascending) {
+ if (id == DB_COLUMN_FILENUMBER) {
+ return;
+ }
int sorted = 0;
do {
sorted = 1;
@@ -1743,8 +1765,8 @@ pl_sort (int iter, int id, const char *format, int ascending) {
}
}
else {
- pl_format_title (it, title1, sizeof (title1), id, format);
- pl_format_title (next, title2, sizeof (title2), id, format);
+ pl_format_title (it, -1, title1, sizeof (title1), id, format);
+ pl_format_title (next, -1, title2, sizeof (title2), id, format);
}
int cmp = ascending ? strcmp (title1, title2) < 0 : strcmp (title1, title2) > 0;
if (cmp) {