From c582f4397b56e763e5ef6eecbd22e96a0594cee1 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 2 Apr 2008 15:31:19 +0200 Subject: [PATCH] [widgets] Check for no value in uicb_widget_tell and only update sbar on no error Signed-off-by: Julien Danjou --- widget.c | 69 ++++++++++++++++++++++--------------------- widgets/graph.c | 3 -- widgets/progressbar.c | 3 -- widgets/textbox.c | 3 -- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/widget.c b/widget.c index 16502948..72f7586c 100644 --- a/widget.c +++ b/widget.c @@ -187,6 +187,7 @@ uicb_widget_tell(int screen, char *arg) Widget *widget; char *p, *property = NULL, *command; ssize_t len; + widget_tell_status_t status; if (!arg) { @@ -228,44 +229,44 @@ uicb_widget_tell(int screen, char *arg) len = a_strlen(p); command = p_new(char, len + 1); a_strncpy(command, len + 1, p, len); - switch(widget->tell(widget, property, command)) - { - case WIDGET_ERROR: - warn("error changing property %s of widget %s\n", - property, widget->name); - break; - case WIDGET_ERROR_NOVALUE: - warn("error changing property %s of widget %s, no value given\n", - property, widget->name); - break; - case WIDGET_ERROR_FORMAT_BOOL: - warn("error changing property %s of widget %s, must is boolean (0 or 1)\n", - property, widget->name); - break; - case WIDGET_ERROR_FORMAT_FONT: - warn("error changing property %s of widget %s, must be a valid font\n", - property, widget->name); - break; - case WIDGET_ERROR_FORMAT_COLOR: - warn("error changing property %s of widget %s, must be a valid color\n", - property, widget->name); - break; - case WIDGET_ERROR_FORMAT_SECTION: - warn("error changing property %s of widget %s, section/title not found\n", - property, widget->name); - break; - case WIDGET_NOERROR: - case WIDGET_ERROR_CUSTOM: - break; - } + status = widget->tell(widget, property, command); p_delete(&command); } else - widget->tell(widget, property, NULL); + status = WIDGET_ERROR_NOVALUE; - widget->cache.needs_update = True; - - return; + switch(status) + { + case WIDGET_ERROR: + warn("error changing property %s of widget %s\n", + property, widget->name); + break; + case WIDGET_ERROR_NOVALUE: + warn("error changing property %s of widget %s, no value given\n", + property, widget->name); + break; + case WIDGET_ERROR_FORMAT_BOOL: + warn("error changing property %s of widget %s, must is boolean (0 or 1)\n", + property, widget->name); + break; + case WIDGET_ERROR_FORMAT_FONT: + warn("error changing property %s of widget %s, must be a valid font\n", + property, widget->name); + break; + case WIDGET_ERROR_FORMAT_COLOR: + warn("error changing property %s of widget %s, must be a valid color\n", + property, widget->name); + break; + case WIDGET_ERROR_FORMAT_SECTION: + warn("error changing property %s of widget %s, section/title not found\n", + property, widget->name); + break; + case WIDGET_NOERROR: + widget->cache.needs_update = True; + break; + case WIDGET_ERROR_CUSTOM: + break; + } } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/widgets/graph.c b/widgets/graph.c index bfbb8b34..cbf7a460 100644 --- a/widgets/graph.c +++ b/widgets/graph.c @@ -271,9 +271,6 @@ graph_tell(Widget *widget, char *property, char *command) if(!d->data_items) return WIDGET_ERROR_CUSTOM; /* error already printed on _new */ - if(!command) - return WIDGET_ERROR_NOVALUE; - if(!a_strcmp(property, "data")) { title = strtok(command, " "); diff --git a/widgets/progressbar.c b/widgets/progressbar.c index d75bf1d0..b090195a 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -388,9 +388,6 @@ progressbar_tell(Widget *widget, char *property, char *command) if(!d->data_items) return WIDGET_ERROR_CUSTOM; /* error already printed on _new */ - if(!command) - return WIDGET_ERROR_NOVALUE; - if(!a_strcmp(property, "data")) { title = strtok(command, " "); diff --git a/widgets/textbox.c b/widgets/textbox.c index df33c66f..a3b41d43 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -74,9 +74,6 @@ textbox_tell(Widget *widget, char *property, char *command) p_delete(&d->text); d->text = a_strdup(command); } - /* !command means a not existing string. So return here */ - else if(!command) - return WIDGET_ERROR_NOVALUE; else if(!a_strcmp(property, "fg")) if(draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->style.fg)) return WIDGET_NOERROR;