From 28830c0dc90385318825babeb7f62b8b0de2b280 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 23 Jun 2008 13:24:03 +0200 Subject: [PATCH] textbox: use tokenize Signed-off-by: Julien Danjou --- common/tokenize.gperf | 1 + widgets/progressbar.c | 6 ++++-- widgets/textbox.c | 12 ++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/tokenize.gperf b/common/tokenize.gperf index 2e56187a..f4dc6d15 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -23,6 +23,7 @@ min_value reverse right scale +text ticks_count ticks_gap top diff --git a/widgets/progressbar.c b/widgets/progressbar.c index d7c7512d..cdbcfe6b 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -412,7 +412,8 @@ progressbar_tell(widget_t *widget, const char *property, const char *new_value) if(!new_value) return WIDGET_ERROR_NOVALUE; - switch (prop) { + switch (prop) + { case A_TK_GAP: d->gap = atoi(new_value); return WIDGET_NOERROR; @@ -470,7 +471,8 @@ progressbar_tell(widget_t *widget, const char *property, const char *new_value) return WIDGET_ERROR; } - switch (prop) { + switch (prop) + { case A_TK_DATA: value = atof(setting); bar->value = (value < bar->min_value ? bar->min_value : diff --git a/widgets/textbox.c b/widgets/textbox.c index 5aa3cf68..c01ef147 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -24,6 +24,7 @@ #include "screen.h" #include "common/util.h" #include "common/configopts.h" +#include "common/tokenize.h" extern awesome_t globalconf; @@ -73,15 +74,18 @@ textbox_tell(widget_t *widget, const char *property, const char *new_value) { textbox_data_t *d = widget->data; - if(!a_strcmp(property, "text")) + switch(a_tokenize(property, -1)) { + case A_TK_TEXT: p_delete(&d->text); a_iso2utf8(new_value, &d->text); - } - else if(!a_strcmp(property, "width")) + break; + case A_TK_WIDTH: d->width = atoi(new_value); - else + break; + default: return WIDGET_ERROR; + } return WIDGET_NOERROR; }