From 4053ceb9e5dc265ca1cbd020e995ed805ae00ded Mon Sep 17 00:00:00 2001 From: wpferguson Date: Wed, 17 Feb 2021 22:24:02 -0500 Subject: [PATCH] [API 6.2.3] Added changes for API 6.2.3 compatibility --- contrib/CollectHelper.lua | 72 +++++++++++++++++++++++--------- contrib/OpenInExplorer.lua | 20 ++++++--- contrib/clear_GPS.lua | 19 ++++++--- examples/multi_os.lua | 20 ++++++--- official/copy_paste_metadata.lua | 40 +++++++++++++----- 5 files changed, 127 insertions(+), 44 deletions(-) diff --git a/contrib/CollectHelper.lua b/contrib/CollectHelper.lua index 5996592..4247b8b 100644 --- a/contrib/CollectHelper.lua +++ b/contrib/CollectHelper.lua @@ -53,6 +53,8 @@ local all_active = false -- Tell gettext where to find the .mo file translating messages for a particular domain gettext.bindtextdomain("CollectHelper",dt.configuration.config_dir.."/lua/locale/") +local CURR_API_STRING = dt.configuration.api_version_string + local function _(msgid) return gettext.dgettext("CollectHelper", msgid) end @@ -173,31 +175,63 @@ local function CollectOnAll_AND() end -- GUI -- -dt.gui.libs.image.register_action( - _("collect: previous"), - function() PreviousCollection() end, - _("Sets the Collect parameters to be the previously active parameters") -) -if dt.preferences.read('module_CollectHelper','folder','bool') then +if CURR_API_STRING < "6.2.3" then dt.gui.libs.image.register_action( - _("collect: folder"), - function() CollectOnFolder(_ , false) end, - _("Sets the Collect parameters to be the selected images's folder") + _("collect: previous"), + function() PreviousCollection() end, + _("Sets the Collect parameters to be the previously active parameters") ) +else + dt.gui.libs.image.register_action( + "CollectHelper_prev", _("collect: previous"), + function() PreviousCollection() end, + _("Sets the Collect parameters to be the previously active parameters") + ) +end +if dt.preferences.read('module_CollectHelper','folder','bool') then + if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("collect: folder"), + function() CollectOnFolder(_ , false) end, + _("Sets the Collect parameters to be the selected images's folder") + ) + else + dt.gui.libs.image.register_action( + "CollectHelper_folder", _("collect: folder"), + function() CollectOnFolder(_ , false) end, + _("Sets the Collect parameters to be the selected images's folder") + ) + end end if dt.preferences.read('module_CollectHelper','colors','bool') then - dt.gui.libs.image.register_action( - _("collect: color label(s)"), - function() CollectOnColors(_ , false) end, - _("Sets the Collect parameters to be the selected images's color label(s)") - ) + if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("collect: color label(s)"), + function() CollectOnColors(_ , false) end, + _("Sets the Collect parameters to be the selected images's color label(s)") + ) + else + dt.gui.libs.image.register_action( + "CollectHelper_labels", _("collect: color label(s)"), + function() CollectOnColors(_ , false) end, + _("Sets the Collect parameters to be the selected images's color label(s)") + ) + end end if dt.preferences.read('module_CollectHelper','all_and','bool') then - dt.gui.libs.image.register_action( - _("collect: all (AND)"), - function() CollectOnAll_AND() end, - _("Sets the Collect parameters based on all activated CollectHelper options") - ) + if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("collect: all (AND)"), + function() CollectOnAll_AND() end, + _("Sets the Collect parameters based on all activated CollectHelper options") + ) + else + dt.gui.libs.image.register_action( + "CollectHelper_and", _("collect: all (AND)"), + function() CollectOnAll_AND() end, + _("Sets the Collect parameters based on all activated CollectHelper options") + ) + end end -- PREFERENCES -- diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua index 72ec15d..d9fe4a6 100644 --- a/contrib/OpenInExplorer.lua +++ b/contrib/OpenInExplorer.lua @@ -184,11 +184,21 @@ end -- GUI -- -dt.gui.libs.image.register_action( - _("show in file explorer"), - function() open_in_fmanager() end, - _("Open the file manager at the selected image's location") -) +if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("show in file explorer"), + function() open_in_fmanager() end, + _("Open the file manager at the selected image's location") + ) +else + dt.gui.libs.image.register_action( + "OpenInExplorer", _("show in file explorer"), + function() open_in_fmanager() end, + _("Open the file manager at the selected image's location") + ) +end + + if act_os ~= "windows" then dt.preferences.register("OpenInExplorer", "linked_image_files_dir", -- name "directory", -- type diff --git a/contrib/clear_GPS.lua b/contrib/clear_GPS.lua index 58404f9..a67fc1a 100644 --- a/contrib/clear_GPS.lua +++ b/contrib/clear_GPS.lua @@ -64,12 +64,21 @@ local function clear_GPS(images) end end +if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("clear GPS data"), + function(event, images) clear_GPS(images) end, + _("Clear GPS data from selected images") + ) +else + dt.gui.libs.image.register_action( + _"clear_GPS", ("clear GPS data"), + function(event, images) clear_GPS(images) end, + _("Clear GPS data from selected images") + ) +end + -dt.gui.libs.image.register_action( - _("clear GPS data"), - function(event, images) clear_GPS(images) end, - _("Clear GPS data from selected images") -) dt.register_event( "clearGPS", "shortcut", diff --git a/examples/multi_os.lua b/examples/multi_os.lua index 6ab356b..d71f0d4 100644 --- a/examples/multi_os.lua +++ b/examples/multi_os.lua @@ -231,11 +231,21 @@ end Add a button to the selected images module in lighttable ]] -dt.gui.libs.image.register_action( - _("extract embedded jpeg"), - function(event, images) extract_embedded_jpeg(images) end, - "extract embedded jpeg" -) +if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("extract embedded jpeg"), + function(event, images) extract_embedded_jpeg(images) end, + "extract embedded jpeg" + ) +else + dt.gui.libs.image.register_action( + "multi_os", _("extract embedded jpeg"), + function(event, images) extract_embedded_jpeg(images) end, + "extract embedded jpeg" + ) +end + + --[[ Add a shortcut diff --git a/official/copy_paste_metadata.lua b/official/copy_paste_metadata.lua index 1db3d62..2c10029 100644 --- a/official/copy_paste_metadata.lua +++ b/official/copy_paste_metadata.lua @@ -114,17 +114,37 @@ local function paste(images) end end -dt.gui.libs.image.register_action( - _("copy metadata"), - function(event, images) copy(images[1]) end, - _("copy metadata of the first selected image") -) +if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("copy metadata"), + function(event, images) copy(images[1]) end, + _("copy metadata of the first selected image") + ) +else + dt.gui.libs.image.register_action( + "metadata_copy", _("copy metadata"), + function(event, images) copy(images[1]) end, + _("copy metadata of the first selected image") + ) +end + + + +if CURR_API_STRING < "6.2.3" then + dt.gui.libs.image.register_action( + _("paste metadata"), + function(event, images) paste(images) end, + _("paste metadata to the selected images") + ) +else + dt.gui.libs.image.register_action( + "metadata_paste", _("paste metadata"), + function(event, images) paste(images) end, + _("paste metadata to the selected images") + ) +end + -dt.gui.libs.image.register_action( - _("paste metadata"), - function(event, images) paste(images) end, - _("paste metadata to the selected images") -) dt.register_event( "capmd1", "shortcut",