[dbus] Fix widget.set() API call

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-20 20:13:44 +02:00
parent 597719e5aa
commit 4742463cec
3 changed files with 18 additions and 24 deletions

27
dbus.c
View File

@ -54,19 +54,16 @@ static void
a_dbus_process_widget_set(DBusMessage *req)
{
char *arg, **path;
int i, screen;
int i;
DBusMessageIter iter;
statusbar_t *statusbar;
widget_t *widget;
if(!dbus_message_get_path_decomposed(req, &path)
|| !a_dbus_path_check(path, 10)
|| a_strcmp(path[2], "screen")
|| a_strcmp(path[4], "statusbar")
|| a_strcmp(path[6], "widget")
|| a_strcmp(path[8], "property"))
|| !a_dbus_path_check(path, 6)
|| a_strcmp(path[2], "widget")
|| a_strcmp(path[4], "property"))
{
warn("invalid object path 2\n");
warn("invalid object path.\n");
dbus_error_free(&err);
return;
}
@ -86,16 +83,10 @@ a_dbus_process_widget_set(DBusMessage *req)
else
dbus_message_iter_get_basic(&iter, &arg);
if((screen = atoi(path[3])) >= globalconf.screens_info->nscreen)
return warn("bad screen number\n");
if(!(widget = widget_getbyname(path[3])))
return warn("no such widget: %s.\n", path[3]);
if(!(statusbar = statusbar_getbyname(screen, path[5])))
return warn("no such statusbar: %s\n", path[5]);
if(!(widget = widget_getbyname(statusbar, path[7])))
return warn("no such widget: %s in statusbar %s.\n", path[7], statusbar->name);
widget->tell(widget, path[9], arg);
widget->tell(widget, path[5], arg);
for(i = 0; path[i]; i++)
p_delete(&path[i]);
@ -119,7 +110,7 @@ a_dbus_process_requests(int *fd)
break;
if(dbus_message_is_method_call(msg, "org.awesome.statusbar.widget", "set"))
if(dbus_message_is_method_call(msg, "org.awesome.widget", "set"))
a_dbus_process_widget_set(msg);
else if(dbus_message_is_signal(msg, DBUS_INTERFACE_LOCAL, "Disconnected"))
{

View File

@ -48,15 +48,18 @@ widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment
}
/** Find a widget on a screen by its name.
* \param statusbar The statusbar to look into.
* \param name The widget name.
* \return A widget pointer.
*/
widget_t *
widget_getbyname(statusbar_t *sb, char *name)
widget_getbyname(const char *name)
{
widget_node_t *widget;
statusbar_t *sb;
int screen;
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
for(sb = globalconf.screens[screen].statusbar; sb; sb = sb->next)
for(widget = sb->widgets; widget; widget = widget->next)
if(!a_strcmp(name, widget->widget->name))
return widget->widget;

View File

@ -35,7 +35,7 @@ typedef widget_t *(WidgetConstructor)(alignment_t);
void widget_invalidate_cache(int, int);
int widget_calculate_offset(int, int, int, int);
void widget_common_new(widget_t *);
widget_t * widget_getbyname(statusbar_t *, char *);
widget_t * widget_getbyname(const char *);
void widget_invalidate_statusbar_bywidget(widget_t *);
WidgetConstructor taglist_new;