1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-29 05:12:41 +00:00

convert if_updatenr to callbacks.iftest

This commit is contained in:
Phil Sutter 2009-11-29 19:50:59 +01:00
parent 841a3814c8
commit e569803324
4 changed files with 9 additions and 5 deletions

View File

@ -798,3 +798,10 @@ void print_updates(struct text_object *obj, char *p, int p_max_size)
(void)obj; (void)obj;
snprintf(p, p_max_size, "%d", get_total_updates()); 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;
}

View File

@ -129,5 +129,6 @@ void print_blink(struct text_object *, char *, int);
void print_include(struct text_object *, char *, int); void print_include(struct text_object *, char *, int);
void print_updates(struct text_object *, char *, int); void print_updates(struct text_object *, char *, int);
int updatenr_iftest(struct text_object *);
#endif /* _COMMON_H */ #endif /* _COMMON_H */

View File

@ -797,11 +797,6 @@ void generate_text_internal(char *p, int p_max_size,
OBJ(text) { OBJ(text) {
snprintf(p, p_max_size, "%s", obj->data.s); snprintf(p, p_max_size, "%s", obj->data.s);
} }
OBJ(if_updatenr) {
if(total_updates % updatereset != obj->data.i - 1) {
DO_JUMP;
}
}
break; break;
} }

View File

@ -1062,6 +1062,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
obj->data.i = arg ? atoi(arg) : 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"); 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()); set_updatereset(obj->data.i > get_updatereset() ? obj->data.i : get_updatereset());
obj->callbacks.iftest = &updatenr_iftest;
END OBJ(alignr, 0) END OBJ(alignr, 0)
obj->data.l = arg ? atoi(arg) : 1; obj->data.l = arg ? atoi(arg) : 1;
obj->callbacks.print = &new_alignr; obj->callbacks.print = &new_alignr;