diff --git a/common/tokenize.gperf b/common/tokenize.gperf index 80ded2b7..f34953b4 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -19,6 +19,7 @@ gap grow height image +layout left line mwfact diff --git a/lib/awful.lua b/lib/awful.lua index 4213fc70..09e9f0ad 100644 --- a/lib/awful.lua +++ b/lib/awful.lua @@ -342,7 +342,7 @@ end function P.layout.get(screen) local t = P.tag.selected(screen) if t then - return t:layout_get() + return t.layout end end @@ -441,7 +441,7 @@ function P.layout.inc(layouts, i) if new_layout_index == 0 then new_layout_index = number_of_layouts end - t:layout_set(layouts[new_layout_index]) + t.layout = layouts[new_layout_index] end end @@ -450,7 +450,7 @@ end function P.layout.set(layout) local t = P.tag.selected() if t then - t:layout_set(layout) + t.layout = layout end end diff --git a/tag.c b/tag.c index 1f8fad29..f538222d 100644 --- a/tag.c +++ b/tag.c @@ -340,48 +340,6 @@ luaA_tag_new(lua_State *L) return luaA_tag_userdata_new(L, tag); } -/** Get the layout of the tag. - * \param L The Lua VM state. - * - * \luastack - * \lvalue A tag. - * \lreturn The layout name. - */ -static int -luaA_tag_layout_get(lua_State *L) -{ - tag_t **tag = luaA_checkudata(L, 1, "tag"); - const char *name = a_strdup(name_func_rlookup((*tag)->layout, LayoutList)); - lua_pushstring(L, name); - return 1; -} - -/** Set the layout of the tag. - * \param L The Lua VM state. - * - * \luastack - * \lvalue A tag. - * \lparam A layout name. - */ -static int -luaA_tag_layout_set(lua_State *L) -{ - tag_t **tag = luaA_checkudata(L, 1, "tag"); - const char *name = luaL_checkstring(L, 2); - layout_t *l = name_func_lookup(name, LayoutList); - - if(l) - { - (*tag)->layout = l; - globalconf.screens[(*tag)->screen].need_arrange = true; - } - else - luaL_error(L, "unknown layout: %s", name); - - return 0; - -} - /** Tag index. * \param L The Lua VM state. * \return The number of elements pushed on stack. @@ -410,6 +368,9 @@ luaA_tag_index(lua_State *L) case A_TK_NAME: lua_pushstring(L, (*tag)->name); break; + case A_TK_LAYOUT: + lua_pushstring(L, name_func_rlookup((*tag)->layout, LayoutList)); + break; case A_TK_SELECTED: lua_pushboolean(L, (*tag)->selected); break; @@ -441,6 +402,7 @@ luaA_tag_newindex(lua_State *L) const char *buf, *attr = luaL_checklstring(L, 2, &len); double d; int i; + layout_t *l; switch(a_tokenize(attr, len)) { @@ -451,6 +413,14 @@ luaA_tag_newindex(lua_State *L) if((*tag)->screen != TAG_SCREEN_UNDEF) widget_invalidate_cache((*tag)->screen, WIDGET_CACHE_TAGS); return 0; + case A_TK_LAYOUT: + buf = luaL_checkstring(L, 3); + l = name_func_lookup(buf, LayoutList); + if(l) + (*tag)->layout = l; + else + luaL_error(L, "unknown layout: %s", buf); + break; case A_TK_SELECTED: tag_view(*tag, luaA_checkboolean(L, 3)); return 0; @@ -496,8 +466,6 @@ const struct luaL_reg awesome_tag_methods[] = const struct luaL_reg awesome_tag_meta[] = { { "add", luaA_tag_add }, - { "layout_get", luaA_tag_layout_get }, - { "layout_set", luaA_tag_layout_set }, { "__index", luaA_tag_index }, { "__newindex", luaA_tag_newindex }, { "__eq", luaA_tag_eq },