Merge pull request #327 from Mark-64/ext_editor_darkroom
External editors: make gui visible in darkroom
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
|
||||
This script provides helpers to edit image files with programs external to darktable. It adds:
|
||||
- a new target storage "collection". Image exported will be reimported to collection for further edit with external programs
|
||||
- a new lighttable module "external editors", to select a program from a list of up to
|
||||
- 9 external editors and run it on a selected image (adjust this limit by changing MAX_EDITORS)
|
||||
- a new module "external editors", visible in lightable and darkroom, to select a program from a list
|
||||
- of up to 9 external editors and run it on a selected image (adjust this limit by changing MAX_EDITORS)
|
||||
- a set of lua preferences in order to configure name and path of up to 9 external editors
|
||||
- a set of lua shortcuts in order to quick launch the external editors
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
* in "preferences/lua options" configure name and path/command of external programs
|
||||
* note that if a program name is left empty, that and all following entries will be ignored
|
||||
* in "preferences/shortcuts/lua" configure shortcuts for external programs (optional)
|
||||
* whenever programs preferences are changed, in lighttable/external editors, press "update list"
|
||||
* whenever programs preferences are changed, in external editors GUI, press "update list"
|
||||
|
||||
-- use --
|
||||
* in the export dialog choose "collection" and select the format and bit depth for the
|
||||
@@ -40,21 +40,19 @@
|
||||
* press "export"
|
||||
* the exported image will be imported into collection and grouped with the original image
|
||||
|
||||
* select an image for editing with en external program, and:
|
||||
* in lighttable/external editors, select program and press "edit"
|
||||
* in lighttable, select an image for editing with en external program
|
||||
* (or in darkroom for the image being edited):
|
||||
* in external editors GUI, select program and press "edit"
|
||||
* edit the image with the external editor, overwite the file, quit the external program
|
||||
* the selected image will be updated
|
||||
or
|
||||
* in lighttable/external editors, select program and press "edit a copy"
|
||||
* in external editors GUI, select program and press "edit a copy"
|
||||
* edit the image with the external editor, overwite the file, quit the external program
|
||||
* a copy of the selected image will be created and updated
|
||||
or
|
||||
* in lighttable select target storage "collection"
|
||||
* enter in darkroom
|
||||
* to create an export or a copy press CRTL+E
|
||||
* use the shortcut to edit the current image with the corresponding external editor
|
||||
* overwite the file, quit the external program
|
||||
* the darkroom view will be updated
|
||||
* the image will be updated
|
||||
|
||||
* warning: mouseover on lighttable/filmstrip will prevail on current image
|
||||
* this is the default DT behavior, not a bug of this script
|
||||
@@ -280,13 +278,9 @@ local function OpenWith(images, choice, copy)
|
||||
new_image = dt.database.import(name)
|
||||
new_image:group_with(image_leader)
|
||||
end
|
||||
-- refresh darkroom view
|
||||
if dt.gui.current_view() == dt.gui.views.darkroom then
|
||||
dt.gui.views.darkroom.display_image(new_image)
|
||||
end
|
||||
end
|
||||
|
||||
-- restore image tags, rating and color, must be put after refresh darkroom view
|
||||
-- restore image tags, rating and color
|
||||
for i, tag in ipairs(tags) do dt.tags.attach(tag, new_image) end
|
||||
new_image.rating = rating
|
||||
new_image.red = red
|
||||
@@ -298,8 +292,12 @@ local function OpenWith(images, choice, copy)
|
||||
-- select the new image
|
||||
local selection = {}
|
||||
table.insert(selection, new_image)
|
||||
dt.gui.selection (selection)
|
||||
dt.gui.selection(selection)
|
||||
|
||||
-- refresh darkroom view
|
||||
if dt.gui.current_view().id == "darkroom" then
|
||||
dt.gui.views.darkroom.display_image(new_image)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -334,19 +332,27 @@ local function export2collection(storage, image_table, extra_data)
|
||||
new_image:group_with(image.group_leader)
|
||||
end
|
||||
|
||||
dt.print (_("finished exporting"))
|
||||
dt.print(_("finished exporting"))
|
||||
end
|
||||
|
||||
-- install the module in the UI
|
||||
local function install_module()
|
||||
|
||||
-- install the module in the UI -----------------------------------------------
|
||||
local function install_module(dr)
|
||||
|
||||
local views = {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}
|
||||
if dr then
|
||||
views = {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100},
|
||||
[dt.gui.views.darkroom] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100}}
|
||||
end
|
||||
|
||||
if not ee.module_installed then
|
||||
-- register new module "external editors" in lighttable ------------------------
|
||||
-- register new module "external editors" in lighttable and darkroom ----
|
||||
dt.register_lib(
|
||||
MODULE_NAME,
|
||||
_("external editors"),
|
||||
true, -- expandable
|
||||
false, -- resetable
|
||||
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}},
|
||||
views,
|
||||
dt.new_widget("box") {
|
||||
orientation = "vertical",
|
||||
table.unpack(ee.widgets),
|
||||
@@ -358,6 +364,7 @@ local function install_module()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- combobox, with variable number of entries ----------------------------------
|
||||
local combobox = dt.new_widget("combobox") {
|
||||
label = _("choose program"),
|
||||
@@ -409,19 +416,23 @@ local box1 = dt.new_widget("box") {
|
||||
button_update_list
|
||||
}
|
||||
|
||||
|
||||
-- table with all the widgets --------------------------------------------------
|
||||
table.insert(ee.widgets, combobox)
|
||||
table.insert(ee.widgets, box1)
|
||||
|
||||
-- register new module "external editors" in lighttable ------------------------
|
||||
|
||||
-- register new module, but only when in lighttable ----------------------------
|
||||
local show_dr = dt.preferences.read(MODULE_NAME, "show_in_darkrooom", "bool")
|
||||
if dt.gui.current_view().id == "lighttable" then
|
||||
install_module()
|
||||
install_module(show_dr)
|
||||
else
|
||||
if not ee.event_registered then
|
||||
dt.register_event(
|
||||
MODULE_NAME, "view-changed",
|
||||
function(event, old_view, new_view)
|
||||
if new_view.name == "lighttable" and old_view.name == "darkroom" then
|
||||
install_module()
|
||||
install_module(show_dr)
|
||||
end
|
||||
end
|
||||
)
|
||||
@@ -430,7 +441,6 @@ else
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- initialize list of programs and widgets ------------------------------------
|
||||
UpdateProgramList(combobox, button_edit, button_edit_copy, false)
|
||||
|
||||
@@ -449,6 +459,9 @@ for i = MAX_EDITORS, 1, -1 do
|
||||
_("name of external editor ")..i,
|
||||
_("friendly name of external editor"), "")
|
||||
end
|
||||
dt.preferences.register(MODULE_NAME, "show_in_darkrooom", "bool",
|
||||
_("show external editors in darkroom"),
|
||||
_("check to show external editors module also in darkroom (requires restart)"), false)
|
||||
|
||||
|
||||
-- register the new shortcuts -------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user