1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

battery_bar: convert to callbacks.barval

This commit is contained in:
Phil Sutter 2009-11-22 21:54:02 +01:00
parent a11a1a1253
commit 4e63422d10
5 changed files with 9 additions and 11 deletions

View File

@ -65,7 +65,7 @@ void get_acpi_ac_adapter(char *, size_t);
void get_acpi_fan(char *, size_t);
void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
int get_battery_perct(const char *bat);
int get_battery_perct_bar(const char *bat);
uint8_t get_battery_perct_bar(struct text_object *);
void get_battery_short_status(char *buf, unsigned int n, const char *bat);
void scan_loadavg_arg(struct text_object *, const char *);

View File

@ -860,9 +860,6 @@ void generate_text_internal(char *p, int p_max_size,
OBJ(battery_percent) {
percent_print(p, p_max_size, get_battery_perct(obj->data.s));
}
OBJ(battery_bar) {
new_bar(obj, p, p_max_size, get_battery_perct_bar(obj->data.s));
}
OBJ(battery_short) {
get_battery_short_status(p, p_max_size, obj->data.s);
}

View File

@ -289,6 +289,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
strcpy(bat, "BAT0");
}
obj->data.s = strndup(bat, text_buffer_size);
obj->callbacks.barval = &get_battery_perct_bar;
obj->callbacks.free = &gen_free_opaque;
#endif /* !__OpenBSD__ */

View File

@ -471,10 +471,10 @@ int get_battery_perct(const char *bat)
return batperct > 100 ? 100 : batperct;
}
int get_battery_perct_bar(const char *bar)
uint8_t get_battery_perct_bar(struct text_object *obj)
{
int batperct = get_battery_perct(bar);
return (int)(batperct * 2.56 - 1);
int batperct = get_battery_perct(obj->data.s);
return round_to_int((double)batperct * 2.55);
}
int open_acpi_temperature(const char *name)

View File

@ -2054,13 +2054,13 @@ int get_battery_perct(const char *bat)
return last_battery_perct[idx];
}
int get_battery_perct_bar(const char *bar)
uint8_t get_battery_perct_bar(struct text_object *obj)
{
int idx;
get_battery_perct(bar);
idx = get_battery_idx(bar);
return (int) (last_battery_perct[idx] * 2.56 - 1);
get_battery_perct(obj->data.s);
idx = get_battery_idx(obj->data.s);
return round_to_int((double)last_battery_perct[idx] * 2.55);
}
/* On Apple powerbook and ibook: