summaryrefslogtreecommitdiff
path: root/plugins/MirLua
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-01-16 19:48:35 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-01-16 19:48:35 +0000
commitefa07c67497a060009ebb5ec001dbd89684a4e17 (patch)
tree5c1e036a1596335467cd1c8e70e7cc221dcd1452 /plugins/MirLua
parent82ae5fccc82f399b9a6ca52d0dc519f849eff9e4 (diff)
MirLua: added Add*MenuRoot in m_clist
git-svn-id: http://svn.miranda-ng.org/main/trunk@16105 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r--plugins/MirLua/src/m_clist.cpp68
-rw-r--r--plugins/MirLua/src/m_database.cpp1
-rw-r--r--plugins/MirLua/src/m_genmenu.cpp12
3 files changed, 43 insertions, 38 deletions
diff --git a/plugins/MirLua/src/m_clist.cpp b/plugins/MirLua/src/m_clist.cpp
index abb54357a6..1d451250f7 100644
--- a/plugins/MirLua/src/m_clist.cpp
+++ b/plugins/MirLua/src/m_clist.cpp
@@ -1,47 +1,47 @@
#include "stdafx.h"
+static int clist_AddMainMenuRoot(lua_State *L)
+{
+ const char *name = luaL_checkstring(L, 1);
+ int position = lua_tointeger(L, 2);
+ HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
+
+ HGENMENU res = Menu_CreateRoot(MO_MAIN, ptrT(Utf8DecodeT(name)), position, hIcon);
+ lua_pushlightuserdata(L, res);
+
+ return 1;
+}
+
static int clist_AddMainMenuItem(lua_State *L)
{
- HGENMENU res = NULL;
-
- if (lua_isstring(L, 1))
- {
- const char *name = luaL_checkstring(L, 1);
- int position = lua_tointeger(L, 2);
- HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
- res = Menu_CreateRoot(MO_MAIN, ptrT(Utf8DecodeT(name)), position, hIcon);
- }
- else if (lua_istable(L, 1))
- {
- CMenuItem mi;
- MakeMenuItem(L, mi);
- res = Menu_AddMainMenuItem(&mi);
- }
+ CMenuItem mi;
+ MakeMenuItem(L, mi);
+ HGENMENU res = Menu_AddMainMenuItem(&mi);
lua_pushlightuserdata(L, res);
return 1;
}
-static int clist_AddContactMenuItem(lua_State *L)
+static int clist_AddContactMenuRoot(lua_State *L)
{
- HGENMENU res = NULL;
+ const char *name = luaL_checkstring(L, 1);
+ int position = lua_tointeger(L, 2);
+ HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
- if (lua_isstring(L, 1))
- {
- const char *name = luaL_checkstring(L, 1);
- int position = lua_tointeger(L, 2);
- HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
- res = Menu_CreateRoot(MO_MAIN, ptrT(Utf8DecodeT(name)), position, hIcon);
- }
- else if (lua_istable(L, 1))
- {
- CMenuItem mi;
- MakeMenuItem(L, mi);
- ptrA szProto(mir_utf8decode((char*)lua_tostring(L, 2), NULL));
- res = Menu_AddContactMenuItem(&mi, szProto);
- }
+ HGENMENU res = Menu_CreateRoot(MO_MAIN, ptrT(Utf8DecodeT(name)), position, hIcon);
+ lua_pushlightuserdata(L, res);
+
+ return 1;
+}
+static int clist_AddContactMenuItem(lua_State *L)
+{
+ CMenuItem mi;
+ MakeMenuItem(L, mi);
+
+ ptrA szProto(mir_utf8decode((char*)lua_tostring(L, 2), NULL));
+ HGENMENU res = Menu_AddContactMenuItem(&mi, szProto);
lua_pushlightuserdata(L, res);
return 1;
@@ -49,7 +49,7 @@ static int clist_AddContactMenuItem(lua_State *L)
static int clist_AddTrayMenuItem(lua_State *L)
{
- if (lua_istable(L, 1) != LUA_TTABLE)
+ if (!lua_istable(L, 1))
{
lua_pushlightuserdata(L, 0);
return 1;
@@ -66,8 +66,12 @@ static int clist_AddTrayMenuItem(lua_State *L)
static luaL_Reg clistApi[] =
{
+ { "AddMainMenuRoot", clist_AddMainMenuRoot },
{ "AddMainMenuItem", clist_AddMainMenuItem },
+
+ { "AddContactMenuRoot", clist_AddContactMenuRoot },
{ "AddContactMenuItem", clist_AddContactMenuItem },
+
{ "AddTrayMenuItem", clist_AddTrayMenuItem },
{ NULL, NULL }
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp
index 8539f32b6e..efd10d6f3b 100644
--- a/plugins/MirLua/src/m_database.cpp
+++ b/plugins/MirLua/src/m_database.cpp
@@ -472,6 +472,7 @@ static luaL_Reg databaseApi[] =
{ "EventsFromEnd", lua_EventsFromEnd },
{ "WriteSetting", lua_WriteSetting },
+ { "SetSetting", lua_WriteSetting },
{ "GetSetting", lua_GetSetting },
{ "Settings", lua_Settings },
diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp
index 7d25468980..b0fbd794a7 100644
--- a/plugins/MirLua/src/m_genmenu.cpp
+++ b/plugins/MirLua/src/m_genmenu.cpp
@@ -38,7 +38,7 @@ void MakeMenuItem(lua_State *L, CMenuItem &mi)
lua_pop(L, 1);
}
-static int genmenu_CreateRoot(lua_State *L)
+/*static int genmenu_CreateRoot(lua_State *L)
{
ObsoleteMethod(L, "use m_clist module instead");
@@ -72,15 +72,15 @@ static int genmenu_AddMenuItem(lua_State *L)
lua_pushlightuserdata(L, res);
return 1;
-}
+}*/
static int genmenu_ModifyMenuItem(lua_State *L)
{
luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
ptrT name(mir_utf8decodeT(lua_tostring(L, 2)));
- HANDLE hIcolibItem = lua_touserdata(L, 3);
- int flags = lua_tointeger(L, 4);
+ HANDLE hIcolibItem = luaL_opt(L, lua_touserdata, 3, INVALID_HANDLE_VALUE);
+ int flags = luaL_optinteger(L, 4, -1);
if (!(flags & CMIF_UNICODE))
flags |= CMIF_UNICODE;
@@ -136,8 +136,8 @@ static int genmenu_RemoveMenuItem(lua_State *L)
static luaL_Reg genmenuApi[] =
{
- { "CreateRoot", genmenu_CreateRoot },
- { "AddMenuItem", genmenu_AddMenuItem },
+ //{ "CreateRoot", genmenu_CreateRoot },
+ //{ "AddMenuItem", genmenu_AddMenuItem },
{ "ModifyMenuItem", genmenu_ModifyMenuItem },
{ "ShowMenuItem", genmenu_ShowMenuItem },
{ "EnableMenuItem", genmenu_EnableMenuItem },