From e56980332496d456be951c6f359b77fbdb8b8000 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 29 Nov 2009 19:50:59 +0100 Subject: [PATCH] convert if_updatenr to callbacks.iftest --- src/common.c | 7 +++++++ src/common.h | 1 + src/conky.c | 5 ----- src/core.c | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common.c b/src/common.c index 0bc47889..10104616 100644 --- a/src/common.c +++ b/src/common.c @@ -798,3 +798,10 @@ void print_updates(struct text_object *obj, char *p, int p_max_size) (void)obj; snprintf(p, p_max_size, "%d", get_total_updates()); } + +int updatenr_iftest(struct text_object *obj) +{ + if (get_total_updates() % get_updatereset() != obj->data.i - 1) + return 0; + return 1; +} diff --git a/src/common.h b/src/common.h index f549e615..072ecc47 100644 --- a/src/common.h +++ b/src/common.h @@ -129,5 +129,6 @@ void print_blink(struct text_object *, char *, int); void print_include(struct text_object *, char *, int); void print_updates(struct text_object *, char *, int); +int updatenr_iftest(struct text_object *); #endif /* _COMMON_H */ diff --git a/src/conky.c b/src/conky.c index 3c7f6f02..261bd16d 100644 --- a/src/conky.c +++ b/src/conky.c @@ -797,11 +797,6 @@ void generate_text_internal(char *p, int p_max_size, OBJ(text) { snprintf(p, p_max_size, "%s", obj->data.s); } - OBJ(if_updatenr) { - if(total_updates % updatereset != obj->data.i - 1) { - DO_JUMP; - } - } break; } diff --git a/src/core.c b/src/core.c index edfe2f08..82d9fda6 100644 --- a/src/core.c +++ b/src/core.c @@ -1062,6 +1062,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long 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"); set_updatereset(obj->data.i > get_updatereset() ? obj->data.i : get_updatereset()); + obj->callbacks.iftest = &updatenr_iftest; END OBJ(alignr, 0) obj->data.l = arg ? atoi(arg) : 1; obj->callbacks.print = &new_alignr;