[tag] Add lua function to get/set tag's name.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-23 14:45:49 +02:00
parent 981b26cbc8
commit 2c548ef816
1 changed files with 20 additions and 0 deletions

20
tag.c
View File

@ -411,6 +411,24 @@ luaA_tag_nmaster_get(lua_State *L)
return 1; return 1;
} }
static int
luaA_tag_name_get(lua_State *L)
{
tag_t **tag = luaL_checkudata(L, 1, "tag");
lua_pushstring(L, (*tag)->name);
return 1;
}
static int
luaA_tag_name_set(lua_State *L)
{
tag_t **tag = luaL_checkudata(L, 1, "tag");
const char *name = luaL_checkstring(L, 2);
p_delete(&(*tag)->name);
(*tag)->name = a_strdup(name);
return 0;
}
static int static int
luaA_tag_gc(lua_State *L) luaA_tag_gc(lua_State *L)
{ {
@ -436,6 +454,8 @@ const struct luaL_reg awesome_tag_meta[] =
{ "ncol_get", luaA_tag_ncol_get }, { "ncol_get", luaA_tag_ncol_get },
{ "nmaster_set", luaA_tag_nmaster_set }, { "nmaster_set", luaA_tag_nmaster_set },
{ "nmaster_get", luaA_tag_nmaster_get }, { "nmaster_get", luaA_tag_nmaster_get },
{ "name_get", luaA_tag_name_get },
{ "name_set", luaA_tag_name_set },
{ "__eq", luaA_tag_eq }, { "__eq", luaA_tag_eq },
{ "__gc", luaA_tag_gc }, { "__gc", luaA_tag_gc },
{ "__tostring", luaA_tag_tostring }, { "__tostring", luaA_tag_tostring },