Skip to content

Commit cc4f1d7

Browse files
committed
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.
1 parent 2ddd096 commit cc4f1d7

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

official/image_path_in_ui.lua

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,22 @@ local du = require "lib/dtutils"
3333

3434
du.check_min_api_version("2.0.0", "image_path_in_ui")
3535

36+
local ipiu = {}
37+
ipiu.module_installed = false
38+
ipiu.event_registered = false
39+
3640
local main_label = dt.new_widget("label"){selectable = true, ellipsize = "middle", halign = "start"}
3741

42+
local function install_module()
43+
if not ipiu.module_installed then
44+
dt.register_lib("image_path_no_ui","Selected Images path",true,false,{
45+
[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER",300}
46+
}, main_label
47+
)
48+
ipiu.module_installed = true
49+
end
50+
end
51+
3852
local function reset_widget()
3953
local selection = dt.gui.selection()
4054
local result = ""
@@ -54,10 +68,21 @@ end
5468

5569
main_label.reset_callback = reset_widget
5670

57-
dt.register_lib("image_path_no_ui","Selected Images path",true,false,{
58-
[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER",300}
59-
}, main_label
60-
);
71+
if dt.gui.current_view().name == "lighttable" then
72+
install_module()
73+
else
74+
if not ipiu.event_registered then
75+
dt.register_event(
76+
"view-changed",
77+
function(event, old_view, new_view)
78+
if new_view.name == "lighttable" and old_view.name == "darkroom" then
79+
install_module()
80+
end
81+
end
82+
)
83+
ipiu.event_registered = true
84+
end
85+
end
6186

6287
dt.register_event("mouse-over-image-changed",reset_widget);
6388

0 commit comments

Comments
 (0)