widgets: add newindex support
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
c007cacd09
commit
1c5fc37eef
|
@ -102,6 +102,8 @@ struct widget_t
|
||||||
int (*draw)(draw_context_t *, int, widget_node_t *, int, int, void *);
|
int (*draw)(draw_context_t *, int, widget_node_t *, int, int, void *);
|
||||||
/** Index function */
|
/** Index function */
|
||||||
int (*index)(lua_State *);
|
int (*index)(lua_State *);
|
||||||
|
/** Newindex function */
|
||||||
|
int (*newindex)(lua_State *);
|
||||||
/** ButtonPressedEvent handler */
|
/** ButtonPressedEvent handler */
|
||||||
void (*button_press)(widget_node_t *, xcb_button_press_event_t *, int, void *, awesome_type_t);
|
void (*button_press)(widget_node_t *, xcb_button_press_event_t *, int, void *, awesome_type_t);
|
||||||
/** Alignement */
|
/** Alignement */
|
||||||
|
|
22
widget.c
22
widget.c
|
@ -394,6 +394,7 @@ luaA_widget_visible_set(lua_State *L)
|
||||||
|
|
||||||
/** Get the visible attribute of a widget.
|
/** Get the visible attribute of a widget.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
|
* \return The number of elements pushed on stack.
|
||||||
*
|
*
|
||||||
* \luastack
|
* \luastack
|
||||||
* \lvalue A widget.
|
* \lvalue A widget.
|
||||||
|
@ -407,6 +408,11 @@ luaA_widget_visible_get(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Generic widget index.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \return The number of elements pushed on stack.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_widget_index(lua_State *L)
|
luaA_widget_index(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -441,6 +447,21 @@ luaA_widget_index(lua_State *L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Generic widget newindex.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \return The number of elements pushed on stack.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_widget_newindex(lua_State *L)
|
||||||
|
{
|
||||||
|
widget_t **widget = luaA_checkudata(L, 1, "widget");
|
||||||
|
|
||||||
|
if((*widget)->newindex)
|
||||||
|
return (*widget)->newindex(L);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const struct luaL_reg awesome_widget_methods[] =
|
const struct luaL_reg awesome_widget_methods[] =
|
||||||
{
|
{
|
||||||
{ "new", luaA_widget_new },
|
{ "new", luaA_widget_new },
|
||||||
|
@ -455,6 +476,7 @@ const struct luaL_reg awesome_widget_meta[] =
|
||||||
{ "visible_set", luaA_widget_visible_set },
|
{ "visible_set", luaA_widget_visible_set },
|
||||||
{ "visible_get", luaA_widget_visible_get },
|
{ "visible_get", luaA_widget_visible_get },
|
||||||
{ "__index", luaA_widget_index },
|
{ "__index", luaA_widget_index },
|
||||||
|
{ "__newindex", luaA_widget_newindex },
|
||||||
{ "__gc", luaA_widget_gc },
|
{ "__gc", luaA_widget_gc },
|
||||||
{ "__eq", luaA_widget_eq },
|
{ "__eq", luaA_widget_eq },
|
||||||
{ "__tostring", luaA_widget_tostring },
|
{ "__tostring", luaA_widget_tostring },
|
||||||
|
|
Loading…
Reference in New Issue