mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 17:47:09 +00:00
convert fs bars to callbacks.barval
This commit is contained in:
parent
a5ff5d39d0
commit
4f8e700d64
@ -588,10 +588,10 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
|||||||
scan_pre_exec_arg(obj, arg);
|
scan_pre_exec_arg(obj, arg);
|
||||||
END OBJ(fs_bar, &update_fs_stats)
|
END OBJ(fs_bar, &update_fs_stats)
|
||||||
init_fs_bar(obj, arg);
|
init_fs_bar(obj, arg);
|
||||||
obj->callbacks.print = &print_fs_bar;
|
obj->callbacks.barval = &fs_barval;
|
||||||
END OBJ(fs_bar_free, &update_fs_stats)
|
END OBJ(fs_bar_free, &update_fs_stats)
|
||||||
init_fs_bar(obj, arg);
|
init_fs_bar(obj, arg);
|
||||||
obj->callbacks.print = &print_fs_bar_free;
|
obj->callbacks.barval = &fs_free_barval;
|
||||||
END OBJ(fs_free, &update_fs_stats)
|
END OBJ(fs_free, &update_fs_stats)
|
||||||
init_fs(obj, arg);
|
init_fs(obj, arg);
|
||||||
obj->callbacks.print = &print_fs_free;
|
obj->callbacks.print = &print_fs_free;
|
||||||
|
14
src/fs.c
14
src/fs.c
@ -211,13 +211,13 @@ void init_fs_bar(struct text_object *obj, const char *arg)
|
|||||||
obj->data.opaque = prepare_fs_stat(arg);
|
obj->data.opaque = prepare_fs_stat(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_size)
|
static uint8_t do_fs_barval(struct text_object *obj, int be_free_bar)
|
||||||
{
|
{
|
||||||
double val = 1.0;
|
double val = 1.0;
|
||||||
struct fs_stat *fs = obj->data.opaque;
|
struct fs_stat *fs = obj->data.opaque;
|
||||||
|
|
||||||
if (!fs)
|
if (!fs)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
if (fs->size)
|
if (fs->size)
|
||||||
val = (double)fs->avail / (double)fs->size;
|
val = (double)fs->avail / (double)fs->size;
|
||||||
@ -225,17 +225,17 @@ static void do_print_fs_bar(struct text_object *obj, int be_free_bar, char *p, i
|
|||||||
if (!be_free_bar)
|
if (!be_free_bar)
|
||||||
val = 1.0 - val;
|
val = 1.0 - val;
|
||||||
|
|
||||||
new_bar(obj, p, p_max_size, (int)(255 * val));
|
return round_to_int(val * 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_fs_bar(struct text_object *obj, char *p, int p_max_size)
|
uint8_t fs_barval(struct text_object *obj)
|
||||||
{
|
{
|
||||||
do_print_fs_bar(obj, 0, p, p_max_size);
|
return do_fs_barval(obj, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_fs_bar_free(struct text_object *obj, char *p, int p_max_size)
|
uint8_t fs_free_barval(struct text_object *obj)
|
||||||
{
|
{
|
||||||
do_print_fs_bar(obj, 1, p, p_max_size);
|
return do_fs_barval(obj, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_fs(struct text_object *obj, const char *arg)
|
void init_fs(struct text_object *obj, const char *arg)
|
||||||
|
4
src/fs.h
4
src/fs.h
@ -19,8 +19,8 @@ struct fs_stat {
|
|||||||
struct text_object;
|
struct text_object;
|
||||||
|
|
||||||
void init_fs_bar(struct text_object *, const char *);
|
void init_fs_bar(struct text_object *, const char *);
|
||||||
void print_fs_bar(struct text_object *, char *, int);
|
uint8_t fs_barval(struct text_object *);
|
||||||
void print_fs_bar_free(struct text_object *, char *, int);
|
uint8_t fs_free_barval(struct text_object *);
|
||||||
|
|
||||||
void init_fs(struct text_object *, const char *);
|
void init_fs(struct text_object *, const char *);
|
||||||
void print_fs_free_perc(struct text_object *, char *, int);
|
void print_fs_free_perc(struct text_object *, char *, int);
|
||||||
|
Loading…
Reference in New Issue
Block a user