ta{g,sk}list: check dofunction return value

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-29 11:03:57 +02:00
parent 79dc1a9501
commit 84ff146083
2 changed files with 26 additions and 24 deletions

View File

@ -105,23 +105,24 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w,
tag_t *tag = tags->tab[i]; tag_t *tag = tags->tab[i];
luaA_tag_userdata_new(globalconf.L, tag); luaA_tag_userdata_new(globalconf.L, tag);
luaA_dofunction(globalconf.L, data->label, 1, 1); if(luaA_dofunction(globalconf.L, data->label, 1, 1))
{
if(lua_isstring(globalconf.L, -1))
text[i] = lua_tolstring(globalconf.L, -1, &len[i]);
if(lua_isstring(globalconf.L, -1)) lua_pop(globalconf.L, 1);
text[i] = lua_tolstring(globalconf.L, -1, &len[i]);
lua_pop(globalconf.L, 1); draw_parser_data_init(&pdata[i]);
area = draw_text_extents(ctx->connection, ctx->phys_screen,
globalconf.font, text[i], len[i], &pdata[i]);
draw_parser_data_init(&pdata[i]); if(pdata[i].bg_image)
area = draw_text_extents(ctx->connection, ctx->phys_screen, area.width = MAX(area.width, pdata[i].bg_resize ? w->area.height : pdata[i].bg_image->width);
globalconf.font, text[i], len[i], &pdata[i]);
if(pdata[i].bg_image) w->area.width += area.width;
area.width = MAX(area.width, pdata[i].bg_resize ? w->area.height : pdata[i].bg_image->width);
w->area.width += area.width; area_array_append(&tda->areas, area);
}
area_array_append(&tda->areas, area);
} }
/* Now that we have widget width we can compute widget x coordinate */ /* Now that we have widget width we can compute widget x coordinate */

View File

@ -143,20 +143,21 @@ tasklist_draw(draw_context_t *ctx, int screen,
lua_pushnumber(globalconf.L, screen + 1); lua_pushnumber(globalconf.L, screen + 1);
/* call label function with client as argument and wait for one /* call label function with client as argument and wait for one
* result */ * result */
luaA_dofunction(globalconf.L, d->label, 2, 1); if(luaA_dofunction(globalconf.L, d->label, 2, 1))
/* If we got a string as returned value, we got something to write:
* a label. So we store it in a client_label_t structure, pushed
* into the client_label_array_t which is owned by the object. */
if(lua_isstring(globalconf.L, -1))
{ {
client_label_t cl; /* If we got a string as returned value, we got something to write:
cl.client = c; * a label. So we store it in a client_label_t structure, pushed
cl.label = a_strdup(lua_tolstring(globalconf.L, -1, &cl.label_len)); * into the client_label_array_t which is owned by the object. */
client_label_array_append(&odata->client_labels, cl); if(lua_isstring(globalconf.L, -1))
} {
client_label_t cl;
cl.client = c;
cl.label = a_strdup(lua_tolstring(globalconf.L, -1, &cl.label_len));
client_label_array_append(&odata->client_labels, cl);
}
lua_pop(globalconf.L, 1); lua_pop(globalconf.L, 1);
}
} }
if(!odata->client_labels.len) if(!odata->client_labels.len)