[widget] Move widget_get to statusbar
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
aecc3c0e45
commit
35b5afe38c
24
statusbar.c
24
statusbar.c
|
@ -473,6 +473,29 @@ luaA_statusbar_new(lua_State *L)
|
||||||
return luaA_settype(L, "statusbar");
|
return luaA_settype(L, "statusbar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get all widget from a statusbar.
|
||||||
|
* \return A table with all widgets from the statusbar.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_statusbar_widget_get(lua_State *L)
|
||||||
|
{
|
||||||
|
statusbar_t **sb = luaL_checkudata(L, 1, "statusbar");;
|
||||||
|
widget_node_t *widget;
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
lua_newtable(L);
|
||||||
|
|
||||||
|
for(widget = (*sb)->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;
|
||||||
|
}
|
||||||
|
|
||||||
/** Handle statusbar garbage collection.
|
/** Handle statusbar garbage collection.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
|
@ -491,6 +514,7 @@ const struct luaL_reg awesome_statusbar_methods[] =
|
||||||
const struct luaL_reg awesome_statusbar_meta[] =
|
const struct luaL_reg awesome_statusbar_meta[] =
|
||||||
{
|
{
|
||||||
{ "widget_add", luaA_statusbar_widget_add },
|
{ "widget_add", luaA_statusbar_widget_add },
|
||||||
|
{ "widget_get", luaA_statusbar_widget_get },
|
||||||
{ "position_set", luaA_statusbar_position_set },
|
{ "position_set", luaA_statusbar_position_set },
|
||||||
{ "position_get", luaA_statusbar_position_get },
|
{ "position_get", luaA_statusbar_position_get },
|
||||||
{ "align_set", luaA_statusbar_align_set },
|
{ "align_set", luaA_statusbar_align_set },
|
||||||
|
|
44
widget.c
44
widget.c
|
@ -296,7 +296,7 @@ widget_invalidate_bywidget(widget_t *widget)
|
||||||
* \param widget The widget.
|
* \param widget The widget.
|
||||||
* \return Return luaA_settype() return value.
|
* \return Return luaA_settype() return value.
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
luaA_widget_userdata_new(widget_t *widget)
|
luaA_widget_userdata_new(widget_t *widget)
|
||||||
{
|
{
|
||||||
widget_t **w;
|
widget_t **w;
|
||||||
|
@ -464,47 +464,6 @@ luaA_widget_eq(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get all widget from all statusbars.
|
|
||||||
* \return A table with all widgets from all statusbars.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_widget_get(lua_State *L)
|
|
||||||
{
|
|
||||||
statusbar_t *sb;
|
|
||||||
widget_node_t *widget;
|
|
||||||
int i = 1, screen;
|
|
||||||
bool add = true;
|
|
||||||
widget_node_t *wlist = NULL, *witer;
|
|
||||||
|
|
||||||
lua_newtable(L);
|
|
||||||
|
|
||||||
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
|
||||||
for(sb = globalconf.screens[screen].statusbar; sb; sb = sb->next)
|
|
||||||
for(widget = sb->widgets; widget; widget = widget->next)
|
|
||||||
{
|
|
||||||
for(witer = wlist; witer; witer = witer->next)
|
|
||||||
if(witer->widget == widget->widget)
|
|
||||||
{
|
|
||||||
add = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(add)
|
|
||||||
{
|
|
||||||
witer = p_new(widget_node_t, 1);
|
|
||||||
widget_node_list_push(&wlist, witer);
|
|
||||||
luaA_widget_userdata_new(witer->widget);
|
|
||||||
/* ref again for the list */
|
|
||||||
widget_ref(&widget->widget);
|
|
||||||
lua_rawseti(L, -2, i++);
|
|
||||||
}
|
|
||||||
add = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
widget_node_list_wipe(&wlist);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the widget name.
|
/** Set the widget name.
|
||||||
* \param A string with the new widget name.
|
* \param A string with the new widget name.
|
||||||
*/
|
*/
|
||||||
|
@ -556,7 +515,6 @@ luaA_widget_visible_get(lua_State *L)
|
||||||
const struct luaL_reg awesome_widget_methods[] =
|
const struct luaL_reg awesome_widget_methods[] =
|
||||||
{
|
{
|
||||||
{ "new", luaA_widget_new },
|
{ "new", luaA_widget_new },
|
||||||
{ "get", luaA_widget_get },
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
const struct luaL_reg awesome_widget_meta[] =
|
const struct luaL_reg awesome_widget_meta[] =
|
||||||
|
|
2
widget.h
2
widget.h
|
@ -39,6 +39,8 @@ widget_t * widget_getbyname(const char *);
|
||||||
void widget_tell_managestatus(widget_t *, widget_tell_status_t, const char *);
|
void widget_tell_managestatus(widget_t *, widget_tell_status_t, const char *);
|
||||||
void widget_render(widget_node_t *, draw_context_t *, xcb_gcontext_t, xcb_drawable_t, int, position_t, int, int, void *);
|
void widget_render(widget_node_t *, draw_context_t *, xcb_gcontext_t, xcb_drawable_t, int, position_t, int, int, void *);
|
||||||
|
|
||||||
|
int luaA_widget_userdata_new(widget_t *);
|
||||||
|
|
||||||
widget_constructor_t taglist_new;
|
widget_constructor_t taglist_new;
|
||||||
widget_constructor_t textbox_new;
|
widget_constructor_t textbox_new;
|
||||||
widget_constructor_t iconbox_new;
|
widget_constructor_t iconbox_new;
|
||||||
|
|
Loading…
Reference in New Issue