mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
[titlebar] Add titlebar_widget_get()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
131f31c561
commit
70dbc724bf
2 changed files with 25 additions and 1 deletions
|
@ -479,7 +479,7 @@ luaA_statusbar_new(lua_State *L)
|
|||
static int
|
||||
luaA_statusbar_widget_get(lua_State *L)
|
||||
{
|
||||
statusbar_t **sb = luaL_checkudata(L, 1, "statusbar");;
|
||||
statusbar_t **sb = luaL_checkudata(L, 1, "statusbar");
|
||||
widget_node_t *widget;
|
||||
int i = 1;
|
||||
|
||||
|
|
24
titlebar.c
24
titlebar.c
|
@ -455,6 +455,29 @@ luaA_titlebar_widget_add(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Get all widgets from a titlebar.
|
||||
* \return A table with all widgets from the titlebar.
|
||||
*/
|
||||
static int
|
||||
luaA_titlebar_widget_get(lua_State *L)
|
||||
{
|
||||
titlebar_t **tb = luaL_checkudata(L, 1, "titlebar");
|
||||
widget_node_t *widget;
|
||||
int i = 1;
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
for(widget = (*tb)->widgets; widget; widget = widget->next)
|
||||
{
|
||||
luaA_widget_userdata_new(widget->widget);
|
||||
/* ref again for the list */
|
||||
widget_ref(&widget->widget);
|
||||
lua_rawseti(L, -2, i++);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_titlebar_gc(lua_State *L)
|
||||
{
|
||||
|
@ -488,6 +511,7 @@ const struct luaL_reg awesome_titlebar_methods[] =
|
|||
const struct luaL_reg awesome_titlebar_meta[] =
|
||||
{
|
||||
{ "widget_add", luaA_titlebar_widget_add },
|
||||
{ "widget_get", luaA_titlebar_widget_get },
|
||||
{ "__eq", luaA_titlebar_eq },
|
||||
{ "__gc", luaA_titlebar_gc },
|
||||
{ "__tostring", luaA_titlebar_tostring },
|
||||
|
|
Loading…
Reference in a new issue