[gimp/wip/schumaml/issue-6421-darktable-master-lua: 8/8] plug-ins: update darktable lua script to API change in darktable master




commit 636eb02edc8e476346666776b276669c8c77c172
Author: William Ferguson <wpferguson gmail com>
Date:   Wed Feb 10 21:44:54 2021 +0100

    plug-ins: update darktable lua script to API change in darktable master
    
    The Lua API is undergoing changes in darktable master. I've fixed the lua-scripts repository as I've made
    changes, but I forgot about the collateral damage.
    
    Attached is a fixed version of file-darktable-export-on-exit.lua which should be good for darktable 3.6 
and
    beyond.
    
    Fixes #6421

 .../file-raw/file-darktable-export-on-exit.lua     | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/plug-ins/file-raw/file-darktable-export-on-exit.lua 
b/plug-ins/file-raw/file-darktable-export-on-exit.lua
index 7a7f81cb02..79b27dc089 100644
--- a/plug-ins/file-raw/file-darktable-export-on-exit.lua
+++ b/plug-ins/file-raw/file-darktable-export-on-exit.lua
@@ -31,6 +31,24 @@ USAGE
 
 local dt = require "darktable"
 
+local orig_register_event = dt.register_event
+
+function dt.register_event(name, event, func, label)
+  if dt.configuration.api_version_string >= "6.2.1" then
+    if label then
+      orig_register_event(name, event, func, label)
+    else
+      orig_register_event(name, event, func)
+    end
+  else
+    if label then
+      orig_register_event(event, func, label)
+    else
+      orig_register_event(event, func)
+    end
+  end
+end
+
 local min_api_version = "2.1.0"
 if dt.configuration.api_version_string < min_api_version then
   dt.print("the exit export script requires at least darktable version 1.7.0")
@@ -40,9 +58,11 @@ else
   dt.print("closing darktable will export the image and make GIMP load it")
 end
 
+local CURR_API_STRING = dt.configuration.api_version_string
+
 local export_filename = dt.preferences.read("export_on_exit", "export_filename", "string")
 
-dt.register_event("exit", function()
+dt.register_event("fileraw", "exit", function()
   -- safegurad against someone using this with their library containing 50k images
   if #dt.database > 1 then
     dt.print_error("too many images, only exporting the first")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]