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
@@ -101,7 +99,7 @@ local function _(msgid)
101
99
end
102
100
103
101
-- maximum number of external programs, can be increased to necessity
104
- local MAX_EDITORS = 9
102
+ local MAX_EDITORS = 12
105
103
106
104
-- number of valid entries in the list of external programs
107
105
local n_entries
@@ -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,21 @@ 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
338
+
339
+ -- install the module in the UI -----------------------------------------------
341
340
local function install_module ()
342
341
if not ee .module_installed then
343
- -- register new module "external editors" in lighttable ------------------ ------
342
+ -- register new module "external editors" in lighttable and darkroom ------
344
343
dt .register_lib (
345
344
MODULE_NAME ,
346
345
_ (" external editors" ),
347
346
true , -- expandable
348
347
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 }},
350
350
dt .new_widget (" box" ) {
351
351
orientation = " vertical" ,
352
352
table.unpack (ee .widgets ),
@@ -358,6 +358,7 @@ local function install_module()
358
358
end
359
359
end
360
360
361
+
361
362
-- combobox, with variable number of entries ----------------------------------
362
363
local combobox = dt .new_widget (" combobox" ) {
363
364
label = _ (" choose program" ),
@@ -409,30 +410,11 @@ local box1 = dt.new_widget("box") {
409
410
button_update_list
410
411
}
411
412
413
+
414
+ -- install module in lighttable and darkroom ----------------------------------
412
415
table.insert (ee .widgets , combobox )
413
416
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 ()
436
418
437
419
438
420
-- register new storage -------------------------------------------------------
0 commit comments