Skip to content

Commit 73cd301

Browse files
committed
ext_editor visible in darkroom
1 parent 448da35 commit 73cd301

File tree

1 file changed

+25
-43
lines changed

1 file changed

+25
-43
lines changed

contrib/ext_editor.lua

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
2121
This script provides helpers to edit image files with programs external to darktable. It adds:
2222
- a new target storage "collection". Image exported will be reimported to collection for further edit with external programs
23-
- a new lighttable module "external editors", to select a program from a list of up to
24-
- 9 external editors and run it on a selected image (adjust this limit by changing MAX_EDITORS)
23+
- a new module "external editors", visible in lightable and darkroom, to select a program from a list
24+
- of up to 9 external editors and run it on a selected image (adjust this limit by changing MAX_EDITORS)
2525
- a set of lua preferences in order to configure name and path of up to 9 external editors
2626
- a set of lua shortcuts in order to quick launch the external editors
2727
@@ -32,29 +32,27 @@
3232
* in "preferences/lua options" configure name and path/command of external programs
3333
* note that if a program name is left empty, that and all following entries will be ignored
3434
* in "preferences/shortcuts/lua" configure shortcuts for external programs (optional)
35-
* whenever programs preferences are changed, in lighttable/external editors, press "update list"
35+
* whenever programs preferences are changed, in external editors GUI, press "update list"
3636
3737
-- use --
3838
* in the export dialog choose "collection" and select the format and bit depth for the
3939
exported image
4040
* press "export"
4141
* the exported image will be imported into collection and grouped with the original image
4242
43-
* select an image for editing with en external program, and:
44-
* in lighttable/external editors, select program and press "edit"
43+
* in lighttable, select an image for editing with en external program
44+
* (or in darkroom for the image being edited):
45+
* in external editors GUI, select program and press "edit"
4546
* edit the image with the external editor, overwite the file, quit the external program
4647
* the selected image will be updated
4748
or
48-
* in lighttable/external editors, select program and press "edit a copy"
49+
* in external editors GUI, select program and press "edit a copy"
4950
* edit the image with the external editor, overwite the file, quit the external program
5051
* a copy of the selected image will be created and updated
5152
or
52-
* in lighttable select target storage "collection"
53-
* enter in darkroom
54-
* to create an export or a copy press CRTL+E
5553
* use the shortcut to edit the current image with the corresponding external editor
5654
* overwite the file, quit the external program
57-
* the darkroom view will be updated
55+
* the image will be updated
5856
5957
* warning: mouseover on lighttable/filmstrip will prevail on current image
6058
* this is the default DT behavior, not a bug of this script
@@ -101,7 +99,7 @@ local function _(msgid)
10199
end
102100

103101
-- maximum number of external programs, can be increased to necessity
104-
local MAX_EDITORS = 9
102+
local MAX_EDITORS = 12
105103

106104
-- number of valid entries in the list of external programs
107105
local n_entries
@@ -280,13 +278,9 @@ local function OpenWith(images, choice, copy)
280278
new_image = dt.database.import(name)
281279
new_image:group_with(image_leader)
282280
end
283-
-- refresh darkroom view
284-
if dt.gui.current_view() == dt.gui.views.darkroom then
285-
dt.gui.views.darkroom.display_image(new_image)
286-
end
287281
end
288282

289-
-- restore image tags, rating and color, must be put after refresh darkroom view
283+
-- restore image tags, rating and color
290284
for i, tag in ipairs(tags) do dt.tags.attach(tag, new_image) end
291285
new_image.rating = rating
292286
new_image.red = red
@@ -298,8 +292,12 @@ local function OpenWith(images, choice, copy)
298292
-- select the new image
299293
local selection = {}
300294
table.insert(selection, new_image)
301-
dt.gui.selection (selection)
295+
dt.gui.selection(selection)
302296

297+
-- refresh darkroom view
298+
if dt.gui.current_view().id == "darkroom" then
299+
dt.gui.views.darkroom.display_image(new_image)
300+
end
303301
end
304302

305303

@@ -334,19 +332,21 @@ local function export2collection(storage, image_table, extra_data)
334332
new_image:group_with(image.group_leader)
335333
end
336334

337-
dt.print (_("finished exporting"))
335+
dt.print(_("finished exporting"))
338336
end
339337

340-
-- install the module in the UI
338+
339+
-- install the module in the UI -----------------------------------------------
341340
local function install_module()
342341
if not ee.module_installed then
343-
-- register new module "external editors" in lighttable ------------------------
342+
-- register new module "external editors" in lighttable and darkroom ------
344343
dt.register_lib(
345344
MODULE_NAME,
346345
_("external editors"),
347346
true, -- expandable
348347
false, -- resetable
349-
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}},
348+
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100},
349+
[dt.gui.views.darkroom] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100}},
350350
dt.new_widget("box") {
351351
orientation = "vertical",
352352
table.unpack(ee.widgets),
@@ -358,6 +358,7 @@ local function install_module()
358358
end
359359
end
360360

361+
361362
-- combobox, with variable number of entries ----------------------------------
362363
local combobox = dt.new_widget("combobox") {
363364
label = _("choose program"),
@@ -409,30 +410,11 @@ local box1 = dt.new_widget("box") {
409410
button_update_list
410411
}
411412

413+
414+
-- install module in lighttable and darkroom ----------------------------------
412415
table.insert(ee.widgets, combobox)
413416
table.insert(ee.widgets, box1)
414-
415-
-- register new module "external editors" in lighttable ------------------------
416-
if dt.gui.current_view().id == "lighttable" then
417-
install_module()
418-
else
419-
if not ee.event_registered then
420-
dt.register_event(
421-
MODULE_NAME, "view-changed",
422-
function(event, old_view, new_view)
423-
if new_view.name == "lighttable" and old_view.name == "darkroom" then
424-
install_module()
425-
end
426-
end
427-
)
428-
ee.event_registered = true
429-
end
430-
end
431-
432-
433-
434-
-- initialize list of programs and widgets ------------------------------------
435-
UpdateProgramList(combobox, button_edit, button_edit_copy, false)
417+
install_module()
436418

437419

438420
-- register new storage -------------------------------------------------------

0 commit comments

Comments
 (0)