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.

This commit is contained in:
Bill Ferguson
2020-08-09 00:36:43 -04:00
parent 8a710798f7
commit 138b23674a

View File

@@ -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