From 997805c46b3c558722471826a50c0f5b338635cf Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 23 Nov 2009 23:48:12 +0100 Subject: [PATCH] convert smapi_bat_bar to callbacks.barval --- src/core.c | 2 +- src/smapi.c | 11 +++-------- src/smapi.h | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/core.c b/src/core.c index e81be898..878bbaee 100644 --- a/src/core.c +++ b/src/core.c @@ -1082,7 +1082,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long obj->data.i = -1; } else arg = scan_bar(obj, arg + cnt); - obj->callbacks.print = &print_smapi_bat_bar; + obj->callbacks.barval = &smapi_bat_barval; #endif /* IBM */ #ifdef MPD #define mpd_set_maxlen(name) \ diff --git a/src/smapi.c b/src/smapi.c index 8c8c4d9a..48cf9a72 100644 --- a/src/smapi.c +++ b/src/smapi.c @@ -172,14 +172,9 @@ void print_smapi_bat_power(struct text_object *obj, char *p, int p_max_size) NORM_ERR("argument to smapi_bat_power must be an integer"); } -void print_smapi_bat_bar(struct text_object *obj, char *p, int p_max_size) +uint8_t smapi_bat_barval(struct text_object *obj) { - if (!p_max_size) - return; - if (obj->data.i >= 0 && smapi_bat_installed(obj->data.i)) - new_bar(obj, p, p_max_size, (int) - (255 * smapi_get_bat_int(obj->data.i, "remaining_percent") / 100)); - else - new_bar(obj, p, p_max_size, 0); + return round_to_int(smapi_get_bat_int(obj->data.i, "remaining_percent") * 2.55); + return 0; } diff --git a/src/smapi.h b/src/smapi.h index 70a73d2f..c7a74e75 100644 --- a/src/smapi.h +++ b/src/smapi.h @@ -40,6 +40,6 @@ void print_smapi(struct text_object *, char *, int); void print_smapi_bat_perc(struct text_object *, char *, int); void print_smapi_bat_temp(struct text_object *, char *, int); void print_smapi_bat_power(struct text_object *, char *, int); -void print_smapi_bat_bar(struct text_object *, char *, int); +uint8_t smapi_bat_barval(struct text_object *); #endif /* _SMAPI_H */