From 7d34d0dd85ed305555167d50afc86ba80aebf157 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 20 May 2008 20:25:49 +0200 Subject: [PATCH] [dbus/widget] Correctly invalidate statusbars on update Signed-off-by: Julien Danjou --- dbus.c | 4 +++- widget.c | 65 +++++++++++++++++++++++++++++++------------------------- widget.h | 1 + 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/dbus.c b/dbus.c index 7b8a62d86..675f7a21a 100644 --- a/dbus.c +++ b/dbus.c @@ -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]); diff --git a/widget.c b/widget.c index 1e2af3f4c..9eaae1129 100644 --- a/widget.c +++ b/widget.c @@ -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; } diff --git a/widget.h b/widget.h index 47e4260e9..92d5bc5ed 100644 --- a/widget.h +++ b/widget.h @@ -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;