From d1e330eee07bdae2792b2204fe97edd473e21b17 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 22:01:58 -0400 Subject: [PATCH 01/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- tools/script_manager.lua | 52 ++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/tools/script_manager.lua b/tools/script_manager.lua index 0946ae5..9592a7e 100644 --- a/tools/script_manager.lua +++ b/tools/script_manager.lua @@ -450,6 +450,26 @@ local function link_downloads_directory() os.execute("ln -s " .. "$HOME/Downloads " .. LUA_DIR .. "/downloads") end +local function install_module() + if not sm.module_installed then + dt.register_lib( + "script_manager", -- Module name + "script manager", -- Visible name + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 0}}, -- containers + dt.new_widget("box") -- widget + { + orientation = "vertical", + sm.main_box, + }, + nil,-- view_enter + nil -- view_leave + ) + sm.module_installed = true + end +end + -- - - - - - - - - - - - - - - - - - - - - - - - -- M A I N P R O G R A M -- - - - - - - - - - - - - - - - - - - - - - - - @@ -466,6 +486,8 @@ sm.script_names = {} sm.script_paths = {} sm.main_menu_choices = {} sm.main_stack_items = {} +sm.event_registered = false +sm.module_installed = false -- see if we've run this before @@ -742,21 +764,21 @@ sm.main_box = dt.new_widget("box"){ -- D A R K T A B L E I N T E G R A T I O N -- - - - - - - - - - - - - - - - - - - - - - - - --- register the module -dt.register_lib( - "script_manager", -- Module name - "script manager", -- Visible name - true, -- expandable - false, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 0}}, -- containers - dt.new_widget("box") -- widget - { - orientation = "vertical", - sm.main_box, - }, - nil,-- view_enter - nil -- view_leave -) +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not sm.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + sm.event_registered = true + end +end -- set up the scripts block if we have them otherwise we'll wait until we download them From 50be8a924044a0bd2b919e2513d9bb89aaa99ae0 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 22:11:29 -0400 Subject: [PATCH 02/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- official/enfuse.lua | 66 +++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/official/enfuse.lua b/official/enfuse.lua index 3b5bb7c..7432a1e 100644 --- a/official/enfuse.lua +++ b/official/enfuse.lua @@ -46,10 +46,35 @@ du.check_min_api_version("3.0.0", "enfuse") -- 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) +local enf = {} +enf.event_registered = false +enf.module_installed = false +enf.lib_widgets = {} + local function _(msgid) return gettext.dgettext("enfuse", msgid) end +local function install_module() + if not enf.module_installed then + dt.register_lib( + "enfuse", -- plugin name + "enfuse", -- name + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers + dt.new_widget("box") -- widget + { + orientation = "vertical", + sensitive = enfuse_installed, + table.unpack(enf.lib_widgets) + }, + nil,-- view_enter + nil -- view_leave + ) + enf.module_installed = true + end +end -- add a new lib -- is enfuse installed? local enfuse_installed = df.check_if_bin_exists("enfuse") @@ -229,30 +254,31 @@ if enfuse_installed then local lib_widgets = {} if not enfuse_installed then - table.insert(lib_widgets, df.executable_path_widget({"ffmpeg"})) + table.insert(enf.lib_widgets, df.executable_path_widget({"ffmpeg"})) end - table.insert(lib_widgets, exposure_mu) - table.insert(lib_widgets, depth) - table.insert(lib_widgets, blend_colorspace) - table.insert(lib_widgets, enfuse_button) + table.insert(enf.lib_widgets, exposure_mu) + table.insert(enf.lib_widgets, depth) + table.insert(enf.lib_widgets, blend_colorspace) + table.insert(enf.lib_widgets, enfuse_button) -- ... and tell dt about it all - dt.register_lib( - "enfuse", -- plugin name - "enfuse", -- name - true, -- expandable - false, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers - dt.new_widget("box") -- widget - { - orientation = "vertical", - sensitive = enfuse_installed, - table.unpack(lib_widgets) - }, - nil,-- view_enter - nil -- view_leave - ) + if dt.gui.current_view().name == "lighttable" then + install_module() + else + if not enf.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + dt.print_log("view changed from darkroom to lighttable") + install_module() + end + end + ) + enf.event_registered = true + end + end else dt.print_error("enfuse executable not found") error("enfuse executable not found") From 4e68e420ccf2236641fe3c2c525aee9a631ece23 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 22:40:40 -0400 Subject: [PATCH 03/20] removed debugging print statemant --- official/enfuse.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/official/enfuse.lua b/official/enfuse.lua index 7432a1e..4213b48 100644 --- a/official/enfuse.lua +++ b/official/enfuse.lua @@ -271,7 +271,6 @@ if enfuse_installed then "view-changed", function(event, old_view, new_view) if new_view.name == "lighttable" and old_view.name == "darkroom" then - dt.print_log("view changed from darkroom to lighttable") install_module() end end From 2ddd0965cd16302304c16925f9d9ff2cccc3e089 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 22:40:54 -0400 Subject: [PATCH 04/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- examples/moduleExample.lua | 94 ++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 28 deletions(-) diff --git a/examples/moduleExample.lua b/examples/moduleExample.lua index 2c46a08..12de682 100644 --- a/examples/moduleExample.lua +++ b/examples/moduleExample.lua @@ -46,6 +46,44 @@ local function _(msgid) return gettext.dgettext("moduleExample", msgid) end +-- declare a local namespace and a couple of variables we'll need to install the module +local mE = {} +mE.widgets = {} +mE.event_registered = false -- keep track of whether we've added an event callback or not +mE.module_installed = false -- keep track of whether the module is module_installed + +--[[ We have to create the module in one of two ways depending on which view darktable starts + in. In orker to not repeat code, we wrap the darktable.register_lib in a local function. + ]] + +local function install_module() + if not mE.module_installed then + -- https://www.darktable.org/lua-api/index.html#darktable_register_lib + dt.register_lib( + "exampleModule", -- Module name + "exampleModule", -- name + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers + -- https://www.darktable.org/lua-api/types_lua_box.html + dt.new_widget("box") -- widget + { + orientation = "vertical", + dt.new_widget("button") + { + label = _("MyButton"), + clicked_callback = function (_) + dt.print(_("Button clicked")) + end + }, + table.unpack(mE.widgets), + }, + nil,-- view_enter + nil -- view_leave + ) + mE.module_installed = true + end +end -- https://www.darktable.org/lua-api/types_lua_check_button.html local check_button = dt.new_widget("check_button"){label = _("MyCheck_button"), value = true} @@ -90,35 +128,35 @@ local slider = dt.new_widget("slider") value = 52 -- The current value of the slider } --- https://www.darktable.org/lua-api/index.html#darktable_register_lib -dt.register_lib( - "exampleModule", -- Module name - "exampleModule", -- name - true, -- expandable - false, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers - -- https://www.darktable.org/lua-api/types_lua_box.html - dt.new_widget("box") -- widget - { - orientation = "vertical", - dt.new_widget("button") - { - label = _("MyButton"), - clicked_callback = function (_) - dt.print(_("Button clicked")) +-- pack the widgets in a table for loading in the module + +table.insert(mE.widgets, check_button) +table.insert(mE.widgets, combobox) +table.insert(mE.widgets, entry) +table.insert(mE.widgets, file_chooser_button) +table.insert(mE.widgets, label) +table.insert(mE.widgets, separator) +table.insert(mE.widgets, slider) + +-- ... and tell dt about it all + + +if dt.gui.current_view().name == "lighttable" then -- make sure we are in lighttable view + install_module() -- register the lib +else + if not mE.event_registered then -- if we are not in lighttable view then register an event to signal when we might be + -- https://www.darktable.org/lua-api/index.html#darktable_register_event + dt.register_event( + "view-changed", -- we want to be informed when the view changes + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then -- if the view changes from darkroom to lighttable + install_module() -- register the lib + end end - }, - check_button, - combobox, - entry, - file_chooser_button, - label, - separator, - slider - }, - nil,-- view_enter - nil -- view_leave -) + ) + mE.event_registered = true -- keep track of whether we have an event handler installed + end +end -- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua -- kate: hl Lua; From cc4f1d7251e24e74a1a8510129e234ff832a5d9a Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 23:11:33 -0400 Subject: [PATCH 05/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- official/image_path_in_ui.lua | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/official/image_path_in_ui.lua b/official/image_path_in_ui.lua index 18e57ca..60bcce6 100644 --- a/official/image_path_in_ui.lua +++ b/official/image_path_in_ui.lua @@ -33,8 +33,22 @@ local du = require "lib/dtutils" du.check_min_api_version("2.0.0", "image_path_in_ui") +local ipiu = {} +ipiu.module_installed = false +ipiu.event_registered = false + local main_label = dt.new_widget("label"){selectable = true, ellipsize = "middle", halign = "start"} +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} + }, main_label + ) + ipiu.module_installed = true + end +end + local function reset_widget() local selection = dt.gui.selection() local result = "" @@ -54,10 +68,21 @@ end main_label.reset_callback = reset_widget -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 - ); +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not ipiu.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + ipiu.event_registered = true + end +end dt.register_event("mouse-over-image-changed",reset_widget); From d05536bed4697f2ce2b802775b5f799d0d073d82 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 23:21:54 -0400 Subject: [PATCH 06/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/AutoGrouper.lua | 65 +++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/contrib/AutoGrouper.lua b/contrib/AutoGrouper.lua index 0d92915..18ff103 100644 --- a/contrib/AutoGrouper.lua +++ b/contrib/AutoGrouper.lua @@ -45,6 +45,17 @@ local function _(msgid) return gettext.dgettext("AutoGrouper", msgid) end +local Ag = {} +Ag.module_installed = false +Ag.event_registered = false + +local GUI = { + gap = {}, + selected = {}, + collection = {} +} + + local function InRange(test, low, high) --tests if test value is within range of low and high (inclusive) if test >= low and test <= high then return true @@ -111,12 +122,26 @@ local function main(on_collection) end end +local function install_module() + if not Ag.module_installed then + dt.register_lib( + 'AutoGroup_Lib', -- Module name + _('auto group'), -- name + true, -- expandable + true, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 99}}, -- containers + dt.new_widget("box"){ + orientation = "vertical", + GUI.gap, + GUI.selected, + GUI.collection + } + ) + Ag.module_installed = true + end +end + -- GUI -- -GUI = { - gap = {}, - selected = {}, - collection = {} -} temp = dt.preferences.read(MOD, 'active_gap', 'integer') if not InRange(temp, 1, 86400) then temp = 3 end GUI.gap = dt.new_widget('slider'){ @@ -143,16 +168,20 @@ GUI.collection = dt.new_widget("button"){ tooltip =_('auto group the entire collection'), clicked_callback = function() main(true) end } -dt.register_lib( - 'AutoGroup_Lib', -- Module name - _('auto group'), -- name - true, -- expandable - true, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 99}}, -- containers - dt.new_widget("box"){ - orientation = "vertical", - GUI.gap, - GUI.selected, - GUI.collection - } -) + +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not Ag.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + Ag.event_registered = true + end +end + From 994b9c6472da4b99750b7ec155671ccdc498ebe8 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 23:28:50 -0400 Subject: [PATCH 07/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/quicktag.lua | 66 ++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/contrib/quicktag.lua b/contrib/quicktag.lua index 31a4b79..104c4fe 100644 --- a/contrib/quicktag.lua +++ b/contrib/quicktag.lua @@ -47,6 +47,12 @@ local dt = require "darktable" local du = require "lib/dtutils" local debug = require "darktable.debug" +local qt = {} +qt.module_installed = false +qt.event_registered = false +qt.widget_table = {} + + local gettext = dt.gettext @@ -177,6 +183,27 @@ local function update_quicktag_list() end end +local function install_module() + if not qt.module_installed then + dt.register_lib( + "quicktag", -- Module name + "quicktag", -- name + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 490}}, + + dt.new_widget("box"){ + orientation = "vertical", + table.unpack(qt.widget_table), + + }, + nil,-- view_enter + nil -- view_leave + ) + qt.module_installed = true + end +end + update_quicktag_list() local new_quicktag = dt.new_widget("entry"){ @@ -213,33 +240,32 @@ local new_qt_widget = dt.new_widget ("box") { -- back UI elements in a table -- thanks to wpferguson for the hint -local widget_table = {} for i=1,qnr do - widget_table[#widget_table + 1] = button[i] + qt.widget_table[#qt.widget_table + 1] = button[i] end -widget_table[#widget_table + 1] = dt.new_widget("separator"){} -widget_table[#widget_table + 1] = old_quicktag -widget_table[#widget_table + 1] = new_qt_widget +qt.widget_table[#qt.widget_table + 1] = dt.new_widget("separator"){} +qt.widget_table[#qt.widget_table + 1] = old_quicktag +qt.widget_table[#qt.widget_table + 1] = new_qt_widget --create module -dt.register_lib( - "quicktag", -- Module name - "quicktag", -- name - true, -- expandable - false, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 490}}, - - dt.new_widget("box"){ - orientation = "vertical", - table.unpack(widget_table), - - }, - nil,-- view_enter - nil -- view_leave -) +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not qt.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + qt.event_registered = true + end +end -- create shortcuts for i=1,qnr do From be5557080b1afb3486568e4d5f169402d87faa92 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 8 Aug 2020 23:38:48 -0400 Subject: [PATCH 08/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/transfer_hierarchy.lua | 40 +++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/contrib/transfer_hierarchy.lua b/contrib/transfer_hierarchy.lua index c2ba9cb..70bb598 100755 --- a/contrib/transfer_hierarchy.lua +++ b/contrib/transfer_hierarchy.lua @@ -99,6 +99,10 @@ end -- Helper functions: BEGIN +local th = {} +th.module_installed = false +th.event_registered = false + local function pathExists(path) local success, err, errno = os.rename(path, path) if not success then @@ -122,6 +126,16 @@ local function createDirectory(path) end end +local function install_module() + if not th.module_installed then + darktable.register_lib(LIB_ID, + "transfer hierarchy", true, true, { + [darktable.gui.views.lighttable] = { "DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 700 } + }, th.transfer_widget, nil, nil) + th.module_installed = true + end +end + -- Helper functions: END @@ -292,7 +306,7 @@ end -local transfer_widget = darktable.new_widget("box") { +th.transfer_widget = darktable.new_widget("box") { orientation = "vertical", darktable.new_widget("button") { label = _("calculate"), @@ -347,12 +361,18 @@ darktable.preferences.register( -- Preferences: END - - - - - -darktable.register_lib(LIB_ID, - "transfer hierarchy", true, true, { - [darktable.gui.views.lighttable] = { "DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 700 } - }, transfer_widget, nil, nil) +if darktable.gui.current_view().name == "lighttable" then + install_module() +else + if not th.event_registered then + darktable.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + th.event_registered = true + end +end From 8a710798f7f01924b9d0cd76ee4b54cce2955984 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 00:17:34 -0400 Subject: [PATCH 09/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/ext_editor.lua | 58 ++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/contrib/ext_editor.lua b/contrib/ext_editor.lua index 4035c22..6999c05 100644 --- a/contrib/ext_editor.lua +++ b/contrib/ext_editor.lua @@ -84,6 +84,12 @@ du.check_min_api_version("5.0.2", MODULE_NAME) -- darktable 3.x -- OS compatibility local PS = dt.configuration.running_os == "windows" and "\\" or "/" +-- namespace +local ee = {} +ee.module_installed = false +ee.event_registered = false +ee.widgets = {} + -- translation local gettext = dt.gettext @@ -329,6 +335,26 @@ local function export2collection(storage, image_table, extra_data) dt.print (_("finished exporting")) end +-- install the module in the UI +local function install_module() + if not ee.module_installed then + -- register new module "external editors" in lighttable ------------------------ + dt.register_lib( + MODULE_NAME, + _("external editors"), + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, + dt.new_widget("box") { + orientation = "vertical", + table.unpack(ee.widgets), + }, + nil, -- view_enter + nil -- view_leave + ) + ee.module_installed = true + end +end -- combobox, with variable number of entries ---------------------------------- local combobox = dt.new_widget("combobox") { @@ -381,22 +407,26 @@ local box1 = dt.new_widget("box") { button_update_list } +table.insert(ee.widgets, combobox) +table.insert(ee.widgets, box1) -- register new module "external editors" in lighttable ------------------------ -dt.register_lib( - MODULE_NAME, - _("external editors"), - true, -- expandable - false, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, - dt.new_widget("box") { - orientation = "vertical", - combobox, - box1 - }, - nil, -- view_enter - nil -- view_leave - ) +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not ee.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + ee.event_registered = true + end +end + -- initialize list of programs and widgets ------------------------------------ From 138b23674a2b428c2440f8674af4b20890f1be97 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 00:36:43 -0400 Subject: [PATCH 10/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/photils.lua | 53 +++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/contrib/photils.lua b/contrib/photils.lua index 1c72f4b..cc41b34 100644 --- a/contrib/photils.lua +++ b/contrib/photils.lua @@ -91,7 +91,13 @@ local PHOTILS = { per_page = 10, selected_tags = {}, in_pagination = false, - tagged_image = "" + tagged_image = "", + module_installed = false, + event_registered = false, + plugin_display_views = { + [dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}, + [dt.gui.views.darkroom] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100} + }, } local GUI = { @@ -358,6 +364,21 @@ function PHOTILS.on_reset(with_view) GUI.attach_button.sensitive = false end +local function install_module() + if not PHOTILS.module_installed then + dt.register_lib(MODULE_NAME, + "photils autotagger", + true, + true, + PHOTILS.plugin_display_views, + GUI.container, + nil, + nil + ) + PHOTILS.module_installed = true + end +end + -- add a fix number of buttons for _ = 1, PHOTILS.per_page, 1 do local btn_tag = dt.new_widget("check_button") { @@ -402,10 +423,6 @@ table.insert(GUI.container, GUI.stack) GUI.stack.active = 1 -local plugin_display_views = { - [dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}, - [dt.gui.views.darkroom] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100} -} -- uses photils: prefix because script settings are all together and not seperated by script @@ -417,12 +434,20 @@ dt.preferences.register(MODULE_NAME, true) dt.register_event("mouse-over-image-changed",PHOTILS.image_changed) -dt.register_lib(MODULE_NAME, - "photils autotagger", - true, - true, - plugin_display_views, - GUI.container, - nil, - nil -) + +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not PHOTILS.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + PHOTILS.event_registered = true + end +end + From 52acdb9036b463e528e2fb27cc44bc4507ecb141 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 00:45:27 -0400 Subject: [PATCH 11/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/copy_attach_detach_tags.lua | 65 ++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/contrib/copy_attach_detach_tags.lua b/contrib/copy_attach_detach_tags.lua index 2fb8330..9b43c47 100644 --- a/contrib/copy_attach_detach_tags.lua +++ b/contrib/copy_attach_detach_tags.lua @@ -51,6 +51,11 @@ local function _(msgid) return gettext.dgettext("copy_attach_detach_tags", msgid) end +local cadt = {} +cadt.module_installed = false +cadt.event_registered = false +cadt.widget_table = {} + local image_tags = {} @@ -156,6 +161,26 @@ local function replace_tags() dt.print(_('Tags replaced')) end +local function install_module() + if not cadt.module_installed then + dt.register_lib("tagging_addon","Tagging addon",true,true,{ + [dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",500} + }, + dt.new_widget("box") { + -- orientation = "vertical", + reset_callback = function() + taglist_label.label = "" + image_tags = {} + end, + table.unpack(cadt.widget_table), + }, + nil, + nil + ) + cadt.module_installed = true + end +end + -- create modul Tagging addons taglist_label.reset_callback = mcopy_tags @@ -190,31 +215,31 @@ local box2 = dt.new_widget("box"){ local sep = dt.new_widget("separator"){} -- pack elements into widget table for a nicer layout -local widget_table = {} -widget_table[1] = box1 -widget_table[#widget_table+1] = box2 +cadt.widget_table[1] = box1 +cadt.widget_table[#cadt.widget_table+1] = box2 -widget_table[#widget_table+1] = sep -widget_table[#widget_table+1] = taglabel -widget_table[#widget_table+1] = taglist_label +cadt.widget_table[#cadt.widget_table+1] = sep +cadt.widget_table[#cadt.widget_table+1] = taglabel +cadt.widget_table[#cadt.widget_table+1] = taglist_label -- create modul -dt.register_lib("tagging_addon","Tagging addon",true,true,{ - [dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",500} - }, - dt.new_widget("box") { - -- orientation = "vertical", - reset_callback = function() - taglist_label.label = "" - image_tags = {} - end, - table.unpack(widget_table), - }, - nil, - nil - ) +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not cadt.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + cadt.event_registered = true + end +end -- shortcut for copy From 5f5ad426bf1acbbfa3b28a7717a9d2aa83a9d007 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:01:33 -0400 Subject: [PATCH 12/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/rename-tags.lua | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/contrib/rename-tags.lua b/contrib/rename-tags.lua index a0c70be..f385a7a 100644 --- a/contrib/rename-tags.lua +++ b/contrib/rename-tags.lua @@ -35,6 +35,10 @@ local debug = require "darktable.debug" -- check API version du.check_min_api_version("3.0.0", "rename-tags") +local rt = {} +rt.module_installed = false +rt.event_registered = false + -- GUI entries local old_tag = darktable.new_widget("entry") { tooltip = "Enter old tag" } local new_tag = darktable.new_widget("entry") { tooltip = "Enter new tag" } @@ -99,6 +103,13 @@ local function rename_tags() rename_reset() end +local function install_module() + if not rt.module_installed then + darktable.register_lib ("rename_tags", "rename tag", true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rt.rename_widget, nil, nil) + rt.module_installed = true + end +end + -- GUI local old_widget = darktable.new_widget ("box") { orientation = "horizontal", @@ -112,7 +123,7 @@ local new_widget = darktable.new_widget ("box") { new_tag } -local rename_widget = darktable.new_widget ("box") { +rt.rename_widget = darktable.new_widget ("box") { orientation = "vertical", reset_callback = rename_reset, old_widget, @@ -120,6 +131,20 @@ local rename_widget = darktable.new_widget ("box") { darktable.new_widget("button") { label = "Go", clicked_callback = rename_tags } } +if darktable.gui.current_view().name == "lighttable" then + install_module() +else + if not rt.event_registered then + darktable.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + rt.event_registered = true + end +end -darktable.register_lib ("rename_tags", "rename tag", true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rename_widget, nil, nil) From 432b6b5dd767a5952c9026941c8f44c5a1e84dcd Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:21:17 -0400 Subject: [PATCH 13/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/geoToolbox.lua | 52 +++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 19e3c7c..5a30862 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -40,6 +40,12 @@ local function _(msgid) return gettext.dgettext("geoToolbox", msgid) end + +local gT = {} +gT.module_installed = false +gT.event_registered = false + + -- local labelDistance = dt.new_widget("label") labelDistance.label = _("Distance:") @@ -572,6 +578,22 @@ local function altitude_profile() end +local function install_module() + if not gT.module_installed then + dt.register_lib( + "geoToolbox", -- Module name + "geo toolbox", -- name + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers + gT.widget, + nil,-- view_enter + nil -- view_leave + ) + gT.module_installed = true + end +end + local separator = dt.new_widget("separator"){} local separator2 = dt.new_widget("separator"){} @@ -579,13 +601,7 @@ local separator3 = dt.new_widget("separator"){} local separator4 = dt.new_widget("separator"){} local separator5 = dt.new_widget("separator"){} -dt.register_lib( - "geoToolbox", -- Module name - "geo toolbox", -- name - true, -- expandable - false, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers - dt.new_widget("box") +gT.widget = dt.new_widget("box") { orientation = "vertical", dt.new_widget("button") @@ -664,10 +680,24 @@ dt.register_lib( clicked_callback = altitude_profile }, labelDistance - }, - nil,-- view_enter - nil -- view_leave -) + } + + +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not gT.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + gT.event_registered = true + end +end -- Preferences dt.preferences.register("geoToolbox", From 880ec7fc587660f18bf7579137ec4b9f6b27e796 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:26:45 -0400 Subject: [PATCH 14/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/gpx_export.lua | 74 +++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/contrib/gpx_export.lua b/contrib/gpx_export.lua index b6fed82..e36b623 100644 --- a/contrib/gpx_export.lua +++ b/contrib/gpx_export.lua @@ -36,6 +36,10 @@ local function _(msgid) return gettext.dgettext("gpx_export", msgid) end +local gpx = {} +gpx.module_installed = false +gpx.event_registered = false + local path_entry = dt.new_widget("entry") { text = dt.preferences.read("gpx_exporter", "gpxExportPath", "string"), @@ -127,31 +131,55 @@ local function create_gpx_file() end end -dt.register_lib( - "gpx_exporter", - "gpx export", - true, -- expandable - true, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers +local function install_module() + if not gpx.module_installed then + dt.register_lib( + "gpx_exporter", + "gpx export", + true, -- expandable + true, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers + gpx.widget, + nil,-- view_enter + nil -- view_leave + ) + gpx.module_installed = true + end +end + +gpx.widget = dt.new_widget("box") +{ + orientation = "vertical", + dt.new_widget("button") + { + label = _("export"), + tooltip = _("export gpx file"), + clicked_callback = create_gpx_file + }, dt.new_widget("box") { - orientation = "vertical", - dt.new_widget("button") + orientation = "horizontal", + dt.new_widget("label") { - label = _("export"), - tooltip = _("export gpx file"), - clicked_callback = create_gpx_file - }, - dt.new_widget("box") - { - orientation = "horizontal", - dt.new_widget("label") - { - label = _("file:"), - }, - path_entry + label = _("file:"), }, + path_entry }, - nil,-- view_enter - nil -- view_leave -) +} + + +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not gpx.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + gpx.event_registered = true + end +end From d10cf968f19976f4b17f37e52e8f3c6285bad71e Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:33:09 -0400 Subject: [PATCH 15/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/exportLUT.lua | 67 +++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/contrib/exportLUT.lua b/contrib/exportLUT.lua index aa76b0d..bd35fb3 100644 --- a/contrib/exportLUT.lua +++ b/contrib/exportLUT.lua @@ -41,6 +41,11 @@ end du.check_min_api_version("5.0.0", "exportLUT") +local eL = {} +eL.module_installed = false +eL.event_registered = false +eL.widgets = {} + -- Thanks Kevin Ertel for this bit local os_path_seperator = '/' if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end @@ -119,27 +124,51 @@ local function export_luts() end end +local function install_module() + if not eL.module_installed then + dt.register_lib( + _("export haldclut"), + _("export haldclut"), + true, + false, + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, + dt.new_widget("box") + { + orientation = "vertical", + table.unpack(eL.widgets), + }, + nil, + nil + ) + eL.module_installed = true + end +end + local export_button = dt.new_widget("button"){ label = _("export"), clicked_callback = export_luts } -dt.register_lib( - _("export haldclut"), - _("export haldclut"), - true, - false, - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, - dt.new_widget("box") - { - orientation = "vertical", - identity_label, - file_chooser_button, - output_label, - export_chooser_button, - warning_label, - export_button - }, - nil, - nil -) +table.insert(eL.widgets, identity_label) +table.insert(eL.widgets, file_chooser_button) +table.insert(eL.widgets, output_label) +table.insert(eL.widgets, export_chooser_button) +table.insert(eL.widgets, warning_label) +table.insert(eL.widgets, export_button) + +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not eL.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + eL.event_registered = true + end +end + From d4e21b78774075c6e0bc12e52fda88c7d35e8ed0 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:43:20 -0400 Subject: [PATCH 16/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/image_time.lua | 44 ++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/contrib/image_time.lua b/contrib/image_time.lua index a13a79a..676f5af 100644 --- a/contrib/image_time.lua +++ b/contrib/image_time.lua @@ -110,6 +110,8 @@ local ds = require "lib/dtutils.string" local gettext = dt.gettext local img_time = {} +img_time.module_installed = false +img_time.event_registered = false du.check_min_api_version("3.0.0", "image_time") @@ -390,6 +392,22 @@ local function reset_widgets() img_time.adir.selected = 1 end +local function install_module() + if not img_time.module_installed then + dt.register_lib( + "image_time", -- Module name + _("image time"), -- Visible name + true, -- expandable + true, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers + img_time.widget, + nil,-- view_enter + nil -- view_leave + ) + img_time.module_installed = true + end +end + -- widgets img_time.widgets = { @@ -528,13 +546,19 @@ img_time.widget = dt.new_widget("box"){ img_time.stack, } -dt.register_lib( - "image_time", -- Module name - _("image time"), -- Visible name - true, -- expandable - true, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers - img_time.widget, - nil,-- view_enter - nil -- view_leave -) +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not img_time.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + img_time.event_registered = true + end +end + From b8e3ec43023af8d38d68d13b971a09580be310f2 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:43:31 -0400 Subject: [PATCH 17/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/HDRMerge.lua | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/contrib/HDRMerge.lua b/contrib/HDRMerge.lua index ad7dd3a..aa13a1c 100644 --- a/contrib/HDRMerge.lua +++ b/contrib/HDRMerge.lua @@ -94,6 +94,10 @@ local GUI = { --GUI Elements Table } } +HDRM.module_installed = false +HDRM.event_registered = false + + --Detect User Styles-- local styles = dt.styles local styles_count = 1 -- 'none' = 1 @@ -264,6 +268,23 @@ local function main() end +local function install_module() + if not HDRM.module_installed then + dt.register_lib( -- register HDRMerge module + 'HDRMerge_Lib', -- Module name + _('HDRMerge'), -- name + true, -- expandable + true, -- resetable + {[dt.gui.views.lighttable] = {'DT_UI_CONTAINER_PANEL_RIGHT_CENTER', 99}}, -- containers + dt.new_widget('box'){ + orientation = 'vertical', + GUI.stack + } + ) + HDRM.module_installed = true + end +end + -- GUI Elements -- local lbl_hdr = dt.new_widget('section_label'){ label = _('HDRMerge options') @@ -411,14 +432,18 @@ else GUI.stack.active = 2 end -dt.register_lib( -- register HDRMerge module - 'HDRMerge_Lib', -- Module name - _('HDRMerge'), -- name - true, -- expandable - true, -- resetable - {[dt.gui.views.lighttable] = {'DT_UI_CONTAINER_PANEL_RIGHT_CENTER', 99}}, -- containers - dt.new_widget('box'){ - orientation = 'vertical', - GUI.stack - } -) +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not HDRM.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + HDRM.event_registered = true + end +end From dfb8d4e7c6b7f2219f2a8c1068d167e86c0dbb2e Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:48:36 -0400 Subject: [PATCH 18/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/LabelsToTags.lua | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/contrib/LabelsToTags.lua b/contrib/LabelsToTags.lua index 044e920..29f9322 100644 --- a/contrib/LabelsToTags.lua +++ b/contrib/LabelsToTags.lua @@ -55,6 +55,10 @@ du.check_min_api_version("3.0.0", "LabelsToTags") -- Lua 5.3 no longer has "unpack" but "table.unpack" unpack = unpack or table.unpack +local ltt = {} +ltt.module_installed = false +ltt.event_registered = false + local LIB_ID = "LabelsToTags" -- Helper functions: BEGIN @@ -184,7 +188,7 @@ local function doTagging(selfC) job.valid = false end -local my_widget = darktable.new_widget("box") { +ltt.my_widget = darktable.new_widget("box") { orientation = "vertical", mappingComboBox, darktable.new_widget("button") { @@ -217,6 +221,15 @@ darktable.register_tag_mapping = function(name, mapping) mappingComboBox.reset_callback(mappingComboBox) end +local function install_module() + if not ltt.module_installed then + darktable.register_lib(LIB_ID,"labels to tags",true,true,{ + [darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",20}, + },ltt.my_widget,nil,nil) + ltt.module_installed = true + end +end + --[[ darktable.register_tag_mapping("Example", { ["+----*"] = { "Red", "Only red" }, @@ -229,6 +242,19 @@ darktable.register_tag_mapping("Example", ["*****R"] = { "Rejected" } }) ]] -darktable.register_lib(LIB_ID,"labels to tags",true,true,{ - [darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",20}, - },my_widget,nil,nil) +if darktable.gui.current_view().name == "lighttable" then + install_module() +else + if not ltt.event_registered then + darktable.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + ltt.event_registered = true + end +end + From b613cc266a232baf469ceea1660a61d72867e20f Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:56:38 -0400 Subject: [PATCH 19/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- contrib/face_recognition.lua | 43 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/contrib/face_recognition.lua b/contrib/face_recognition.lua index 26caff6..96bc4a2 100644 --- a/contrib/face_recognition.lua +++ b/contrib/face_recognition.lua @@ -55,6 +55,8 @@ local OUTPUT = dt.configuration.tmp_dir .. PS .. "facerecognition.txt" -- namespace local fc = {} +fc.module_installed = false +fc.event_registered = false -- ensure we meet the minimum api du.check_min_api_version("5.0.0", "face_recognition") @@ -337,6 +339,22 @@ local function face_recognition () end end +local function install_module() + if not fc.module_installed then + dt.register_lib( + "face_recognition", -- Module name + _("face recognition"), -- Visible name + true, -- expandable + true, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 300}}, -- containers + fc.widget, + nil,-- view_enter + nil -- view_leave + ) + fc.module_installed = true + end +end + -- build the interface fc.unknown_tag = dt.new_widget("entry"){ @@ -466,16 +484,21 @@ fc.widget = dt.new_widget("box"){ table.unpack(widgets), } -dt.register_lib( - "face_recognition", -- Module name - _("face recognition"), -- Visible name - true, -- expandable - true, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 300}}, -- containers - fc.widget, - nil,-- view_enter - nil -- view_leave -) +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not fc.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + fc.event_registered = true + end +end fc.tolerance.value = dt.preferences.read(MODULE, "tolerance", "float") From 912ae93d1036b78578c2568e98bf691720193818 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sun, 9 Aug 2020 01:56:48 -0400 Subject: [PATCH 20/20] Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. --- tools/executable_manager.lua | 57 ++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/tools/executable_manager.lua b/tools/executable_manager.lua index f45ecb6..2bbe392 100644 --- a/tools/executable_manager.lua +++ b/tools/executable_manager.lua @@ -40,6 +40,10 @@ local gettext = dt.gettext gettext.bindtextdomain("executable_manager",dt.configuration.config_dir.."/lua/locale/") +local exec_man = {} -- our own namespace +exec_man.module_installed = false +exec_man.event_registered = false + -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -- F U N C T I O N S -- - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -86,12 +90,30 @@ local function update_combobox_choices(combobox, choice_table, selected) combobox.value = selected end +local function install_module() + if not exec_man.module_installed then + dt.register_lib( + "executable_manager", -- Module name + "executable manager", -- Visible name + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_BOTTOM", 100}}, -- containers + dt.new_widget("box") -- widget + { + orientation = "vertical", + exec_man.selector, + exec_man.stack, + }, + nil,-- view_enter + nil -- view_leave + ) + exec_man.module_installed = true + end +end -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -- M A I N P R O G R A M -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -local exec_man = {} -- our own namespace - local DARKTABLERC = dt.configuration.config_dir .. PS .. "darktablerc" @@ -187,19 +209,18 @@ update_combobox_choices(exec_man.selector, exec_table, 1) -- register the lib -dt.register_lib( - "executable_manager", -- Module name - "executable manager", -- Visible name - true, -- expandable - false, -- resetable - {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_BOTTOM", 100}}, -- containers - dt.new_widget("box") -- widget - { - orientation = "vertical", - exec_man.selector, - exec_man.stack, - }, - nil,-- view_enter - nil -- view_leave -) - +if dt.gui.current_view().name == "lighttable" then + install_module() +else + if not exec_man.event_registered then + dt.register_event( + "view-changed", + function(event, old_view, new_view) + if new_view.name == "lighttable" and old_view.name == "darkroom" then + install_module() + end + end + ) + exec_man.event_registered = true + end +end