summaryrefslogtreecommitdiff
path: root/client/lua.cc
diff options
context:
space:
mode:
authordeva <deva>2008-07-02 07:49:31 +0000
committerdeva <deva>2008-07-02 07:49:31 +0000
commit4d7617cbf20985b7cf2231675d8aadd01f77c3d2 (patch)
tree673a098723c6f6cef90719e0ffa65b2cb31c37b6 /client/lua.cc
parentef408f5639958ce51170978433a0e483240a3ff2 (diff)
Added disable/enable methods on widgets and exposed them to lua.
Diffstat (limited to 'client/lua.cc')
-rw-r--r--client/lua.cc66
1 files changed, 66 insertions, 0 deletions
diff --git a/client/lua.cc b/client/lua.cc
index 1be850c..22249a4 100644
--- a/client/lua.cc
+++ b/client/lua.cc
@@ -30,6 +30,60 @@
#define GLOBAL_POINTER "_pracroGlobalLUAObjectPointerThisShouldBeANameThatIsNotAccidentallyOverwritten"
+static int _enable(lua_State *L)
+{
+ int n = lua_gettop(L); // number of arguments
+ if(n != 1) {
+ char errstr[512];
+ sprintf(errstr, "Number of args expected 0, got %d", n);
+ lua_pushstring(L, errstr);
+ lua_error(L);
+ return 1;
+ }
+
+ QString name = lua_tostring(L, lua_gettop(L));
+
+ 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->enable(name);
+
+ return 0;
+}
+
+static int _disable(lua_State *L)
+{
+ int n = lua_gettop(L); // number of arguments
+ if(n != 1) {
+ char errstr[512];
+ sprintf(errstr, "Number of args expected 0, got %d", n);
+ lua_pushstring(L, errstr);
+ lua_error(L);
+ return 1;
+ }
+
+ QString name = lua_tostring(L, lua_gettop(L));
+
+ 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->disable(name);
+
+ return 0;
+}
+
static int _getValue(lua_State *L)
{
int n = lua_gettop(L); // number of arguments
@@ -105,6 +159,8 @@ LUA::LUA(MacroWindow *macrowindow)
lua_register(L, "getValue", _getValue);
lua_register(L, "setValue", _setValue);
+ lua_register(L, "enable", _enable);
+ lua_register(L, "disable", _disable);
}
LUA::~LUA()
@@ -122,6 +178,16 @@ void LUA::setValue(QString name, QString value)
macrowindow->setValue(name, value);
}
+void LUA::enable(QString name)
+{
+ return macrowindow->enable(name);
+}
+
+void LUA::disable(QString name)
+{
+ return macrowindow->disable(name);
+}
+
bool LUA::run(QString program, QString name, QString value)
{
if(L == NULL) {