mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 04:32:55 +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:
parent
6371551153
commit
dd8ec48fcb
17
src/bmpx.c
17
src/bmpx.c
@ -145,3 +145,20 @@ void fail(GError *error)
|
|||||||
current_info->bmpx.bitrate = 0;
|
current_info->bmpx.bitrate = 0;
|
||||||
current_info->bmpx.track = 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
|
||||||
|
|
||||||
|
@ -36,4 +36,11 @@ struct bmpx_s {
|
|||||||
int track;
|
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_*/
|
#endif /*BMPX_H_*/
|
||||||
|
20
src/conky.c
20
src/conky.c
@ -1636,26 +1636,6 @@ void generate_text_internal(char *p, int p_max_size,
|
|||||||
}
|
}
|
||||||
#endif /* XMMS */
|
#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,
|
/* we have four different types of top (top, top_mem,
|
||||||
* top_time and top_io). To avoid having almost-same code four
|
* top_time and top_io). To avoid having almost-same code four
|
||||||
* times, we have this special handler. */
|
* times, we have this special handler. */
|
||||||
|
12
src/core.c
12
src/core.c
@ -1205,17 +1205,17 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
|||||||
#endif /* AUDACIOUS */
|
#endif /* AUDACIOUS */
|
||||||
#ifdef BMPX
|
#ifdef BMPX
|
||||||
END OBJ(bmpx_title, &update_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)
|
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)
|
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)
|
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)
|
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)
|
END OBJ(bmpx_bitrate, &update_bmpx)
|
||||||
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
|
obj->callbacks.print = &print_bmpx_bitrate;
|
||||||
#endif
|
#endif
|
||||||
#ifdef EVE
|
#ifdef EVE
|
||||||
END OBJ_ARG(eve, 0, "eve needs arguments: <userid> <apikey> <characterid>")
|
END OBJ_ARG(eve, 0, "eve needs arguments: <userid> <apikey> <characterid>")
|
||||||
|
Loading…
Reference in New Issue
Block a user