mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 00:41:17 +02:00
CLuaMenuFilebrowser::exec: Fix value handling when dirMode = false
- Add luaId to action function as parameter - Set Lua api version to 1.25
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include <gui/widget/keyboard_input.h>
|
#include <gui/widget/keyboard_input.h>
|
||||||
#include <gui/filebrowser.h>
|
#include <gui/filebrowser.h>
|
||||||
#include <system/debug.h>
|
#include <system/debug.h>
|
||||||
|
#include <system/helpers.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
|
|
||||||
#include "luainstance.h"
|
#include "luainstance.h"
|
||||||
@@ -165,15 +166,17 @@ int CLuaMenuFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*acti
|
|||||||
if (!filter.empty())
|
if (!filter.empty())
|
||||||
fileBrowser.Filter = &fileFilter;
|
fileBrowser.Filter = &fileFilter;
|
||||||
|
|
||||||
if (fileBrowser.exec(value->c_str()) == true)
|
std::string tmpValue = (dirMode) ? *value : getPathName(*value);
|
||||||
|
if (fileBrowser.exec(tmpValue.c_str()) == true)
|
||||||
*value = fileBrowser.getSelectedFile()->Name;
|
*value = fileBrowser.getSelectedFile()->Name;
|
||||||
|
|
||||||
if (!luaAction.empty()) {
|
if (!luaAction.empty()) {
|
||||||
lua_pushglobaltable(L);
|
lua_pushglobaltable(L);
|
||||||
lua_getfield(L, -1, luaAction.c_str());
|
lua_getfield(L, -1, luaAction.c_str());
|
||||||
lua_remove(L, -2);
|
lua_remove(L, -2);
|
||||||
|
lua_pushstring(L, luaId.c_str());
|
||||||
lua_pushstring(L, value->c_str());
|
lua_pushstring(L, value->c_str());
|
||||||
int status = lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0);
|
int status = lua_pcall(L, 2 /* two arg */, 1 /* one result */, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLuaMenuFilebrowser::%s:%d] error in script: %s\n", __func__, __LINE__, lua_tostring(L, -1));
|
fprintf(stderr, "[CLuaMenuFilebrowser::%s:%d] error in script: %s\n", __func__, __LINE__, lua_tostring(L, -1));
|
||||||
luaL_error(L, " => %s", lua_tostring(L, -1));
|
luaL_error(L, " => %s", lua_tostring(L, -1));
|
||||||
|
@@ -31,7 +31,7 @@ extern "C" {
|
|||||||
#include "luainstance_helpers.h"
|
#include "luainstance_helpers.h"
|
||||||
|
|
||||||
#define LUA_API_VERSION_MAJOR 1
|
#define LUA_API_VERSION_MAJOR 1
|
||||||
#define LUA_API_VERSION_MINOR 24
|
#define LUA_API_VERSION_MINOR 25
|
||||||
|
|
||||||
/* inspired by Steve Kemp http://www.steve.org.uk/ */
|
/* inspired by Steve Kemp http://www.steve.org.uk/ */
|
||||||
class CLuaInstance
|
class CLuaInstance
|
||||||
|
Reference in New Issue
Block a user