20
20
21
21
This script provides helpers to edit image files with programs external to darktable. It adds:
22
22
- 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)
25
25
- a set of lua preferences in order to configure name and path of up to 9 external editors
26
26
- a set of lua shortcuts in order to quick launch the external editors
27
27
32
32
* in "preferences/lua options" configure name and path/command of external programs
33
33
* note that if a program name is left empty, that and all following entries will be ignored
34
34
* 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"
36
36
37
37
-- use --
38
38
* in the export dialog choose "collection" and select the format and bit depth for the
39
39
exported image
40
40
* press "export"
41
41
* the exported image will be imported into collection and grouped with the original image
42
42
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"
45
46
* edit the image with the external editor, overwite the file, quit the external program
46
47
* the selected image will be updated
47
48
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"
49
50
* edit the image with the external editor, overwite the file, quit the external program
50
51
* a copy of the selected image will be created and updated
51
52
or
52
- * in lighttable select target storage "collection"
53
- * enter in darkroom
54
- * to create an export or a copy press CRTL+E
55
53
* use the shortcut to edit the current image with the corresponding external editor
56
54
* overwite the file, quit the external program
57
- * the darkroom view will be updated
55
+ * the image will be updated
58
56
59
57
* warning: mouseover on lighttable/filmstrip will prevail on current image
60
58
* this is the default DT behavior, not a bug of this script
@@ -280,13 +278,9 @@ local function OpenWith(images, choice, copy)
280
278
new_image = dt .database .import (name )
281
279
new_image :group_with (image_leader )
282
280
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
287
281
end
288
282
289
- -- restore image tags, rating and color, must be put after refresh darkroom view
283
+ -- restore image tags, rating and color
290
284
for i , tag in ipairs (tags ) do dt .tags .attach (tag , new_image ) end
291
285
new_image .rating = rating
292
286
new_image .red = red
@@ -298,8 +292,12 @@ local function OpenWith(images, choice, copy)
298
292
-- select the new image
299
293
local selection = {}
300
294
table.insert (selection , new_image )
301
- dt .gui .selection (selection )
295
+ dt .gui .selection (selection )
302
296
297
+ -- refresh darkroom view
298
+ if dt .gui .current_view ().id == " darkroom" then
299
+ dt .gui .views .darkroom .display_image (new_image )
300
+ end
303
301
end
304
302
305
303
@@ -334,19 +332,27 @@ local function export2collection(storage, image_table, extra_data)
334
332
new_image :group_with (image .group_leader )
335
333
end
336
334
337
- dt .print (_ (" finished exporting" ))
335
+ dt .print (_ (" finished exporting" ))
338
336
end
339
337
340
- -- install the module in the UI
341
- local function install_module ()
338
+
339
+ -- install the module in the UI -----------------------------------------------
340
+ local function install_module (dr )
341
+
342
+ local views = {[dt .gui .views .lighttable ] = {" DT_UI_CONTAINER_PANEL_RIGHT_CENTER" , 100 }}
343
+ if dr then
344
+ views = {[dt .gui .views .lighttable ] = {" DT_UI_CONTAINER_PANEL_RIGHT_CENTER" , 100 },
345
+ [dt .gui .views .darkroom ] = {" DT_UI_CONTAINER_PANEL_LEFT_CENTER" , 100 }}
346
+ end
347
+
342
348
if not ee .module_installed then
343
- -- register new module "external editors" in lighttable -------------------- ----
349
+ -- register new module "external editors" in lighttable and darkroom ----
344
350
dt .register_lib (
345
351
MODULE_NAME ,
346
352
_ (" external editors" ),
347
353
true , -- expandable
348
354
false , -- resetable
349
- {[ dt . gui . views . lighttable ] = { " DT_UI_CONTAINER_PANEL_RIGHT_CENTER " , 100 }},
355
+ views ,
350
356
dt .new_widget (" box" ) {
351
357
orientation = " vertical" ,
352
358
table.unpack (ee .widgets ),
@@ -358,6 +364,7 @@ local function install_module()
358
364
end
359
365
end
360
366
367
+
361
368
-- combobox, with variable number of entries ----------------------------------
362
369
local combobox = dt .new_widget (" combobox" ) {
363
370
label = _ (" choose program" ),
@@ -409,19 +416,23 @@ local box1 = dt.new_widget("box") {
409
416
button_update_list
410
417
}
411
418
419
+
420
+ -- table with all the widgets --------------------------------------------------
412
421
table.insert (ee .widgets , combobox )
413
422
table.insert (ee .widgets , box1 )
414
423
415
- -- register new module "external editors" in lighttable ------------------------
424
+
425
+ -- register new module, but only when in lighttable ----------------------------
426
+ local show_dr = dt .preferences .read (MODULE_NAME , " show_in_darkrooom" , " bool" )
416
427
if dt .gui .current_view ().id == " lighttable" then
417
- install_module ()
428
+ install_module (show_dr )
418
429
else
419
430
if not ee .event_registered then
420
431
dt .register_event (
421
432
MODULE_NAME , " view-changed" ,
422
433
function (event , old_view , new_view )
423
434
if new_view .name == " lighttable" and old_view .name == " darkroom" then
424
- install_module ()
435
+ install_module (show_dr )
425
436
end
426
437
end
427
438
)
430
441
end
431
442
432
443
433
-
434
444
-- initialize list of programs and widgets ------------------------------------
435
445
UpdateProgramList (combobox , button_edit , button_edit_copy , false )
436
446
@@ -449,6 +459,9 @@ for i = MAX_EDITORS, 1, -1 do
449
459
_ (" name of external editor " ).. i ,
450
460
_ (" friendly name of external editor" ), " " )
451
461
end
462
+ dt .preferences .register (MODULE_NAME , " show_in_darkrooom" , " bool" ,
463
+ _ (" show external editors in darkroom" ),
464
+ _ (" check to show external editors module also in darkroom (requires restart)" ), false )
452
465
453
466
454
467
-- register the new shortcuts -------------------------------------------------
0 commit comments