summaryrefslogtreecommitdiff
path: root/client/lua.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/lua.cc')
-rw-r--r--client/lua.cc46
1 files changed, 42 insertions, 4 deletions
diff --git a/client/lua.cc b/client/lua.cc
index 9494ee2..2dcd279 100644
--- a/client/lua.cc
+++ b/client/lua.cc
@@ -119,7 +119,7 @@ static int _setValue(lua_State *L)
int n = lua_gettop(L); // number of arguments
if(n != 2) {
char errstr[512];
- sprintf(errstr, "Number of args expected 0, got %d", n);
+ sprintf(errstr, "Number of args expected 2, got %d", n);
lua_pushstring(L, errstr);
lua_error(L);
return 0;
@@ -144,6 +144,37 @@ static int _setValue(lua_State *L)
return 0;
}
+static int _setVisible(lua_State *L)
+{
+ int n = lua_gettop(L); // number of arguments
+ if(n != 2) {
+ char errstr[512];
+ sprintf(errstr, "Number of args expected 2, got %d", n);
+ lua_pushstring(L, errstr);
+ lua_error(L);
+ return 0;
+ }
+
+ bool value = lua_toboolean(L, lua_gettop(L));
+ lua_pop(L, 1);
+ QString name = lua_tostring(L, lua_gettop(L));
+ lua_pop(L, 1);
+
+ lua_getglobal(L, GLOBAL_POINTER);
+ LUA *lua = (LUA*)lua_touserdata(L, lua_gettop(L));
+
+ if(!lua) {
+ lua_pushstring(L, "No LUA pointer!");
+ lua_error(L);
+ return 1;
+ }
+
+ lua->setVisible(name, value);
+
+ return 0;
+}
+
+
LUA::LUA(MacroWindow *macrowindow)
{
this->macrowindow = macrowindow;
@@ -163,6 +194,7 @@ LUA::LUA(MacroWindow *macrowindow)
lua_register(L, "setValue", _setValue);
lua_register(L, "enable", _enable);
lua_register(L, "disable", _disable);
+ lua_register(L, "setVisible", _setVisible);
}
LUA::~LUA()
@@ -180,19 +212,25 @@ QString LUA::getValue(QString name)
void LUA::setValue(QString name, QString value)
{
Widget *widget = macrowindow->getWidget(name);
- if(widget) return widget->setValue(value);
+ if(widget) widget->setValue(value);
}
void LUA::enable(QString name)
{
Widget *widget = macrowindow->getWidget(name);
- if(widget) return widget->enable();
+ if(widget) widget->enable();
}
void LUA::disable(QString name)
{
Widget *widget = macrowindow->getWidget(name);
- if(widget) return widget->disable();
+ if(widget) widget->disable();
+}
+
+void LUA::setVisible(QString name, bool value)
+{
+ Widget *widget = macrowindow->getWidget(name);
+ if(widget) widget->setVisibility(value);
}
bool LUA::run(QString program, QString name, QString value)