From d88415237683a7d6b46ccd782cd5d79b62cd8316 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 29 Jan 2012 21:06:01 +0100 Subject: [PATCH] add mpd_date function that shows date for current track (sf.net #3440445) patch submitted by Andrey Tikhonov --- doc/variables.xml | 9 +++++++++ src/conky.c | 2 ++ src/core.c | 4 ++++ src/mpd.c | 3 +++ src/mpd.h | 2 ++ src/text_object.h | 1 + 6 files changed, 21 insertions(+) diff --git a/doc/variables.xml b/doc/variables.xml index 8d8e349a..eee27ca4 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -2276,6 +2276,15 @@ Bitrate of current song + + + + + + + Date of current song + + diff --git a/src/conky.c b/src/conky.c index f2ea4790..1379f574 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1932,6 +1932,8 @@ void generate_text_internal(char *p, int p_max_size, print_mpd_artist(obj, p, p_max_size); OBJ(mpd_album) print_mpd_album(obj, p, p_max_size); + OBJ(mpd_date) + print_mpd_date(obj, p, p_max_size); OBJ(mpd_random) print_mpd_random(obj, p, p_max_size); OBJ(mpd_repeat) diff --git a/src/core.c b/src/core.c index e93ef58e..d02bf291 100644 --- a/src/core.c +++ b/src/core.c @@ -925,6 +925,9 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ(mpd_album, &update_mpd) mpd_set_maxlen(mpd_album); init_mpd(); + END OBJ(mpd_date, &update_mpd) + mpd_set_maxlen(mpd_date); + init_mpd(); END OBJ(mpd_vol, &update_mpd) init_mpd(); END OBJ(mpd_bitrate, &update_mpd) init_mpd(); END OBJ(mpd_status, &update_mpd) init_mpd(); @@ -1737,6 +1740,7 @@ void free_text_objects(struct text_object *root, int internal) case OBJ_mpd_title: case OBJ_mpd_artist: case OBJ_mpd_album: + case OBJ_mpd_date: case OBJ_mpd_random: case OBJ_mpd_repeat: case OBJ_mpd_vol: diff --git a/src/mpd.c b/src/mpd.c index ec929b79..dd4a6f5c 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -95,6 +95,7 @@ static void clear_mpd(void) xfree(mpd_info.title); xfree(mpd_info.artist); xfree(mpd_info.album); + xfree(mpd_info.date); /* do not free() the const char *status! */ /* do not free() the const char *random! */ /* do not free() the const char *repeat! */ @@ -273,6 +274,7 @@ static void *update_mpd_thread(void *arg) SONGSET(artist); SONGSET(album); SONGSET(title); + SONGSET(date); SONGSET(track); SONGSET(name); SONGSET(file); @@ -403,6 +405,7 @@ void print_mpd_##name(struct text_object *obj, char *p, int p_max_size) \ MPD_PRINT_GENERATOR(title, "%s") MPD_PRINT_GENERATOR(artist, "%s") MPD_PRINT_GENERATOR(album, "%s") +MPD_PRINT_GENERATOR(date, "%s") MPD_PRINT_GENERATOR(random, "%s") MPD_PRINT_GENERATOR(repeat, "%s") MPD_PRINT_GENERATOR(track, "%s") diff --git a/src/mpd.h b/src/mpd.h index d011fcee..277be6d3 100644 --- a/src/mpd.h +++ b/src/mpd.h @@ -7,6 +7,7 @@ struct mpd_s { char *title; char *artist; char *album; + char *date; const char *status; const char *random; const char *repeat; @@ -41,6 +42,7 @@ void print_mpd_smart(struct text_object *, char *, int); void print_mpd_title(struct text_object *, char *, int); void print_mpd_artist(struct text_object *, char *, int); void print_mpd_album(struct text_object *, char *, int); +void print_mpd_date(struct text_object *, char *, int); void print_mpd_random(struct text_object *, char *, int); void print_mpd_repeat(struct text_object *, char *, int); void print_mpd_track(struct text_object *, char *, int); diff --git a/src/text_object.h b/src/text_object.h index 52d19e70..dfbf93e8 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -327,6 +327,7 @@ enum text_object_type { OBJ_mpd_title, OBJ_mpd_artist, OBJ_mpd_album, + OBJ_mpd_date, OBJ_mpd_random, OBJ_mpd_repeat, OBJ_mpd_vol,