[API 7.0.0 compatibility] Made changes to take advantage of the latest API changes

including the ability to start and stop most scripts.
This commit is contained in:
Bill Ferguson
2021-06-19 23:34:14 -04:00
parent f272aeb9fe
commit 5da64a7da0
59 changed files with 1675 additions and 449 deletions

View File

@@ -39,13 +39,20 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local MODULE_NAME = "photils"
du.check_min_api_version("5.0.0", MODULE_NAME)
du.check_min_api_version("7.0.0", MODULE_NAME)
-- return data structure for script_manager
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
local CURR_API_STRING = dt.configuration.api_version_string
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local gettext = dt.gettext
gettext.bindtextdomain(MODULE_NAME,
@@ -391,6 +398,22 @@ local function install_module()
end
end
local function destroy()
dt.gui.libs[MODULE_NAME].visible = false
dt.destroy_event("photils", "mouse-over-image-changed")
end
local function restart()
dt.gui.libs[MODULE_NAME].visible = true
dt.register_event("photils", "mouse-over-image-changed",
PHOTILS.image_changed)
end
local function show()
dt.gui.libs[MODULE_NAME].visible = true
end
-- add a fix number of buttons
for _ = 1, PHOTILS.per_page, 1 do
local btn_tag = dt.new_widget("check_button") {
@@ -454,7 +477,7 @@ dt.preferences.register(MODULE_NAME,
"The embedded thumbnail could speedup the tag suggestion but can fail if the RAW file is not supported."),
true)
dt.register_event("mouse-over-image-changed",
dt.register_event("photils", "mouse-over-image-changed",
PHOTILS.image_changed)
if dt.gui.current_view().id == "lighttable" then
@@ -462,7 +485,7 @@ if dt.gui.current_view().id == "lighttable" then
else
if not PHOTILS.event_registered then
dt.register_event(
"view-changed",
"photils", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
@@ -473,3 +496,9 @@ else
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = show
return script_data