[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;
|
Widget *widget;
|
||||||
char *p, *property = NULL, *command;
|
char *p, *property = NULL, *command;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
widget_tell_status_t status;
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
{
|
{
|
||||||
|
@ -228,44 +229,44 @@ uicb_widget_tell(int screen, char *arg)
|
||||||
len = a_strlen(p);
|
len = a_strlen(p);
|
||||||
command = p_new(char, len + 1);
|
command = p_new(char, len + 1);
|
||||||
a_strncpy(command, len + 1, p, len);
|
a_strncpy(command, len + 1, p, len);
|
||||||
switch(widget->tell(widget, property, command))
|
status = 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;
|
|
||||||
}
|
|
||||||
p_delete(&command);
|
p_delete(&command);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
widget->tell(widget, property, NULL);
|
status = WIDGET_ERROR_NOVALUE;
|
||||||
|
|
||||||
widget->cache.needs_update = True;
|
switch(status)
|
||||||
|
{
|
||||||
return;
|
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
|
// 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)
|
if(!d->data_items)
|
||||||
return WIDGET_ERROR_CUSTOM; /* error already printed on _new */
|
return WIDGET_ERROR_CUSTOM; /* error already printed on _new */
|
||||||
|
|
||||||
if(!command)
|
|
||||||
return WIDGET_ERROR_NOVALUE;
|
|
||||||
|
|
||||||
if(!a_strcmp(property, "data"))
|
if(!a_strcmp(property, "data"))
|
||||||
{
|
{
|
||||||
title = strtok(command, " ");
|
title = strtok(command, " ");
|
||||||
|
|
|
@ -388,9 +388,6 @@ progressbar_tell(Widget *widget, char *property, char *command)
|
||||||
if(!d->data_items)
|
if(!d->data_items)
|
||||||
return WIDGET_ERROR_CUSTOM; /* error already printed on _new */
|
return WIDGET_ERROR_CUSTOM; /* error already printed on _new */
|
||||||
|
|
||||||
if(!command)
|
|
||||||
return WIDGET_ERROR_NOVALUE;
|
|
||||||
|
|
||||||
if(!a_strcmp(property, "data"))
|
if(!a_strcmp(property, "data"))
|
||||||
{
|
{
|
||||||
title = strtok(command, " ");
|
title = strtok(command, " ");
|
||||||
|
|
|
@ -74,9 +74,6 @@ textbox_tell(Widget *widget, char *property, char *command)
|
||||||
p_delete(&d->text);
|
p_delete(&d->text);
|
||||||
d->text = a_strdup(command);
|
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"))
|
else if(!a_strcmp(property, "fg"))
|
||||||
if(draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->style.fg))
|
if(draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->style.fg))
|
||||||
return WIDGET_NOERROR;
|
return WIDGET_NOERROR;
|
||||||
|
|
Loading…
Reference in New Issue