From f885b8e9542c3e1718bfac8a297462b5ab2834f7 Mon Sep 17 00:00:00 2001 From: Lukas Hrazky Date: Sat, 24 Oct 2009 15:01:37 +0200 Subject: [PATCH] capi.widget: added widget.type getter Signed-off-by: Lukas Hrazky Signed-off-by: Julien Danjou --- objects/widget.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/objects/widget.c b/objects/widget.c index ecd67d7c..7e98b11e 100644 --- a/objects/widget.c +++ b/objects/widget.c @@ -494,6 +494,17 @@ luaA_widget_extents(lua_State *L) return 1; } +static int +luaA_widget_get_type(lua_State *L, widget_t *w) +{ + if (w->type == widget_textbox) lua_pushstring(L, "textbox"); + else if (w->type == widget_systray) lua_pushstring(L, "systray"); + else if (w->type == widget_imagebox) lua_pushstring(L, "imagebox"); + else lua_pushstring(L, "unknown"); + + return 1; +} + static int luaA_widget_set_type(lua_State *L, widget_t *w) { @@ -572,7 +583,7 @@ widget_class_setup(lua_State *L) (lua_class_propfunc_t) luaA_widget_set_visible); luaA_class_add_property(&widget_class, A_TK_TYPE, (lua_class_propfunc_t) luaA_widget_set_type, - NULL, + (lua_class_propfunc_t) luaA_widget_get_type, NULL); }