From 841a3814c807c1a4b2637aa3f3bf3ae857da1699 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 29 Nov 2009 19:48:24 +0100 Subject: [PATCH] convert $updates to callbacks.print --- src/common.c | 6 ++++++ src/common.h | 3 ++- src/conky.c | 8 +++++--- src/conky.h | 1 + src/core.c | 1 + 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common.c b/src/common.c index a76989f1..0bc47889 100644 --- a/src/common.c +++ b/src/common.c @@ -792,3 +792,9 @@ void print_include(struct text_object *obj, char *p, int p_max_size) generate_text_internal(buf, max_user_text, *obj->sub, &info); snprintf(p, p_max_size, "%s", buf); } + +void print_updates(struct text_object *obj, char *p, int p_max_size) +{ + (void)obj; + snprintf(p, p_max_size, "%d", get_total_updates()); +} diff --git a/src/common.h b/src/common.h index e5117065..f549e615 100644 --- a/src/common.h +++ b/src/common.h @@ -15,7 +15,6 @@ void add_update_callback(void (*func)(void)); void free_update_callbacks(void); void start_update_threading(void); - void strfold(char *start, int count); int check_mount(struct text_object *); void prepare_update(void); @@ -129,4 +128,6 @@ void print_to_bytes(struct text_object *, char *, int); void print_blink(struct text_object *, char *, int); void print_include(struct text_object *, char *, int); +void print_updates(struct text_object *, char *, int); + #endif /* _COMMON_H */ diff --git a/src/conky.c b/src/conky.c index a3f21f5f..3c7f6f02 100644 --- a/src/conky.c +++ b/src/conky.c @@ -425,6 +425,11 @@ int get_updatereset(void) return updatereset; } +int get_total_updates(void) +{ + return total_updates; +} + #define SECRIT_MULTILINE_CHAR '\x02' static inline int calc_text_width(const char *s) @@ -792,9 +797,6 @@ void generate_text_internal(char *p, int p_max_size, OBJ(text) { snprintf(p, p_max_size, "%s", obj->data.s); } - OBJ(updates) { - snprintf(p, p_max_size, "%d", total_updates); - } OBJ(if_updatenr) { if(total_updates % updatereset != obj->data.i - 1) { DO_JUMP; diff --git a/src/conky.h b/src/conky.h index 6ba7026c..696f6928 100644 --- a/src/conky.h +++ b/src/conky.h @@ -172,6 +172,7 @@ long get_current_text_color(void); void set_updatereset(int); int get_updatereset(void); +int get_total_updates(void); int percent_print(char *, int, unsigned); void human_readable(long long, char *, int); diff --git a/src/core.c b/src/core.c index 493b2884..edfe2f08 100644 --- a/src/core.c +++ b/src/core.c @@ -1057,6 +1057,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long parse_net_stat_arg(obj, arg, free_at_crash); obj->callbacks.print = &print_totalup; END OBJ(updates, 0) + obj->callbacks.print = &print_updates; END OBJ_IF(if_updatenr, 0) obj->data.i = arg ? atoi(arg) : 0; if(obj->data.i == 0) CRIT_ERR(obj, free_at_crash, "if_updatenr needs a number above 0 as argument");