Code

*: use Compiler.h macros instead of glib.h
[ncmpc.git] / src / screen_song.c
index a66f3e1b7217e2d5e873eaf3b0d6c762ec273a22..c2b6c3c5f67be21c1a397d996c83f74d70c8271a 100644 (file)
@@ -36,7 +36,9 @@
 
 enum {
        LABEL_LENGTH = MPD_TAG_COUNT,
+       LABEL_PATH,
        LABEL_BITRATE,
+       LABEL_POSITION,
 };
 
 static const char *const tag_labels[] = {
@@ -44,6 +46,7 @@ static const char *const tag_labels[] = {
        [MPD_TAG_TITLE] = N_("Title"),
        [MPD_TAG_ALBUM] = N_("Album"),
        [LABEL_LENGTH] = N_("Length"),
+       [LABEL_POSITION] = N_("Position"),
        [MPD_TAG_COMPOSER] = N_("Composer"),
        [MPD_TAG_NAME] = N_("Name"),
        [MPD_TAG_DISC] = N_("Disc"),
@@ -51,6 +54,7 @@ static const char *const tag_labels[] = {
        [MPD_TAG_DATE] = N_("Date"),
        [MPD_TAG_GENRE] = N_("Genre"),
        [MPD_TAG_COMMENT] = N_("Comment"),
+       [LABEL_PATH] = N_("Path"),
        [LABEL_BITRATE] = N_("Bitrate"),
 };
 
@@ -120,7 +124,7 @@ screen_song_repaint(void)
 }
 
 static const char *
-screen_song_list_callback(unsigned idx, G_GNUC_UNUSED void *data)
+screen_song_list_callback(unsigned idx, gcc_unused void *data)
 {
        assert(idx < current.lines->len);
 
@@ -173,7 +177,7 @@ screen_song_resize(int cols, int rows)
 }
 
 static const char *
-screen_song_title(G_GNUC_UNUSED char *str, G_GNUC_UNUSED size_t size)
+screen_song_title(gcc_unused char *str, gcc_unused size_t size)
 {
        return _("Song viewer");
 }
@@ -260,6 +264,11 @@ screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c)
 {
        assert(song != NULL);
 
+       char songpos[16];
+       g_snprintf(songpos, sizeof(songpos), "%d", mpd_song_get_pos(song) + 1);
+       screen_song_append(_(tag_labels[LABEL_POSITION]), songpos,
+                          max_tag_label_width);
+
        screen_song_append_tag(song, MPD_TAG_ARTIST);
        screen_song_append_tag(song, MPD_TAG_TITLE);
        screen_song_append_tag(song, MPD_TAG_ALBUM);
@@ -308,10 +317,11 @@ screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c)
        screen_song_append_tag(song, MPD_TAG_GENRE);
        screen_song_append_tag(song, MPD_TAG_COMMENT);
 
-       screen_song_append(_("Path"), mpd_song_get_uri(song),
+       screen_song_append(_(tag_labels[LABEL_PATH]), mpd_song_get_uri(song),
                           max_tag_label_width);
        if (mpdclient_is_playing(c) && c->song != NULL &&
-           strcmp(mpd_song_get_uri(c->song), mpd_song_get_uri(song)) == 0) {
+           strcmp(mpd_song_get_uri(c->song), mpd_song_get_uri(song)) == 0 &&
+           mpd_status_get_kbit_rate(c->status)) {
                char buf[16];
                g_snprintf(buf, sizeof(buf), _("%d kbps"),
                           mpd_status_get_kbit_rate(c->status));