mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 17:47:09 +00:00
fs objects: convert to callbacks.print
This commit is contained in:
parent
18d2319d73
commit
e0a3a82932
11
src/conky.c
11
src/conky.c
@ -969,17 +969,6 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
OBJ(eval) {
|
||||
evaluate(obj->data.s, p, p_max_size);
|
||||
}
|
||||
OBJ(fs_bar) {
|
||||
print_fs_bar(obj, 0, p, p_max_size);
|
||||
}
|
||||
OBJ(fs_free_perc) {
|
||||
print_fs_perc(obj, 1, p, p_max_size);
|
||||
}
|
||||
OBJ(fs_bar_free) {
|
||||
print_fs_bar(obj, 1, p, p_max_size);
|
||||
}
|
||||
OBJ(fs_used_perc) {
|
||||
print_fs_perc(obj, 0, p, p_max_size);
|
||||
}
|
||||
#ifdef HDDTEMP
|
||||
OBJ(hddtemp) {
|
||||
|
@ -576,15 +576,19 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
scan_pre_exec_arg(obj, arg);
|
||||
END OBJ(fs_bar, &update_fs_stats)
|
||||
init_fs_bar(obj, arg);
|
||||
obj->callbacks.print = &print_fs_bar;
|
||||
END OBJ(fs_bar_free, &update_fs_stats)
|
||||
init_fs_bar(obj, arg);
|
||||
obj->callbacks.print = &print_fs_bar_free;
|
||||
END OBJ(fs_free, &update_fs_stats)
|
||||
init_fs(obj, arg);
|
||||
obj->callbacks.print = &print_fs_free;
|
||||
END OBJ(fs_used_perc, &update_fs_stats)
|
||||
init_fs(obj, arg);
|
||||
obj->callbacks.print = &print_fs_used_perc;
|
||||
END OBJ(fs_free_perc, &update_fs_stats)
|
||||
init_fs(obj, arg);
|
||||
obj->callbacks.print = &print_fs_free_perc;
|
||||
END OBJ(fs_size, &update_fs_stats)
|
||||
init_fs(obj, arg);
|
||||
obj->callbacks.print = &print_fs_size;
|
||||
|
24
src/fs.c
24
src/fs.c
@ -211,7 +211,7 @@ void init_fs_bar(struct text_object *obj, const char *arg)
|
||||
obj->data.opaque = prepare_fs_stat(arg);
|
||||
}
|
||||
|
||||
void print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_size)
|
||||
static void do_print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_size)
|
||||
{
|
||||
double val = 1.0;
|
||||
struct fs_stat *fs = obj->data.opaque;
|
||||
@ -228,12 +228,22 @@ void print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_s
|
||||
new_bar(obj, p, p_max_size, (int)(255 * val));
|
||||
}
|
||||
|
||||
void print_fs_bar(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
do_print_fs_bar(obj, 0, p, p_max_size);
|
||||
}
|
||||
|
||||
void print_fs_bar_free(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
do_print_fs_bar(obj, 1, p, p_max_size);
|
||||
}
|
||||
|
||||
void init_fs(struct text_object *obj, const char *arg)
|
||||
{
|
||||
obj->data.opaque = prepare_fs_stat(arg ? arg : "/");
|
||||
}
|
||||
|
||||
void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size)
|
||||
static void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size)
|
||||
{
|
||||
struct fs_stat *fs = obj->data.opaque;
|
||||
int val = 100;
|
||||
@ -250,6 +260,16 @@ void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size
|
||||
percent_print(p, p_max_size, val);
|
||||
}
|
||||
|
||||
void print_fs_free_perc(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
print_fs_perc(obj, 1, p, p_max_size);
|
||||
}
|
||||
|
||||
void print_fs_used_perc(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
print_fs_perc(obj, 0, p, p_max_size);
|
||||
}
|
||||
|
||||
#define HUMAN_PRINT_FS_GENERATOR(name, expr) \
|
||||
void print_fs_##name(struct text_object *obj, char *p, int p_max_size) \
|
||||
{ \
|
||||
|
6
src/fs.h
6
src/fs.h
@ -19,10 +19,12 @@ struct fs_stat {
|
||||
struct text_object;
|
||||
|
||||
void init_fs_bar(struct text_object *, const char *);
|
||||
void print_fs_bar(struct text_object *, int, char *, int);
|
||||
void print_fs_bar(struct text_object *, char *, int);
|
||||
void print_fs_bar_free(struct text_object *, char *, int);
|
||||
|
||||
void init_fs(struct text_object *, const char *);
|
||||
void print_fs_perc(struct text_object *, int, char *, int);
|
||||
void print_fs_free_perc(struct text_object *, char *, int);
|
||||
void print_fs_used_perc(struct text_object *, char *, int);
|
||||
void print_fs_free(struct text_object *, char *, int);
|
||||
void print_fs_size(struct text_object *, char *, int);
|
||||
void print_fs_used(struct text_object *, char *, int);
|
||||
|
Loading…
Reference in New Issue
Block a user