1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

audacious: convert to callbacks.print

This commit is contained in:
Phil Sutter 2009-11-08 19:19:42 +01:00
parent 974d28a667
commit 6371551153
4 changed files with 71 additions and 64 deletions

View File

@ -254,3 +254,44 @@ void *audacious_thread_func(void *pvoid)
}
}
}
void print_audacious_title(struct text_object *obj, char *p, int p_max_size)
{
snprintf(p, info.audacious.max_title_len > 0
? info.audacious.max_title_len : p_max_size, "%s",
info.audacious.items[AUDACIOUS_TITLE]);
}
void print_audacious_bar(struct text_object *obj, char *p, int p_max_size)
{
double progress;
if (!p_max_size)
return;
progress =
atof(info.audacious.items[AUDACIOUS_POSITION_SECONDS]) /
atof(info.audacious.items[AUDACIOUS_LENGTH_SECONDS]);
new_bar(obj, p, p_max_size, (int) (progress * 255.0f));
}
#define AUDACIOUS_PRINT_GENERATOR(name, idx) \
void print_audacious_##name(struct text_object *obj, char *p, int p_max_size) \
{ \
snprintf(p, p_max_size, "%s", info.audacious.items[AUDACIOUS_##idx]); \
}
AUDACIOUS_PRINT_GENERATOR(status, STATUS)
AUDACIOUS_PRINT_GENERATOR(length, LENGTH)
AUDACIOUS_PRINT_GENERATOR(length_seconds, LENGTH_SECONDS)
AUDACIOUS_PRINT_GENERATOR(position, POSITION)
AUDACIOUS_PRINT_GENERATOR(position_seconds, POSITION_SECONDS)
AUDACIOUS_PRINT_GENERATOR(bitrate, BITRATE)
AUDACIOUS_PRINT_GENERATOR(frequency, FREQUENCY)
AUDACIOUS_PRINT_GENERATOR(channels, CHANNELS)
AUDACIOUS_PRINT_GENERATOR(filename, FILENAME)
AUDACIOUS_PRINT_GENERATOR(playlist_length, PLAYLIST_LENGTH)
AUDACIOUS_PRINT_GENERATOR(playlist_position, PLAYLIST_POSITION)
AUDACIOUS_PRINT_GENERATOR(main_volume, MAIN_VOLUME)
#undef AUDACIOUS_PRINT_GENERATOR

View File

@ -65,4 +65,19 @@ void update_audacious(void);
/* Thread functions */
void *audacious_thread_func(void *);
void print_audacious_status(struct text_object *, char *, int);
void print_audacious_title(struct text_object *, char *, int);
void print_audacious_length(struct text_object *, char *, int);
void print_audacious_length_seconds(struct text_object *, char *, int);
void print_audacious_position(struct text_object *, char *, int);
void print_audacious_position_seconds(struct text_object *, char *, int);
void print_audacious_bitrate(struct text_object *, char *, int);
void print_audacious_frequency(struct text_object *, char *, int);
void print_audacious_channels(struct text_object *, char *, int);
void print_audacious_filename(struct text_object *, char *, int);
void print_audacious_playlist_length(struct text_object *, char *, int);
void print_audacious_playlist_position(struct text_object *, char *, int);
void print_audacious_main_volume(struct text_object *, char *, int);
void print_audacious_bar(struct text_object *, char *, int);
#endif

View File

@ -1635,69 +1635,6 @@ void generate_text_internal(char *p, int p_max_size,
}
}
#endif /* XMMS */
#ifdef AUDACIOUS
OBJ(audacious_status) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_STATUS]);
}
OBJ(audacious_title) {
snprintf(p, cur->audacious.max_title_len > 0
? cur->audacious.max_title_len : p_max_size, "%s",
cur->audacious.items[AUDACIOUS_TITLE]);
}
OBJ(audacious_length) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_LENGTH]);
}
OBJ(audacious_length_seconds) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
}
OBJ(audacious_position) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_POSITION]);
}
OBJ(audacious_position_seconds) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_POSITION_SECONDS]);
}
OBJ(audacious_bitrate) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_BITRATE]);
}
OBJ(audacious_frequency) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_FREQUENCY]);
}
OBJ(audacious_channels) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_CHANNELS]);
}
OBJ(audacious_filename) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_FILENAME]);
}
OBJ(audacious_playlist_length) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_PLAYLIST_LENGTH]);
}
OBJ(audacious_playlist_position) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_PLAYLIST_POSITION]);
}
OBJ(audacious_main_volume) {
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_MAIN_VOLUME]);
}
OBJ(audacious_bar) {
double progress;
progress =
atof(cur->audacious.items[AUDACIOUS_POSITION_SECONDS]) /
atof(cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
new_bar(obj, p, p_max_size, (int) (progress * 255.0f));
}
#endif /* AUDACIOUS */
#ifdef BMPX
OBJ(bmpx_title) {

View File

@ -1168,6 +1168,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
#endif
#ifdef AUDACIOUS
END OBJ(audacious_status, &update_audacious)
obj->callbacks.print = &print_audacious_status;
END OBJ_ARG(audacious_title, &update_audacious, "audacious_title needs an argument")
sscanf(arg, "%d", &info.audacious.max_title_len);
if (info.audacious.max_title_len > 0) {
@ -1175,20 +1176,33 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
} else {
CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
}
obj->callbacks.print = &print_audacious_title;
END OBJ(audacious_length, &update_audacious)
obj->callbacks.print = &print_audacious_length;
END OBJ(audacious_length_seconds, &update_audacious)
obj->callbacks.print = &print_audacious_length_seconds;
END OBJ(audacious_position, &update_audacious)
obj->callbacks.print = &print_audacious_position;
END OBJ(audacious_position_seconds, &update_audacious)
obj->callbacks.print = &print_audacious_position_seconds;
END OBJ(audacious_bitrate, &update_audacious)
obj->callbacks.print = &print_audacious_bitrate;
END OBJ(audacious_frequency, &update_audacious)
obj->callbacks.print = &print_audacious_frequency;
END OBJ(audacious_channels, &update_audacious)
obj->callbacks.print = &print_audacious_channels;
END OBJ(audacious_filename, &update_audacious)
obj->callbacks.print = &print_audacious_filename;
END OBJ(audacious_playlist_length, &update_audacious)
obj->callbacks.print = &print_audacious_playlist_length;
END OBJ(audacious_playlist_position, &update_audacious)
obj->callbacks.print = &print_audacious_playlist_position;
END OBJ(audacious_main_volume, &update_audacious)
obj->callbacks.print = &print_audacious_main_volume;
END OBJ(audacious_bar, &update_audacious)
scan_bar(obj, arg);
#endif
obj->callbacks.print = &print_audacious_bar;
#endif /* AUDACIOUS */
#ifdef BMPX
END OBJ(bmpx_title, &update_bmpx)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));