From ba94914c0e256aae2d09f2c6fc8877da1c70edfb Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Thu, 20 Jun 2024 18:09:10 -0400 Subject: [PATCH] contrib/auto_snapshot - added Lua option to create always create a snapshot when opening an image in darkroom, even if it is altered --- contrib/auto_snapshot.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/auto_snapshot.lua b/contrib/auto_snapshot.lua index e7d3986..a5eca61 100644 --- a/contrib/auto_snapshot.lua +++ b/contrib/auto_snapshot.lua @@ -37,6 +37,7 @@ local dt = require "darktable" local du = require "lib/dtutils" +local log = require "lib/dtutils.log" -- - - - - - - - - - - - - - - - - - - - - - - - -- C O N S T A N T S @@ -96,6 +97,13 @@ log.log_level(DEFAULT_LOG_LEVEL) local auto_snapshot = {} +-- - - - - - - - - - - - - - - - - - - - - - - - +-- P R E F E R E N C E S +-- - - - - - - - - - - - - - - - - - - - - - - - + +dt.preferences.register(MODULE, "always_create_snapshot", "bool", "always automatically create_snapshot", + "auto_snapshot - create a snapshot even if the image is altered", false) + -- - - - - - - - - - - - - - - - - - - - - - - - -- D A R K T A B L E I N T E G R A T I O N -- - - - - - - - - - - - - - - - - - - - - - - - @@ -112,7 +120,10 @@ script_data.destroy = destroy dt.register_event(MODULE, "darkroom-image-loaded", function(event, clean, image) - if clean then + local always = dt.preferences.read(MODULE, "always_create_snapshot", "bool") + if clean and always then + dt.gui.libs.snapshots.take_snapshot() + elseif clean and not image.is_altered then dt.gui.libs.snapshots.take_snapshot() end