1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

bmpx: convert to callbacks.print

While here, also drop those calls to memset, as the whole info object is
being zeroed at the beginning of main(). (Probably this is useful upon
config reload, too.)
This commit is contained in:
Phil Sutter 2009-11-08 19:27:01 +01:00
parent 6371551153
commit dd8ec48fcb
4 changed files with 30 additions and 26 deletions

View File

@ -145,3 +145,20 @@ void fail(GError *error)
current_info->bmpx.bitrate = 0;
current_info->bmpx.track = 0;
}
#define BMPX_PRINT_GENERATOR(name, fmt) \
void print_bmpx_##name(struct text_object *obj, char *p, int p_max_size) \
{ \
(void)obj; \
snprintf(p, p_max_size, fmt, info.bmpx.name); \
}
BMPX_PRINT_GENERATOR(title, "%s")
BMPX_PRINT_GENERATOR(artist, "%s")
BMPX_PRINT_GENERATOR(album, "%s")
BMPX_PRINT_GENERATOR(uri, "%s")
BMPX_PRINT_GENERATOR(track, "%i")
BMPX_PRINT_GENERATOR(bitrate, "%i")
#undef BMPX_PRINT_GENERATOR

View File

@ -36,4 +36,11 @@ struct bmpx_s {
int track;
};
void print_bmpx_title(struct text_object *, char *, int);
void print_bmpx_artist(struct text_object *, char *, int);
void print_bmpx_album(struct text_object *, char *, int);
void print_bmpx_uri(struct text_object *, char *, int);
void print_bmpx_track(struct text_object *, char *, int);
void print_bmpx_bitrate(struct text_object *, char *, int);
#endif /*BMPX_H_*/

View File

@ -1636,26 +1636,6 @@ void generate_text_internal(char *p, int p_max_size,
}
#endif /* XMMS */
#ifdef BMPX
OBJ(bmpx_title) {
snprintf(p, p_max_size, "%s", cur->bmpx.title);
}
OBJ(bmpx_artist) {
snprintf(p, p_max_size, "%s", cur->bmpx.artist);
}
OBJ(bmpx_album) {
snprintf(p, p_max_size, "%s", cur->bmpx.album);
}
OBJ(bmpx_uri) {
snprintf(p, p_max_size, "%s", cur->bmpx.uri);
}
OBJ(bmpx_track) {
snprintf(p, p_max_size, "%i", cur->bmpx.track);
}
OBJ(bmpx_bitrate) {
snprintf(p, p_max_size, "%i", cur->bmpx.bitrate);
}
#endif /* BMPX */
/* we have four different types of top (top, top_mem,
* top_time and top_io). To avoid having almost-same code four
* times, we have this special handler. */

View File

@ -1205,17 +1205,17 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
#endif /* AUDACIOUS */
#ifdef BMPX
END OBJ(bmpx_title, &update_bmpx)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
obj->callbacks.print = &print_bmpx_title;
END OBJ(bmpx_artist, &update_bmpx)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
obj->callbacks.print = &print_bmpx_artist;
END OBJ(bmpx_album, &update_bmpx)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
obj->callbacks.print = &print_bmpx_album;
END OBJ(bmpx_track, &update_bmpx)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
obj->callbacks.print = &print_bmpx_track;
END OBJ(bmpx_uri, &update_bmpx)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
obj->callbacks.print = &print_bmpx_uri;
END OBJ(bmpx_bitrate, &update_bmpx)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
obj->callbacks.print = &print_bmpx_bitrate;
#endif
#ifdef EVE
END OBJ_ARG(eve, 0, "eve needs arguments: <userid> <apikey> <characterid>")