Added check_min_api_function to dtutils.lua to check the minimum version of the lua API required for a script to run. This is intended to replace the API check done with darktable.configuration.check_version(), which requires changing each time the API version changes. check_min_api_version should work for all API version changes unless backward compatibility is broken. All the scripts using darktable.configuration.check_version() were changed to use check_min_api_version().
This commit is contained in:
@@ -53,7 +53,13 @@ LUA ERROR Hallo Welt!
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0}))
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
--check API version
|
||||
if not du.check_min_api_version("3.0.0") then
|
||||
dt.print("ERROR:gettextExample failed to load. Lua API version 3.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Not translated Text
|
||||
dt.print_error("Hello World!")
|
||||
|
||||
@@ -27,7 +27,12 @@ USAGE
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
if not du.check_min_api_version("2.0.0") then
|
||||
dt.print("ERROR:hello_world failed to load. Lua API version 2.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
dt.print("hello, world")
|
||||
|
||||
|
||||
@@ -31,8 +31,12 @@ https://www.darktable.org/lua-api/index.html.php#darktable_new_widget
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
|
||||
if not du.check_min_api_version("3.0.0") then
|
||||
dt.print("ERROR:moduleExample failed to load. Lua API version 3.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
-- add a new lib
|
||||
local check_button = dt.new_widget("check_button"){label = "MyCheck_button", value = true}
|
||||
|
||||
@@ -80,12 +80,16 @@ local function _(msgid)
|
||||
end
|
||||
|
||||
--[[
|
||||
Specify the version(s) of the lua API that this script is compatible with. This script uses new
|
||||
features released in the latest version of darktable and is only compatible with the latest API version.
|
||||
Multiple API versions may be specified, seperated by commas.
|
||||
Check that the current api version is greater than or equal to the specified minimum. If it's not
|
||||
then du.check_min_api_version will print an error to the log and return false. If the minimum api is
|
||||
not met, then just refuse to load and return. Optionally, you could print an error message to the
|
||||
screen stating that you couldn't load because the minimum api version wasn't met.
|
||||
]]
|
||||
|
||||
dt.configuration.check_version(...,{5,0,0})
|
||||
if not du.check_min_api_version("5.0.0") then
|
||||
dt.print("ERROR:mulit_os failed to load: Lua API version 5.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
--[[
|
||||
copy_image_attributes is a local subroutine to copy image attributes in the database from the raw image
|
||||
|
||||
@@ -22,7 +22,12 @@ USAGE
|
||||
* require this script from your main lua file
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,1},{3,0,0},{4,0,0},{5,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
if not du.check_min_api_version("2.0.1") then
|
||||
dt.print("ERROR:preferenceExamples failed to load. Lua API version 2.0.1 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
|
||||
@@ -20,7 +20,12 @@ USAGE
|
||||
* require this file from your main lua config file:
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{5,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
if not du.check_min_api_version("5.0.0") then
|
||||
dt.print("ERROR:printExamples failed to load. Lua API version 5.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Will print a string to the darktable control log (the long
|
||||
-- overlayed window that appears over the main panel).
|
||||
|
||||
@@ -26,7 +26,12 @@ prints the operating system
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{5,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
if not du.check_min_api_version("5.0.0") then
|
||||
dt.print("ERROR:running_os not loaded. Lua API version 5.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
dt.print("You are running: "..dt.configuration.running_os)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user