[dbus/widget] Correctly invalidate statusbars on update

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-20 20:25:49 +02:00
parent 4742463cec
commit 7d34d0dd85
3 changed files with 40 additions and 30 deletions

4
dbus.c
View File

@ -57,6 +57,7 @@ a_dbus_process_widget_set(DBusMessage *req)
int i;
DBusMessageIter iter;
widget_t *widget;
widget_tell_status_t status;
if(!dbus_message_get_path_decomposed(req, &path)
|| !a_dbus_path_check(path, 6)
@ -86,7 +87,8 @@ a_dbus_process_widget_set(DBusMessage *req)
if(!(widget = widget_getbyname(path[3])))
return warn("no such widget: %s.\n", path[3]);
widget->tell(widget, path[5], arg);
status = widget->tell(widget, path[5], arg);
widget_tell_managestatus(widget, status, path[5]);
for(i = 0; path[i]; i++)
p_delete(&path[i]);

View File

@ -141,6 +141,7 @@ widget_invalidate_statusbar_bywidget(widget_t *widget)
statusbar_t *statusbar;
widget_node_t *witer;
warn("invalidate %p\n", widget);
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
for(statusbar = globalconf.screens[screen].statusbar;
statusbar;
@ -219,6 +220,39 @@ luaA_widget_mouse(lua_State *L)
return 0;
}
void
widget_tell_managestatus(widget_t *widget, widget_tell_status_t status, const char *property)
{
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_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_invalidate_statusbar_bywidget(widget);
break;
case WIDGET_ERROR_CUSTOM:
break;
}
}
static int
luaA_widget_set(lua_State *L)
{
@ -229,35 +263,8 @@ luaA_widget_set(lua_State *L)
property = luaL_checkstring(L, 2);
value = luaL_checkstring(L, 3);
switch((status = (*widget)->tell(*widget, property, value)))
{
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_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_invalidate_statusbar_bywidget(*widget);
break;
case WIDGET_ERROR_CUSTOM:
break;
}
status = (*widget)->tell(*widget, property, value);
widget_tell_managestatus(*widget, status, property);
return 0;
}

View File

@ -37,6 +37,7 @@ int widget_calculate_offset(int, int, int, int);
void widget_common_new(widget_t *);
widget_t * widget_getbyname(const char *);
void widget_invalidate_statusbar_bywidget(widget_t *);
void widget_tell_managestatus(widget_t *, widget_tell_status_t, const char *);
WidgetConstructor taglist_new;
WidgetConstructor textbox_new;