[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:
@@ -34,6 +34,14 @@ local cjson = require "cjson"
|
||||
|
||||
du.check_min_api_version("2.0.0", "check_for_updates")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
-- 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,
|
||||
-- or nil if one or both are of the wrong format
|
||||
@@ -80,6 +88,10 @@ local function compare_versions(a, b)
|
||||
end
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
|
||||
-- local function test(a, b, r)
|
||||
-- local cmp = compare_versions(a, b)
|
||||
@@ -134,3 +146,6 @@ if now > (back_then + 60 * 60 * 24 * 7) then
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
script_data.destroy = destroy
|
||||
return script_data
|
||||
|
||||
@@ -29,8 +29,15 @@ local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local gettext = dt.gettext
|
||||
|
||||
du.check_min_api_version("3.0.0", "copy_paste_metadata")
|
||||
local CURR_API_STRING = dt.configuration.api_version_string
|
||||
du.check_min_api_version("7.0.0", "copy_paste_metadata")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
-- set this to "false" if you don't want to overwrite metadata fields
|
||||
-- (title, description, creator, publisher and rights) that are already set
|
||||
@@ -113,26 +120,41 @@ local function paste(images)
|
||||
end
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.gui.libs.image.destroy_action("metadata_copy")
|
||||
dt.gui.libs.image.destroy_action("metadata_paste")
|
||||
dt.destroy_event("capmd1", "shortcut")
|
||||
dt.destroy_event("capmd2", "shortcut")
|
||||
end
|
||||
|
||||
dt.gui.libs.image.register_action(
|
||||
_("copy metadata"),
|
||||
"metadata_copy", _("copy metadata"),
|
||||
function(event, images) copy(images[1]) end,
|
||||
_("copy metadata of the first selected image")
|
||||
)
|
||||
|
||||
|
||||
|
||||
dt.gui.libs.image.register_action(
|
||||
_("paste metadata"),
|
||||
"metadata_paste", _("paste metadata"),
|
||||
function(event, images) paste(images) end,
|
||||
_("paste metadata to the selected images")
|
||||
)
|
||||
|
||||
|
||||
|
||||
dt.register_event(
|
||||
"shortcut",
|
||||
"capmd1", "shortcut",
|
||||
function(event, shortcut) copy(dt.gui.action_images[1]) end,
|
||||
"copy metadata"
|
||||
)
|
||||
|
||||
dt.register_event(
|
||||
"shortcut",
|
||||
"capmd2", "shortcut",
|
||||
function(event, shortcut) paste(dt.gui.action_images) end,
|
||||
"paste metadata"
|
||||
)
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
|
||||
@@ -33,11 +33,23 @@ local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("2.0.0", "delete_long_tags")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
dt.preferences.register("delete_long_tags", "length", "integer",
|
||||
"maximum length of tags to keep",
|
||||
"tags longer than this get deleted on start",
|
||||
666, 0, 65536)
|
||||
|
||||
local function destroy()
|
||||
-- noting to destroy
|
||||
end
|
||||
|
||||
local max_length = dt.preferences.read("delete_long_tags", "length", "integer")
|
||||
|
||||
-- deleting while iterating the tags list seems to break the iterator!
|
||||
@@ -55,3 +67,7 @@ for _,name in pairs(long_tags) do
|
||||
tag = dt.tags.find(name)
|
||||
tag:delete()
|
||||
end
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
|
||||
@@ -31,6 +31,20 @@ local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("5.0.0", "delete_unused_tags")
|
||||
|
||||
local script_data = {}
|
||||
|
||||
local function destroy()
|
||||
-- noting to destroy
|
||||
end
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
-- deleting while iterating the tags list seems to break the iterator!
|
||||
local unused_tags = {}
|
||||
|
||||
@@ -45,3 +59,6 @@ for _,name in pairs(unused_tags) do
|
||||
tag = dt.tags.find(name)
|
||||
tag:delete()
|
||||
end
|
||||
|
||||
script_data.destroy = destroy
|
||||
return script_data
|
||||
@@ -38,11 +38,18 @@ local df = require "lib/dtutils.file"
|
||||
local dtsys = require "lib/dtutils.system"
|
||||
|
||||
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
local CURR_API_STRING = dt.configuration.api_version_string
|
||||
|
||||
local gettext = dt.gettext
|
||||
|
||||
du.check_min_api_version("3.0.0", "enfuse")
|
||||
du.check_min_api_version("7.0.0", "enfuse")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
-- Tell gettext where to find the .mo file translating messages for a particular domain
|
||||
gettext.bindtextdomain("enfuse",dt.configuration.config_dir..PS .. "lua" .. PS .. "locale" .. PS)
|
||||
@@ -76,6 +83,15 @@ local function install_module()
|
||||
enf.module_installed = true
|
||||
end
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.gui.libs["enfuse"].visible = false
|
||||
end
|
||||
|
||||
local function restart()
|
||||
dt.gui.libs["enfuse"].visible = true
|
||||
end
|
||||
|
||||
-- add a new lib
|
||||
-- is enfuse installed?
|
||||
local enfuse_installed = df.check_if_bin_exists("enfuse")
|
||||
@@ -269,7 +285,7 @@ if enfuse_installed then
|
||||
else
|
||||
if not enf.event_registered then
|
||||
dt.register_event(
|
||||
"view-changed",
|
||||
"enfuse", "view-changed",
|
||||
function(event, old_view, new_view)
|
||||
if new_view.name == "lighttable" and old_view.name == "darkroom" then
|
||||
install_module()
|
||||
@@ -285,5 +301,11 @@ else
|
||||
dt.print(_("Could not find enfuse executable. Not loading enfuse exporter..."))
|
||||
end
|
||||
|
||||
script_data.destroy = destroy
|
||||
script_data.restart = restart
|
||||
script_data.destroy_method = "hide"
|
||||
script_data.show = restart
|
||||
|
||||
return script_data
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
-- kate: hl Lua;
|
||||
|
||||
@@ -38,8 +38,15 @@ local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
require "darktable.debug"
|
||||
|
||||
du.check_min_api_version("2.1.0", "generate_image_txt")
|
||||
local CURR_API_STRING = dt.configuration.api_version_string
|
||||
du.check_min_api_version("7.0.0", "generate_image_txt")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
dt.preferences.register("generate_image_txt",
|
||||
"enabled",
|
||||
@@ -62,11 +69,15 @@ local check_command = function(command)
|
||||
end
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.destroy_event("gen_img_txt", "mouse-over-image-changed")
|
||||
end
|
||||
|
||||
|
||||
local command_setting = dt.preferences.read("generate_image_txt", "command", "string")
|
||||
check_command(command_setting)
|
||||
|
||||
dt.register_event("mouse-over-image-changed",
|
||||
dt.register_event("gen_img_txt", "mouse-over-image-changed",
|
||||
function(event, img)
|
||||
-- no need to waste processing time if the image has a txt file already
|
||||
if not img or img.has_txt or not dt.preferences.read("generate_image_txt", "enabled", "bool") then
|
||||
@@ -105,6 +116,9 @@ dt.register_event("mouse-over-image-changed",
|
||||
end
|
||||
)
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent
|
||||
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on;
|
||||
|
||||
@@ -31,8 +31,15 @@ This plugin will add a widget at the bottom of the left column in lighttable mod
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("2.0.0", "image_path_in_ui")
|
||||
local CURR_API_STRING = dt.configuration.api_version_string
|
||||
du.check_min_api_version("7.0.0", "image_path_in_ui")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
local ipiu = {}
|
||||
ipiu.module_installed = false
|
||||
@@ -42,8 +49,8 @@ local main_label = dt.new_widget("label"){selectable = true, ellipsize = "middle
|
||||
|
||||
local function install_module()
|
||||
if not ipiu.module_installed then
|
||||
dt.register_lib("image_path_no_ui", "selected images path", true, false,{
|
||||
[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 300}
|
||||
dt.register_lib("image_path_no_ui","selected images path",true,false,{
|
||||
[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER",300}
|
||||
}, main_label
|
||||
)
|
||||
ipiu.module_installed = true
|
||||
@@ -67,6 +74,20 @@ local function reset_widget()
|
||||
main_label.label = result
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.gui.libs["image_path_no_ui"].visible = false
|
||||
dt.destroy_event("ipiu", "mouse-over-image-changed")
|
||||
end
|
||||
|
||||
local function restart()
|
||||
dt.register_event("ipiu", "mouse-over-image-changed", reset_widget);
|
||||
dt.gui.libs["image_path_no_ui"].visible = true
|
||||
end
|
||||
|
||||
local function show()
|
||||
dt.gui.libs["image_path_no_ui"].visible = true
|
||||
end
|
||||
|
||||
main_label.reset_callback = reset_widget
|
||||
|
||||
if dt.gui.current_view().id == "lighttable" then
|
||||
@@ -85,7 +106,13 @@ else
|
||||
end
|
||||
end
|
||||
|
||||
dt.register_event("mouse-over-image-changed", reset_widget);
|
||||
dt.register_event("ipiu", "mouse-over-image-changed", reset_widget);
|
||||
|
||||
script_data.destroy = destroy
|
||||
script_data.restart = restart
|
||||
script_data.destroy_method = "hide"
|
||||
script_data.show = show
|
||||
|
||||
return script_data
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
|
||||
@@ -34,7 +34,6 @@ local dt = require "darktable"
|
||||
|
||||
local import_filter_list = {}
|
||||
local n_import_filters = 1
|
||||
local CURR_API_STRING = dt.configuration.api_version_string
|
||||
|
||||
-- allow changing the filter from the preferences
|
||||
dt.preferences.register("import_filter_manager", "active_filter", "string",
|
||||
@@ -57,7 +56,7 @@ dt.gui.libs.import.register_widget(filter_dropdown)
|
||||
|
||||
|
||||
-- this is just a wrapper which calls the active import filter
|
||||
dt.register_event("pre-import", function(event, images)
|
||||
dt.register_event("ifm", "pre-import", function(event, images)
|
||||
local active_filter = dt.preferences.read("import_filter_manager", "active_filter", "string")
|
||||
if active_filter == "" then return end
|
||||
local callback = import_filter_list[active_filter]
|
||||
|
||||
@@ -36,25 +36,43 @@ increase it if you need more temporary selection buffers
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("2.0.0", "save_selection")
|
||||
local CURR_API_STRING = dt.configuration.api_version_string
|
||||
du.check_min_api_version("7.0.0", "save_selection")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
local buffer_count = 5
|
||||
|
||||
for i=1,buffer_count do
|
||||
local function destroy()
|
||||
for i = 1, buffer_count do
|
||||
dt.destroy_event("save_selection save " .. i, "shortcut")
|
||||
dt.destroy_event("save_selection restore " .. i, "shortcut")
|
||||
end
|
||||
dt.destroy_event("save_selection switch", "shortcut")
|
||||
end
|
||||
|
||||
for i = 1, buffer_count do
|
||||
local saved_selection
|
||||
dt.register_event("shortcut", function()
|
||||
dt.register_event("save_selection save " .. i, "shortcut", function()
|
||||
saved_selection = dt.gui.selection()
|
||||
end,"save to buffer "..i)
|
||||
dt.register_event("shortcut", function()
|
||||
end, "save to buffer " .. i)
|
||||
dt.register_event("save_selection restore " .. i, "shortcut", function()
|
||||
dt.gui.selection(saved_selection)
|
||||
end,"restore from buffer "..i)
|
||||
end, "restore from buffer " .. i)
|
||||
end
|
||||
|
||||
local bounce_buffer = {}
|
||||
dt.register_event("shortcut", function()
|
||||
dt.register_event("save_selection switch", "shortcut", function()
|
||||
bounce_buffer = dt.gui.selection(bounce_buffer)
|
||||
end,"switch selection with temporary buffer")
|
||||
end, "switch selection with temporary buffer")
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
|
||||
@@ -36,7 +36,15 @@ Plugin allows you to choose how many thumbnails you need per row
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("2.0.0", "selection_to_pdf")
|
||||
du.check_min_api_version("7.0.0", "selection_to_pdf")
|
||||
|
||||
-- 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
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
|
||||
dt.preferences.register
|
||||
("selection_to_pdf","Open with","string",
|
||||
@@ -101,6 +109,12 @@ local function thumbnail(latexfile,i,image,file)
|
||||
my_write(latexfile,"\\end{minipage}\\quad\n")
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.print_log("destroying storage")
|
||||
dt.destroy_storage("export_pdf")
|
||||
dt.print_log("done destroying")
|
||||
end
|
||||
|
||||
dt.register_storage("export_pdf","Export thumbnails to pdf",
|
||||
nil,
|
||||
function(storage,image_table)
|
||||
@@ -168,5 +182,8 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
|
||||
end
|
||||
end,nil,nil,widget)
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
|
||||
Reference in New Issue
Block a user