13
0

implement fetch_valid_settings_file() to avoid the user having to see stub files

This commit is contained in:
Nikolaus Gullotta 2018-08-01 14:42:02 -05:00
parent d77aa4e3a5
commit b45c7089c6

View File

@ -47,6 +47,19 @@ function factory () return function ()
return exists(path.."/") return exists(path.."/")
end end
function fetch_valid_settings_file(directory, fallback)
local i, t, popen = 0, {}, io.popen
local pfile = popen('ls "'..directory..'"')
for filename in pfile:lines() do
i = i + 1
if string.find(filename, ".lua") then
return filename
end
end
pfile:close()
return fallback
end
function get_processor_by_name(track, name) function get_processor_by_name(track, name)
local i = 0 local i = 0
local proc = track:nth_processor(i) local proc = track:nth_processor(i)
@ -377,7 +390,7 @@ function factory () return function ()
else else
if gvld['recall-dir'] == 1 then if gvld['recall-dir'] == 1 then
local global_ok = isdir(global_path) local global_ok = isdir(global_path)
local global_default_path = ARDOUR.LuaAPI.build_filename(global_path, string.format("FactoryDefault-%s.lua", whoami())) local global_default_path = ARDOUR.LuaAPI.build_filename(global_path, fetch_valid_settings_file(global_path, string.format("FactoryDefault-%s.lua", whoami())))
print(global_default_path) print(global_default_path)
if global_ok then if global_ok then
recall_options[2]['path'] = global_default_path recall_options[2]['path'] = global_default_path
@ -398,10 +411,10 @@ function factory () return function ()
if gvld['recall-dir'] == 2 then if gvld['recall-dir'] == 2 then
local local_ok = isdir(local_path) local local_ok = isdir(local_path)
local local_default_path = ARDOUR.LuaAPI.build_filename(local_path, 'stub') local local_default_path = ARDOUR.LuaAPI.build_filename(local_path, fetch_valid_settings_file(local_path))
print(local_default_path) print(local_default_path)
if local_ok then if local_ok then
recall_options[2]['path'] = local_path recall_options[2]['path'] = local_default_path
local rv = LuaDialog.Dialog("Recall Mixer Settings:", recall_options):run() local rv = LuaDialog.Dialog("Recall Mixer Settings:", recall_options):run()
if not(rv) then return end if not(rv) then return end
local dry_return = LuaDialog.Dialog("Mixer Store:", dry_run(false, rv['file'])):run() local dry_return = LuaDialog.Dialog("Mixer Store:", dry_run(false, rv['file'])):run()