diff --git a/contrib/LabelsToTags.lua b/contrib/LabelsToTags.lua index 16f9996..15a44f3 100644 --- a/contrib/LabelsToTags.lua +++ b/contrib/LabelsToTags.lua @@ -48,7 +48,12 @@ ]] local darktable = require("darktable") -darktable.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0}) +local du = require "lib/dtutils" + +if not du.check_min_api_version("3.0.0") then + darktable.print("ERROR:LabelsToTags failed to load. Lua API version 3.0.0 or later required.") + return +end -- Lua 5.3 no longer has "unpack" but "table.unpack" unpack = unpack or table.unpack diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua index d7ea877..b223c71 100644 --- a/contrib/OpenInExplorer.lua +++ b/contrib/OpenInExplorer.lua @@ -34,8 +34,15 @@ A file explorer window will be opened for each selected file at the file's locat ]] local dt = require "darktable" +local du = require "lib/dtutils" local dsys = require "lib/dtutils.system" +--Check API version +if not du.check_min_api_version("5.0.0") then + dt.print("ERROR:OpenInExplorer failed to load. Lua API version 5.0.0 or greater required.") + return +end + --Detect OS and modify accordingly-- local proper_install = false if dt.configuration.running_os == "windows" then diff --git a/contrib/autostyle.lua b/contrib/autostyle.lua index 77c04cb..34b95f0 100644 --- a/contrib/autostyle.lua +++ b/contrib/autostyle.lua @@ -37,13 +37,17 @@ GPLv2 ]] local darktable = require "darktable" +local du = require "lib/dtutils" local filelib = require "lib/dtutils.file" -- Forward declare the functions local autostyle_apply_one_image,autostyle_apply_one_image_event,autostyle_apply,exiftool_attribute,capture -- Tested it with darktable 1.6.1 and darktable git from 2014-01-25 -darktable.configuration.check_version(...,{2,0,2},{2,1,0},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.0.2") then + darktable.print("ERROR:autostyle failed to load. Lua API version 2.0.2 or later required.") + return +end -- Receive the event triggered function autostyle_apply_one_image_event(event,image) diff --git a/contrib/clear_GPS.lua b/contrib/clear_GPS.lua index 2a84a61..5d3fdf7 100644 --- a/contrib/clear_GPS.lua +++ b/contrib/clear_GPS.lua @@ -37,12 +37,16 @@ ]] local dt = require "darktable" +local du = require "lib/dtutils" local gettext = dt.gettext -- not a number local NaN = 0/0 -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:clear_GPS failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain diff --git a/contrib/copy_attach_detach_tags.lua b/contrib/copy_attach_detach_tags.lua index d7dab8a..3f60d9e 100644 --- a/contrib/copy_attach_detach_tags.lua +++ b/contrib/copy_attach_detach_tags.lua @@ -37,10 +37,15 @@ USAGE ]] local dt = require "darktable" +local du = require "lib/dtutils" local debug = require "darktable.debug" local gettext = dt.gettext -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:copy_attach_detach_tags failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("copy_attach_detach_tags",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/cr2hdr.lua b/contrib/cr2hdr.lua index a308ffa..5705751 100644 --- a/contrib/cr2hdr.lua +++ b/contrib/cr2hdr.lua @@ -33,9 +33,13 @@ USAGE ]] local darktable = require "darktable" +local du = require "lib/dtutils" -- Tested with darktable 2.0.1 -darktable.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.0.0") then + darktable.print("ERROR:cr2hdr failed to load. Lua API version 2.0.0 or later required.") + return +end local queue = {} local processed_files = {} diff --git a/contrib/enfuseAdvanced.lua b/contrib/enfuseAdvanced.lua index 7c1edd3..377db49 100644 --- a/contrib/enfuseAdvanced.lua +++ b/contrib/enfuseAdvanced.lua @@ -60,13 +60,17 @@ Pops up multiple CMD windows on windows machienes ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" local dsys = require "lib/dtutils.system" local gettext = dt.gettext local preferences_version = 1 --When releasing an update increment this number by one if changes have been made to the preferences structure that would require a re-initialization -- works with LUA API version 5.0.0 -dt.configuration.check_version(...,{5,0,0}) +if not du.check_min_api_version("5.0.0") then + dt.print("ERROR:enfuseAdvanced failed to load. Lua API version 5.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("enfuseAdvanced",dt.configuration.config_dir.."/lua/") diff --git a/contrib/fujifilm_ratings.lua b/contrib/fujifilm_ratings.lua index 38b3c21..294623e 100644 --- a/contrib/fujifilm_ratings.lua +++ b/contrib/fujifilm_ratings.lua @@ -24,10 +24,14 @@ Dependencies: --]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" local gettext = dt.gettext -dt.configuration.check_version(...,{4,0,0},{5,0,0}) +if not du.check_min_api_version("4.0.0") then + dt.print("ERROR:fujifilm_ratings failed to load. Lua API version 4.0.0 or later required.") + return +end gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index 6fc76fa..99edc31 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -33,11 +33,15 @@ USAGE ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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:geoJSON_export failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("geoJSON_export",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 8a28001..0092289 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -26,11 +26,15 @@ require "geoToolbox" ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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:geoToolbox failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("geoToolbox",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/gimp.lua b/contrib/gimp.lua index e7df43b..0210e01 100644 --- a/contrib/gimp.lua +++ b/contrib/gimp.lua @@ -64,12 +64,16 @@ ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" local dtsys = require "lib/dtutils.system" local gettext = dt.gettext local gimp_widget = nil -dt.configuration.check_version(...,{5,0,0}) +if not du.check_min_api_version("5.0.0") then + dt.print("ERROR:gimp failed to load. Lua API version 5.0.0 or greater required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("gimp",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/gpx_export.lua b/contrib/gpx_export.lua index 0518931..b137d58 100644 --- a/contrib/gpx_export.lua +++ b/contrib/gpx_export.lua @@ -27,7 +27,10 @@ local df = require "lib/dtutils.file" local dl = require "lib/dtutils" local gettext = dt.gettext -dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0}) +if not dl.check_min_api_version("3.0.0") then + dt.print("ERROR:gpx-export failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("gpx_export",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/hugin.lua b/contrib/hugin.lua index 90e5938..8b9887d 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -36,6 +36,7 @@ This plugin will add a new storage option and calls hugin after export. ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" local log = require "lib/dtutils.log" local dtsys = require "lib/dtutils.system" @@ -54,7 +55,10 @@ local executable_table = {"hugin", "hugin_executor", "pto_gen"} local PQ = dt.configuration.running_os == "windows" and '"' or "'" -- works with darktable API version from 5.0.0 on -dt.configuration.check_version(...,{5,0,0}) +if not du.check_min_api_version("5.0.0") then + dt.print("ERROR:hugin failed to load. Lua API version 5.0.0 or greater required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("hugin",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/image_stack.lua b/contrib/image_stack.lua index fd03fb6..ebf87dd 100644 --- a/contrib/image_stack.lua +++ b/contrib/image_stack.lua @@ -71,7 +71,10 @@ local job = nil local PS = dt.configuration.running_os == "windows" and "\\" or "/" -- works with LUA API version 5.0.0 -dt.configuration.check_version(...,{5,0,0}) +if not du.check_min_api_version("5.0.0") then + dt.print("ERROR:image_stack failed to load. Lua API version 5.0.0 or greater required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("image_stack",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index 070a02f..2b932da 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -37,11 +37,15 @@ USAGE ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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:kml_export failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("kml_export",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/passport_guide.lua b/contrib/passport_guide.lua index 48ae64f..442a28f 100644 --- a/contrib/passport_guide.lua +++ b/contrib/passport_guide.lua @@ -36,9 +36,13 @@ USAGE ]] local dt = require "darktable" +local du = require "lib/dtutils" local gettext = dt.gettext -dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.0.0") then + dt.print("ERROR:passport_guide failed to load. Lua API version 2.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("passport_guide",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/pdf_slideshow.lua b/contrib/pdf_slideshow.lua index d5a71d4..eae9141 100644 --- a/contrib/pdf_slideshow.lua +++ b/contrib/pdf_slideshow.lua @@ -39,6 +39,7 @@ format (all fields can be the empty string): ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" require "official/yield" @@ -56,7 +57,10 @@ if not df.check_if_bin_exists("pdflatex") then return end -dt.configuration.check_version(...,{4,0,0},{5,0,0}) +if not du.check_min_api_version("4.0.0") then + dt.print("ERROR:pdf_slideshow failed to load. Lua API version 4.0.0 or greater required.") + return +end dt.preferences.register ("pdf_slideshow","open with","string", diff --git a/contrib/quicktag.lua b/contrib/quicktag.lua index c5ade26..cfc072c 100644 --- a/contrib/quicktag.lua +++ b/contrib/quicktag.lua @@ -44,12 +44,16 @@ USAGE local dt = require "darktable" +local du = require "lib/dtutils" local debug = require "darktable.debug" local gettext = dt.gettext -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:quicktag failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("quicktag",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/rate_group.lua b/contrib/rate_group.lua index 3a557a8..8d5019f 100644 --- a/contrib/rate_group.lua +++ b/contrib/rate_group.lua @@ -39,9 +39,13 @@ ]] local dt = require "darktable" +local du = require "lib/dtutils" -- added version check -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:rate_group failed to load. Lua API version 3.0.0 or later required.") + return +end local function apply_rating(rating) local images = dt.gui.action_images diff --git a/contrib/rename-tags.lua b/contrib/rename-tags.lua index 217357b..c839b6b 100644 --- a/contrib/rename-tags.lua +++ b/contrib/rename-tags.lua @@ -29,8 +29,15 @@ Changes ]] local darktable = require "darktable" +local du = require "lib/dtutils" local debug = require "darktable.debug" +-- check API version +if not du.check_min_api_version("3.0.0") then + darktable.print("ERROR:rename_tags failed to load. Lua API version 3.0.0 or later required.") + return +end + -- GUI entries local old_tag = darktable.new_widget("entry") { tooltip = "Enter old tag" } local new_tag = darktable.new_widget("entry") { tooltip = "Enter new tag" } diff --git a/contrib/select_untagged.lua b/contrib/select_untagged.lua index 9e504c0..8ab4508 100644 --- a/contrib/select_untagged.lua +++ b/contrib/select_untagged.lua @@ -19,9 +19,13 @@ Enable selection of untagged images (darktable|* tags are ignored) ]] local dt = require "darktable" +local du = require "lib/dtutils" local gettext = dt.gettext -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:select_untagged failed to load. Lua API version 3.0.0 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("select_untagged",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index 2da53dc..5563617 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -25,11 +25,15 @@ USAGE ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -dt.configuration.check_version(...,{2,0,2},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.0.2") then + dt.print("ERROR:slideshowMusic failed to load. Lua API version 2.0.2 or greater required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("slideshowMusic",dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/video_mencoder.lua b/contrib/video_mencoder.lua index 3f39587..ec90ffc 100644 --- a/contrib/video_mencoder.lua +++ b/contrib/video_mencoder.lua @@ -31,11 +31,15 @@ USAGE ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -dt.configuration.check_version(...,{2,0,1},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.0.1") then + dt.print("ERROR:video_mencoder failed to load. Lua API version 2.0.1 or later required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("video_mencoder",dt.configuration.config_dir.."/lua/locale/") diff --git a/examples/gettextExample.lua b/examples/gettextExample.lua index 856a825..788911e 100644 --- a/examples/gettextExample.lua +++ b/examples/gettextExample.lua @@ -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!") diff --git a/examples/hello_world.lua b/examples/hello_world.lua index 6a19880..23d9027 100644 --- a/examples/hello_world.lua +++ b/examples/hello_world.lua @@ -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") diff --git a/examples/moduleExample.lua b/examples/moduleExample.lua index eda8748..4dec3fd 100644 --- a/examples/moduleExample.lua +++ b/examples/moduleExample.lua @@ -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} diff --git a/examples/multi_os.lua b/examples/multi_os.lua index 0371768..ac429a8 100644 --- a/examples/multi_os.lua +++ b/examples/multi_os.lua @@ -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 diff --git a/examples/preferenceExamples.lua b/examples/preferenceExamples.lua index 7ac1cfd..5abb76a 100644 --- a/examples/preferenceExamples.lua +++ b/examples/preferenceExamples.lua @@ -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 diff --git a/examples/printExamples.lua b/examples/printExamples.lua index 5ef3695..a37e9e1 100644 --- a/examples/printExamples.lua +++ b/examples/printExamples.lua @@ -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). diff --git a/examples/running_os.lua b/examples/running_os.lua index a615fa9..0879a73 100644 --- a/examples/running_os.lua +++ b/examples/running_os.lua @@ -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) diff --git a/lib/dtutils.lua b/lib/dtutils.lua index abe51d6..fc077be 100644 --- a/lib/dtutils.lua +++ b/lib/dtutils.lua @@ -32,7 +32,40 @@ local dt = require "darktable" local log = require "lib/dtutils.log" -dt.configuration.check_version(...,{5,0,0}) +dtutils.libdoc.functions["check_min_api_version"] = { + Name = [[check_min_api_version]], + Synopsis = [[check the minimum required api version against the current api version]], + Usage = [[local du = require "lib/dtutils" + + local result = du.check_min_api_version(min_api) + min_api - string - the api version that the application was written for (example: "5.0.0")]], + Description = [[check_min_api_version compares the minimum api required for the appllication to + run against the current api version. The minimum api version is typically the api version that + was current when the application was created. If the minimum api version is not met, then an + error message is printed to the log. + + This function is intended to replace darktable.configuration.check_version(). The application code + won't have to be updated each time the api changes because this only checks the minimum version required.]], + Return_Value = [[result - true if the minimum api version is available, false if not.]], + Limitations = [[]], + Example = [[check_min_api_version("5.0.0") returns true if the api is greater or equal to 5.0.0 otherwise an + error message is printed to the log and false is returned.]], + See_Also = [[]], + Reference = [[]], + License = [[]], + Copyright = [[]], +} + +function dtutils.check_min_api_version(min_api) + local current_api = dt.configuration.api_version_string + if min_api <= current_api then + return true + else + dt.print_error("This application is written for lua api version " .. min_api .. " or later.") + dt.print_error("The current lua api version is " .. current_api) + return false + end +end dtutils.libdoc.functions["split"] = { Name = [[split]], diff --git a/lib/dtutils/file.lua b/lib/dtutils/file.lua index 120b70f..5c4a114 100644 --- a/lib/dtutils/file.lua +++ b/lib/dtutils/file.lua @@ -1,5 +1,6 @@ local dtutils_file = {} local dt = require "darktable" +local du = require "lib/dtutils" local ds = require "lib/dtutils.string" local log = require "lib/dtutils.log" @@ -24,7 +25,9 @@ dtutils_file.libdoc = { local gettext = dt.gettext -dt.configuration.check_version(...,{5,0,0}) +if not du.check_min_api_version("5.0.0") then + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("dtutils.file",dt.configuration.config_dir.."/lua/locale/") diff --git a/official/check_for_updates.lua b/official/check_for_updates.lua index 221a660..cfcf914 100644 --- a/official/check_for_updates.lua +++ b/official/check_for_updates.lua @@ -28,10 +28,14 @@ USAGE ]] local dt = require "darktable" +local du = require "lib/dtutils" local https = require "ssl.https" local cjson = require "cjson" -dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.0.0") then + dt.print("ERROR:check_for_updates not loaded. Lua API version 2.0.0 or greater required.") + return +end -- compare two version strings of the form "major.minor.patch" -- returns -1, 0, 1 if the first version is smaller, equal, greater than the second version, diff --git a/official/copy_paste_metadata.lua b/official/copy_paste_metadata.lua index 4d1c70b..e417f61 100644 --- a/official/copy_paste_metadata.lua +++ b/official/copy_paste_metadata.lua @@ -26,8 +26,12 @@ USAGE ]] 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:copy_paste_metadata not loaded. Lua API version 3.0.0 or greater required.") + return +end -- set this to "false" if you don't want to overwrite metadata fields -- (title, description, creator, publisher and rights) that are already set diff --git a/official/delete_long_tags.lua b/official/delete_long_tags.lua index 5a2da73..cf4ebfd 100644 --- a/official/delete_long_tags.lua +++ b/official/delete_long_tags.lua @@ -29,7 +29,12 @@ all tags longer than the given length will be automatically deleted at every res ]] 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:delete_long_tags not loaded. Lua API version 2.0.0 or greater required.") + return +end dt.preferences.register("delete_long_tags", "length", "integer", "maximum length of tags to keep", diff --git a/official/delete_unused_tags.lua b/official/delete_unused_tags.lua index 337f5f6..8ceaa7e 100644 --- a/official/delete_unused_tags.lua +++ b/official/delete_unused_tags.lua @@ -27,8 +27,12 @@ all tags that are not used will be automatically deleted at every restart ]] local dt = require "darktable" +local du = require "lib/dtutils" -dt.configuration.check_version(...,{5,0,0}) +if not du.check_min_api_version("5.0.0") then + dt.print("ERROR:delete_unused_tags not loaded. Lua API version 5.0.0 or greater required.") + return +end -- deleting while iterating the tags list seems to break the iterator! local unused_tags = {} diff --git a/official/enfuse.lua b/official/enfuse.lua index 04dda4d..8f960f5 100644 --- a/official/enfuse.lua +++ b/official/enfuse.lua @@ -33,11 +33,15 @@ TODO ]] local dt = require "darktable" +local du = require "lib/dtutils" local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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:enfuse not loaded. Lua API version 3.0.0 or greater required.") + return +end -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("enfuse",dt.configuration.config_dir.."/lua/locale/") diff --git a/official/generate_image_txt.lua b/official/generate_image_txt.lua index 8dcd5d1..2e0d13b 100644 --- a/official/generate_image_txt.lua +++ b/official/generate_image_txt.lua @@ -35,10 +35,14 @@ USAGE -- * make filenames with double quotes (") work local dt = require "darktable" +local du = require "lib/dtutils" require "darktable.debug" require "official/yield" -dt.configuration.check_version(...,{2,1,0},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.1.0") then + dt.print("ERROR:generate_image_txt not loaded. Lua API version 2.1.0 or greater required.") + return +end dt.preferences.register("generate_image_txt", "enabled", diff --git a/official/image_path_in_ui.lua b/official/image_path_in_ui.lua index b21a218..074bb6a 100644 --- a/official/image_path_in_ui.lua +++ b/official/image_path_in_ui.lua @@ -29,7 +29,12 @@ This plugin will add a widget at the bottom of the left column in lighttable mod ]] 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:image_path_in_ui not loaded. Lua API version 2.0.0 or greater required.") + return +end local main_label = dt.new_widget("label"){selectable = true, ellipsize = "middle", halign = "start"} diff --git a/official/save_selection.lua b/official/save_selection.lua index fd9f4f8..32555a2 100644 --- a/official/save_selection.lua +++ b/official/save_selection.lua @@ -34,7 +34,12 @@ increase it if you need more temporary selection buffers ]] 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:save_selection not loaded. Lua API version 2.0.0 or greater required.") + return +end local buffer_count = 5 diff --git a/official/selection_to_pdf.lua b/official/selection_to_pdf.lua index f44a8dc..dcc797f 100644 --- a/official/selection_to_pdf.lua +++ b/official/selection_to_pdf.lua @@ -34,9 +34,13 @@ Plugin allows you to choose how many thumbnails you need per row ]] local dt = require "darktable" +local du = require "lib/dtutils" require "official/yield" -dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0}) +if not du.check_min_api_version("2.0.0") then + dt.print("ERROR:selection_to_pdf not loaded. Lua API version 2.0.0 or greater required.") + return +end dt.preferences.register ("selection_to_pdf","Open with","string", diff --git a/tools/get_lib_manpages.lua b/tools/get_lib_manpages.lua index cea3bbc..6e21bba 100644 --- a/tools/get_lib_manpages.lua +++ b/tools/get_lib_manpages.lua @@ -10,7 +10,10 @@ local df = require "lib/dtutils.file" local log = require "lib/dtutils.log" local libname = nil -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: get_lib_manpages failed to load. Lua API version 3.0.0 or greater required.") + return +end local keys = {"Name", "Synopsis", "Usage", "Description", "Return_Value", "Limitations", "Example", "See_Also", "Reference", "License", "Copyright"} diff --git a/tools/get_libdoc.lua b/tools/get_libdoc.lua index 42b19e4..47689cf 100644 --- a/tools/get_libdoc.lua +++ b/tools/get_libdoc.lua @@ -5,8 +5,12 @@ ]] 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: get_libdoc failed to load. Lua API version 3.0.0 or greater required.") + return +end local keys = {"Name", "Synopsis", "Usage", "Description", "Return_Value", "Limitations", "Example", "See_Also", "Reference", "License", "Copyright"} diff --git a/tools/script_manager.lua b/tools/script_manager.lua index d8484ea..d0aabd2 100644 --- a/tools/script_manager.lua +++ b/tools/script_manager.lua @@ -455,7 +455,10 @@ end -- api check -dt.configuration.check_version(...,{5,0,0}) +if not du.check_min_api_version("5.0.0") then + dt.print("ERROR:script_manager failed to load. Lua API version 5.0.0 or greater required.") + return +end -- set up tables to contain all the widgets and choices