[statusbar] add colors_set

This commit is contained in:
Lucas de Vries 2008-06-26 16:47:17 +02:00 committed by Julien Danjou
parent 37e8b95ad9
commit b1c48b6834
2 changed files with 45 additions and 2 deletions

View File

@ -118,8 +118,9 @@ typedef struct
} draw_image_t;
draw_context_t *draw_context_new(xcb_connection_t *, int, int, int, xcb_drawable_t, xcolor_t, xcolor_t);
/** Delete a draw context
* \param ctx draw_context_t to delete
/** Delete a draw context.
* \param ctx The draw_context_t to delete.
*/
static inline void
draw_context_delete(draw_context_t **ctx)

View File

@ -340,6 +340,47 @@ luaA_statusbar_align_set(lua_State *L)
return 0;
}
/** Set the default statusbar colors outside the constructor
* \param L The Lua VM state.
* \return The number of elements pushed on the stack.
*
* \luastack
* \lvalue A statusbar.
* \lparam A table with `bg' and `fg'.
*/
static int
luaA_statusbar_colors_set(lua_State *L)
{
statusbar_t **sb = luaA_checkudata(L, 1, "statusbar");
const char *buf;
luaA_checktable(L, 2);
if ((buf = luaA_getopt_string(L, 2, "fg", NULL)))
{
xcolor_new(globalconf.connection, globalconf.default_screen,
buf, &(*sb)->colors.fg);
if((*sb)->ctx)
(*sb)->ctx->fg = (*sb)->colors.fg;
(*sb)->need_update = true;
}
if ((buf = luaA_getopt_string(L, 2, "bg", NULL)))
{
xcolor_new(globalconf.connection, globalconf.default_screen,
buf, &(*sb)->colors.bg);
if((*sb)->ctx)
(*sb)->ctx->bg = (*sb)->colors.bg;
(*sb)->need_update = true;
}
return 0;
}
/** Convert a statusbar to a printable string.
* \param L The Lua VM state.
*
@ -572,6 +613,7 @@ const struct luaL_reg awesome_statusbar_meta[] =
{ "position_set", luaA_statusbar_position_set },
{ "position_get", luaA_statusbar_position_get },
{ "align_set", luaA_statusbar_align_set },
{ "colors_set", luaA_statusbar_colors_set },
{ "add", luaA_statusbar_add },
{ "remove", luaA_statusbar_remove },
{ "__gc", luaA_statusbar_gc },