Skip to content

Commit 13f210b

Browse files
committed
official/apply_camera_style - made name tranlatable and made it into
name string instead of the filename tools/script_manager - change get_script_metadata to retreive a script metadata block and store it as a metadata block making the indiviual fields accessible. change the script buttons to use the translated name if available and just the purpose for the tooltip.
1 parent 8e4767c commit 13f210b

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

official/apply_camera_style.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ script_data.restart = nil -- how to restart the (lib) script after it'
8989
script_data.show = nil -- only required for libs since the destroy_method only hides them
9090

9191
script_data.metadata = {
92-
name = "apply_camera_style", -- name of script
92+
name = _("apply camera style"), -- name of script
9393
purpose = _("apply darktable camera style to matching images"), -- purpose of script
9494
author = "Bill Ferguson <wpferguson@gmail.com>", -- your name and optionally e-mail address
9595
help = "https://docs.darktable.org/lua/development/lua.scripts.manual/scripts/official/apply_camera_style/" -- URL to help/documentation

tools/script_manager.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,29 +405,28 @@ local function get_script_metadata(script)
405405

406406
log.msg(log.debug, "processing metatdata for " .. script)
407407

408-
local description = nil
409-
local metadata = nil
408+
local metadata_block = nil
409+
local metadata = {}
410410

411411
f = io.open(LUA_DIR .. PS .. script .. ".lua")
412412
if f then
413413
-- slurp the file
414414
local content = f:read("*all")
415415
f:close()
416416
-- grab the script_data.metadata table
417-
description = string.match(content, "script_data%.metadata = %{\r?\n(.-)\r?\n%}")
417+
metadata_block = string.match(content, "script_data%.metadata = %{\r?\n(.-)\r?\n%}")
418418
else
419419
log.msg(log.error, "cant read from " .. script)
420420
end
421421

422-
if description then
423-
metadata = ""
424-
-- format it into a string block for display
425-
local lines = du.split(description, "\n")
422+
if metadata_block then
423+
-- break up the lines into key value pairs
424+
local lines = du.split(metadata_block, "\n")
426425
log.msg(log.debug, "got " .. #lines .. " lines")
427-
local first = 1
428426
for i = 1, #lines do
429427
log.msg(log.debug, "splitting line " .. lines[i])
430428
local parts = du.split(lines[i], " = ")
429+
parts[1] = string_trim(parts[1])
431430
log.msg(log.debug, "got value " .. parts[1] .. " and data " .. parts[2])
432431
if string.match(parts[2], "%_%(") then
433432
parts[2] = _(string_dequote(string_dei18n(parts[2])))
@@ -437,14 +436,15 @@ local function get_script_metadata(script)
437436
if string.match(parts[2], ",$") then
438437
parts[2] = string_chop(parts[2])
439438
end
440-
metadata = metadata .. string.format("%s%-10s\t%s", first and "" or "\n", parts[1], parts[2])
441-
first = nil
439+
log.msg(log.debug, "parts 1 is " .. parts[1] .. " and parts 2 is " .. parts[2])
440+
metadata[parts[1]] = parts[2]
441+
log.msg(log.debug, "metadata " .. parts[1] .. " is " .. metadata[parts[1]])
442442
end
443-
log.msg(log.debug, "script data is \n" .. metadata)
443+
log.msg(log.debug, "script data found for " .. metadata["name"])
444444
end
445445

446446
restore_log_level(old_log_level)
447-
return metadata
447+
return metadata_block and metadata or nil
448448
end
449449

450450
local function get_script_doc(script)
@@ -910,11 +910,11 @@ local function populate_buttons(folder, first, last)
910910
end
911911

912912
button.image = POWER_ICON
913-
label.label = script.name
913+
label.label = script.metadata and script.metadata.name or script.name
914914
label.name = "pb_label"
915915
button.ellipsize = "end"
916916
button.sensitive = true
917-
label.tooltip = script.metadata and script.metadata or script.doc
917+
label.tooltip = script.metadata and script.metadata.purpose or script.doc
918918

919919
button.clicked_callback = function (this)
920920
local cb_script = script

0 commit comments

Comments
 (0)