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

Unwrap audacious C macros.

This commit is contained in:
Brenden Matthews 2018-08-08 11:00:51 -04:00
parent 37a85ad8b0
commit 693ad0bafc

View File

@ -192,13 +192,16 @@ aud_result get_res() {
} }
} // namespace } // namespace
void print_audacious_status(struct text_object *, char *p, unsigned int p_max_size) { void print_audacious_status(struct text_object *, char *p,
unsigned int p_max_size) {
const aud_result &res = get_res(); const aud_result &res = get_res();
snprintf(p, p_max_size, "%s", as_message[res.status]); snprintf(p, p_max_size, "%s", as_message[res.status]);
} }
void print_audacious_title(struct text_object *obj, char *p, unsigned int p_max_size) { void print_audacious_title(struct text_object *obj, char *p,
snprintf(p, std::min((unsigned int) obj->data.i, p_max_size), "%s", get_res().title.c_str()); unsigned int p_max_size) {
snprintf(p, std::min((unsigned int)obj->data.i, p_max_size), "%s",
get_res().title.c_str());
} }
void print_audacious_filename(struct text_object *obj, char *p, void print_audacious_filename(struct text_object *obj, char *p,
@ -212,39 +215,56 @@ double audacious_barval(struct text_object *) {
return (double)res.position / res.length; return (double)res.position / res.length;
} }
#define AUDACIOUS_TIME_GENERATOR(name) \ void print_audacious_length(struct text_object *, char *p,
void print_audacious_##name(struct text_object *, char *p, \ unsigned int p_max_size) {
unsigned int p_max_size) { \ const aud_result &res = get_res();
const aud_result &res = get_res(); \ int sec = res.length / 1000;
int sec = res.name / 1000; \ snprintf(p, p_max_size, "%d:%.2d", sec / 60, sec % 60);
snprintf(p, p_max_size, "%d:%.2d", sec / 60, sec % 60); \
} \
\
void print_audacious_##name##_seconds(struct text_object *, char *p, \
unsigned int p_max_size) { \
snprintf(p, p_max_size, "%d", get_res().name); \
} }
AUDACIOUS_TIME_GENERATOR(length) void print_audacious_length_seconds(struct text_object *, char *p,
AUDACIOUS_TIME_GENERATOR(position) unsigned int p_max_size) {
snprintf(p, p_max_size, "%d", get_res().length);
#define AUDACIOUS_INT_GENERATOR_0(name) \
void print_audacious_##name(struct text_object *, char *p, \
unsigned int p_max_size) { \
snprintf(p, p_max_size, "%d", get_res().name); \
} }
#define AUDACIOUS_INT_GENERATOR_1(name) \ void print_audacious_position(struct text_object *, char *p,
void print_audacious_##name(struct text_object *, char *p, \ unsigned int p_max_size) {
unsigned int p_max_size) { \ const aud_result &res = get_res();
snprintf(p, p_max_size, "%d", get_res().name + 1); \ int sec = res.position / 1000;
snprintf(p, p_max_size, "%d:%.2d", sec / 60, sec % 60);
} }
AUDACIOUS_INT_GENERATOR_0(bitrate) void print_audacious_position_seconds(struct text_object *, char *p,
AUDACIOUS_INT_GENERATOR_0(frequency) unsigned int p_max_size) {
AUDACIOUS_INT_GENERATOR_0(channels) snprintf(p, p_max_size, "%d", get_res().position);
AUDACIOUS_INT_GENERATOR_0(playlist_length) }
AUDACIOUS_INT_GENERATOR_1(playlist_position)
AUDACIOUS_INT_GENERATOR_0(main_volume)
#undef AUDACIOUS_PRINT_GENERATOR void print_audacious_bitrate(struct text_object *, char *p,
unsigned int p_max_size) {
snprintf(p, p_max_size, "%d", get_res().bitrate);
}
void print_audacious_frequency(struct text_object *, char *p,
unsigned int p_max_size) {
snprintf(p, p_max_size, "%d", get_res().frequency);
}
void print_audacious_channels(struct text_object *, char *p,
unsigned int p_max_size) {
snprintf(p, p_max_size, "%d", get_res().channels);
}
void print_audacious_playlist_length(struct text_object *, char *p,
unsigned int p_max_size) {
snprintf(p, p_max_size, "%d", get_res().playlist_length);
}
void print_audacious_playlist_position(struct text_object *, char *p,
unsigned int p_max_size) {
snprintf(p, p_max_size, "%d", get_res().playlist_position + 1);
}
void print_audacious_main_volume(struct text_object *, char *p,
unsigned int p_max_size) {
snprintf(p, p_max_size, "%d", get_res().main_volume);
}