[widgets] Check for no value in uicb_widget_tell and only update sbar on no error
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
2456f6d62a
commit
c582f4397b
69
widget.c
69
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
|
||||
|
|
|
@ -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, " ");
|
||||
|
|
|
@ -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, " ");
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue