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-08 22:01:58 -04:00
parent 6aa5893b5f
commit d1e330eee0

View File

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