97 Commits

Author SHA1 Message Date
Bill Ferguson
8318569cdf contrib/rate_group - fix tooltip formation error 2024-09-03 19:06:07 -04:00
wpferguson
3d1f12fe44 Merge pull request #500 from darktable-org/fix_create_tmp_file_windows
lib/dtutils/file - os.tmpname now works correctly on windows, removed
2024-08-13 17:50:23 -04:00
Bill Ferguson
a079860cd8 lib/dtutils/file - os.tmpname now works correctly on windows, removed
check and fix
2024-08-13 17:46:28 -04:00
wpferguson
b07c680332 Merge pull request #499 from wpferguson/update_3rd_party
README.md - updated 3rd party scripts
2024-08-10 23:48:24 -04:00
Bill Ferguson
200fc059c0 README.md - updated 3rd party scripts 2024-08-10 23:38:06 -04:00
wpferguson
aeb1f2226c Merge pull request #498 from darktable-org/fix_translatable_strings
fixed translatable strings for inclusion into darktable
2024-08-08 19:47:26 -04:00
Bill Ferguson
46e729b40e fixed translatable strings for inclusion into darktable 2024-08-08 19:43:33 -04:00
wpferguson
66b613dc29 Merge pull request #497 from wpferguson/remove_quote_windows_command
lib/dtutils/system - remove _quote_windows_command
2024-07-21 22:47:05 -04:00
Bill Ferguson
535ba78a06 lib/dtutils/system - remove _quote_windows_command 2024-07-21 22:43:59 -04:00
Bill Ferguson
cc11c1c3b8 tools/script_manager - set log level to warn instead of debug 2024-07-18 12:42:12 -04:00
wpferguson
fba639e98a Merge pull request #496 from wpferguson/desanitize_libs
Desanitize libs
2024-07-13 14:50:47 -04:00
Bill Ferguson
3e37c06b84 lib/dtutils/string - Added check to determine if string needs to be
sanitized.  Check looks for unprintable characters
                     and spaces.
2024-07-13 14:44:01 -04:00
Bill Ferguson
1b272be5f5 various scripts - reverted the calls to io_popen and os_execute back
to the respective lua calls.
2024-07-13 12:48:37 -04:00
Bill Ferguson
9f423eeef3 lib/dtutils/file - reverted io_popen and os_execute wrappers as
lib/dtutils/system   they don't work in this situation (no control
                     over the input strings)
2024-07-13 12:46:34 -04:00
wpferguson
dc81c0b1c5 Merge pull request #494 from wpferguson/add_preserve_metadata_to_RL_out_sharp
RL_out_sharp - preserve metadata
2024-07-10 15:22:35 -04:00
Bill Ferguson
e8a99c8396 contrib/RL_out_sharp - add function to preserve the exported images
metadata in the sharpened image using exiftool
2024-07-10 15:17:35 -04:00
wpferguson
7c93868bf0 Merge pull request #491 from wpferguson/fix_quote_windows_command_call
lib/dtutils/system - fixed typo in quote_windows_command call
2024-07-08 11:46:30 -04:00
Bill Ferguson
36023d8d4f lib/dtutils/system - fixed typo in quote_windows_command call 2024-07-08 11:43:42 -04:00
wpferguson
97aa4ce363 Merge pull request #490 from wpferguson/fix_email
fix email address
2024-06-30 12:46:51 -04:00
Bill Ferguson
316a89d6a8 contrib/auto_snapshot - fixed email address
contrib/dbmain
2024-06-30 12:44:02 -04:00
wpferguson
d4a479b025 Merge pull request #486 from wpferguson/ensure_renamed_image_visible
ensure renamed image is visible
2024-06-21 10:04:06 -04:00
wpferguson
dd22c947c6 Merge pull request #487 from wpferguson/fix_fujifilm_dynamic_range_duplicates
fujifilm_dynamic_range - fix duplicate processing
2024-06-21 10:03:45 -04:00
wpferguson
09f47b7b09 Merge pull request #488 from wpferguson/auto_snapshot
auto_snapshot
2024-06-21 10:03:30 -04:00
Bill Ferguson
ba94914c0e contrib/auto_snapshot - added Lua option to create always create a snapshot
when opening an image in darkroom, even if it is
                        altered
2024-06-20 18:09:10 -04:00
Bill Ferguson
3bb4e9c59a contrib/auto_snapshot - take a snapshot automatically when opening an image in darkroom 2024-06-20 17:46:54 -04:00
Bill Ferguson
f8c076f308 contrib/fujifilm_dynamic_range - added check for duplicates after an
image is processed.  If duplicates are
                                 found the exposure bias is applied to
                                 them.
2024-06-19 20:50:54 -04:00
Bill Ferguson
94f41db6fc contrib/rename_images - make sure the renamed image, or first renamed
image of a group is visible after renaming.
2024-06-19 11:41:54 -04:00
wpferguson
5727b2d251 Merge pull request #485 from wpferguson/script_manager_api_solution
script_manager api check solution
2024-06-18 00:34:30 -04:00
Bill Ferguson
c95f8a23b2 lib/dtutils/log - fix screen print check 2024-06-18 00:30:34 -04:00
Bill Ferguson
88e4ac1a64 tools/script_manager - changed API check from hard (crash) to soft
which allows script_manager to fix tthe problem
                       by checking out the correct version of the
                       scripts for the API version.
2024-06-18 00:29:27 -04:00
wpferguson
a3fe02bf95 Merge pull request #482 from wpferguson/fix_non_windows_command_sanitize
fix non windows external command sanitize
2024-06-14 12:37:16 -04:00
Bill Ferguson
ff20098175 lib/dtuils/system - removed ds.sanitize wrapped around non windows command. 2024-06-14 12:33:35 -04:00
wpferguson
cdf4b743dd Merge pull request #479 from wpferguson/script_mangaer_4_8
New script_manger UI for darktable 4.8
2024-06-09 17:36:52 -04:00
Bill Ferguson
3efc1805ca tools/script_manager - new user interface for darktable 4.8
wrappers added for io.popen and os.execute
                       to handle windows special characters and
                       spaces
2024-06-09 17:33:06 -04:00
wpferguson
0b46cf8abf Merge pull request #477 from darktable-org/revert-474-script_manager_new_ui
Revert "script_manager new UI"
2024-06-09 16:42:17 -04:00
wpferguson
28622e620e Revert "script_manager new UI" 2024-06-09 16:42:05 -04:00
wpferguson
f21a117d29 Merge pull request #474 from wpferguson/script_manager_new_ui
script_manager new UI
2024-06-09 16:25:50 -04:00
wpferguson
35cbff03dd Merge pull request #475 from wpferguson/doc_update
Update documentation
2024-06-08 22:33:57 -04:00
Bill Ferguson
5571e2f2dc ChangeLog - Updated with the latest repository changes
README - Updated the script additions
2024-06-08 21:51:37 -04:00
wpferguson
3c77f2e863 Merge branch 'master' into script_manager_new_ui 2024-06-07 19:31:25 -04:00
Bill Ferguson
4ff1111341 tools/script_manaager added sanitized io.popen and os.execute functions
for windows character and space issues.  Cleaned
                      up translatable strings to make future translation
                      easier.
2024-06-07 15:23:06 -04:00
wpferguson
abfa8e9878 Merge pull request #473 from wpferguson/fix_472_fujifilm_ratings
Fix fujifilm ratings
2024-06-06 13:02:29 -04:00
wpferguson
bbe9109fca Merge pull request #469 from wpferguson/win_sanitize
Sanitize windows command interactions
2024-06-06 13:01:55 -04:00
wpferguson
34d5df65b2 Merge pull request #468 from wpferguson/dbmaint
database maintenance script
2024-06-06 13:01:19 -04:00
Bill Ferguson
539f25517b contrib/fujifilm_ratings - added check to ensure the image is a
fujifilm file.
2024-06-05 22:16:40 -04:00
wpferguson
5b55a3116d Merge pull request #470 from wpferguson/windows_executuable_manager_fix
executable_manager - fix position not visible on windows
2024-06-05 14:51:10 -04:00
Bill Ferguson
3e032616a0 tools/executable_manager - fix position not visible on windows 2024-06-05 14:49:06 -04:00
Bill Ferguson
9f2dbef4f0 lib/dtutils/system added local helper function quote_windows_command() to
wrap a windows command in quotes.  Added a sanitize step
                   to windows_external_command() plus quote_windows_command()
                   to deal with all the windows username possibilities
2024-06-05 12:15:01 -04:00
Bill Ferguson
2abb83b485 tools/get_lib_manpages - more code cleanup 2024-06-05 00:09:18 -04:00
Bill Ferguson
32e966f8d9 tools/git_lib_manpages code cleanup 2024-06-05 00:01:47 -04:00
Bill Ferguson
67538a4de2 lib/dtutils/system code cleanup 2024-06-05 00:01:17 -04:00
Bill Ferguson
96471ae7e7 lib/dtutils - fixed documentation error 2024-06-05 00:00:43 -04:00
Bill Ferguson
038418b89f contrib/autostyle replaced io.popen functions with wrapper
contrib/color_profile_manager    to properly quote windows commands so
contrib/fujifilm_dynamic_range   that they are sanitized for special
contrib/fujifilm_ratings         characters and spaces
contrib/geoJSON_export
contrib/geoToolbox
contrib/image_stack
contrib/image_time
contrib/kml_export
official/enfuse
tools/executable_manager
tools/get_lib_manpages
tools/get_libdoc
2024-06-04 23:43:21 -04:00
Bill Ferguson
fe48d7498c lib/dtutils/file - replaced os.execute and io.popen with wrapper functions
to sanitize windows calls
2024-06-04 23:41:07 -04:00
Bill Ferguson
2f330ea9cc lib/dtutils/system - added wrapper functions io_popen and os_execute
to wrap io.popen and os.execute system calls
                     respectively.  These wrapper functions provide
                     the necessary quoting on windows to get handle
                     strings with spaces and special characters.
2024-06-04 23:16:19 -04:00
Bill Ferguson
81b0f1fb48 contrib/dbmaint - remove database records for missing film rolls and images. 2024-06-03 18:08:30 -04:00
Bill Ferguson
9088bc9144 tools/script_manager - make the constants <const> to ensure they
stay that way
2024-06-03 14:48:44 -04:00
wpferguson
c3ce8d532d Merge pull request #467 from koto/open_in_file_explorer_osx
Support selecting multiple files in MacOS in OpenInExplorer.
2024-05-30 13:36:47 -04:00
Krzysztof Kotowicz
f1d8ad7fce Fix quoting. 2024-05-27 18:26:35 +02:00
Krzysztof Kotowicz
a3b295112f Update OpenInExplorer.lua
In OpenInExplorer, use AppleScript instead of `open -R` for OSX.

That way multiple files can be selected.
2024-05-27 13:03:00 +02:00
wpferguson
c36618f5fb Merge pull request #466 from wpferguson/more_string_doc_updates
lib/dtutils/string - more embedded doc updates
2024-05-20 23:45:07 -04:00
Bill Ferguson
fecbb39347 lib/dtutils/string - more embedded doc updates 2024-05-20 23:43:47 -04:00
wpferguson
cbe2c5329a Merge pull request #412 from wpferguson/add_substitution_to_string_lib
Add substitution to string lib
2024-05-20 22:18:01 -04:00
Bill Ferguson
dcbe575e9c lib/dtutils/string - updated embedded documentation 2024-05-20 22:13:29 -04:00
Bill Ferguson
417c165d16 lib/dtutils/string - updated documentation 2024-05-20 18:18:46 -04:00
Bill Ferguson
232baab86b lib/dtutils/string - removed debugging statements 2024-05-20 10:07:13 -04:00
Bill Ferguson
3ed4219e6c lib/dtutils/string - added [] to sanitize_lua().
added 4.8 syntax to CATEGORY

                     added 4.8 SEQUENCE changes (syntax, start, width)
2024-05-20 00:56:01 -04:00
Bill Ferguson
97e33672ea lib/dtutils/string - fixed default formatting of sequence 2024-05-19 23:04:01 -04:00
Bill Ferguson
7b2018412a lib/dtutils/string - Cleaned up code to make it more readable.
Fixed VERSION_IF_MULTI.  Added safety check
                     in category to make sure we don't try and
                     read a tag field that doesn't exist.
2024-05-18 22:01:10 -04:00
Bill Ferguson
3e2afffed8 lib/dtutils/string - Added categories to substitution functionality.
This makes it feature complete.  Some substitutions
                         aren't implemented since the current use case for
                         this is creating export directories.  The results
                         from the not implemented substitutions wouldn't
                         work well in path/file names (such as comma
                         separated lists or newlines).
2024-05-18 21:59:11 -04:00
wpferguson
1399e8a4b4 Merge pull request #465 from wpferguson/fix_script_manager
Fix script_manager crash
2024-05-16 11:47:29 -04:00
Bill Ferguson
5c3b2777f0 tools/script_manager - fixed gettext.bindtextdomain 2024-05-16 11:44:35 -04:00
Bill Ferguson
bf138abeb2 tools/script_manager - removed debugging statement 2024-05-15 21:36:15 -04:00
Bill Ferguson
284c0f9714 tools/script_manager - fixed metadata decoding to get rid of spurious
commas
2024-05-15 21:33:29 -04:00
wpferguson
e41029d3f4 Merge pull request #464 from wpferguson/implement_script_metadata
Implement script metadata
2024-05-15 21:27:54 -04:00
Bill Ferguson
55e68f8cd0 Added metadata fields to scripts that script_manager can access and
display as a tooltip.

Added script_manager integration to those scripts that didn't have it.
2024-05-15 21:23:13 -04:00
wpferguson
ac945b9843 Merge pull request #455 from wpferguson/prep_translation
Prepare translatable strings, step 1
2024-05-15 15:18:11 -04:00
Bill Ferguson
f6916c3a15 tools/script_manager - lower cased mixed case buttons and headings 2024-05-15 14:51:14 -04:00
Bill Ferguson
cd3788f012 all scripts - added bindtextdomain back in because 4.8 isn't ready to
handle the translations yet.  In 5.0 this will be removed
              and darktable will handle translating the strings.
2024-05-14 22:39:22 -04:00
Bill Ferguson
b1b3392b92 tools/script_manager removed color interface check button. Color can
be specified in the CSS using the tags that are
                     present if desired.

                    Cleaned up formatting of configuration items.

                    Added a few debugging messages.
2024-04-09 21:41:42 -04:00
Bill Ferguson
ddf0c89402 tools/script_manager - cleaned up layout of panels and added some
spacing so what is being operated on is more
                         appearent
2024-04-06 21:28:58 -04:00
Bill Ferguson
3b0ff3475a tools/script_manager added blank lines to improve code readability 2024-04-05 21:12:45 -04:00
Bill Ferguson
401509cfe4 tools/script_manager added parser for script_data.metadata blocks in
scripts.  Parsed data block is used as the tooltip.
                      Fallback is the comment block at the top of the
                      script.
2024-04-05 20:38:10 -04:00
Bill Ferguson
9c4e906033 data/icons - added 20px icons 2024-04-05 20:37:34 -04:00
Bill Ferguson
a11726889d tools/script_manager - add support for "local" libraries by adding
entries in the package.path search path if
                       required
2024-04-02 19:09:31 -04:00
Bill Ferguson
86ee8adbce tools/script_manager - changed category/categories to folder/folders to
accurately refrect reality and to open the possibility
                       of actually categorizing scripts.
2024-04-01 18:26:41 -04:00
Bill Ferguson
231e9b352b changed translatable strings to lower case 2024-03-29 14:17:19 -04:00
Bill Ferguson
e47ab34745 changed translatable strings to lower case 2024-03-29 13:10:41 -04:00
Bill Ferguson
1fd2ca20ab changed translatable strings to lower case 2024-03-29 12:55:08 -04:00
Bill Ferguson
05a73d8810 changed translatable strings to lower case 2024-03-29 12:45:28 -04:00
Bill Ferguson
66b33d6f48 updated contrib scripts to use darktable translation facilities 2024-01-20 20:22:32 -05:00
Bill Ferguson
37dba718a2 updated official scripts to use darktable translation facilities 2024-01-20 15:25:16 -05:00
Bill Ferguson
c11845cbf9 updated example scripts to use darktable translation facilities 2024-01-19 18:57:18 -05:00
Bill Ferguson
f9fe33f930 updated script_manager and executable_manager to use darktable
translation facilities.  Changed translatable messages with
arguments to use string.format for one complete string versus snippets.

Removed gen_i18n_mo since we will be using darktable's translation
facilities and there's no need to generate lua specific mo files.
2024-01-19 15:24:56 -05:00
Bill Ferguson
ad10542b30 lib/dtutils/string - Added variable substitution functions that
are equivalent to the darktable variable
                     substitution functions.
2023-03-26 14:55:40 -04:00
Bill Ferguson
5331a38f10 lib/dtutils/string - added % and + to sanitize_lua() to prevent
pattern matching problems
2023-03-25 17:05:11 -04:00
Bill Ferguson
c9943a2065 lib/dtutils/string - Added logging capability with the ability to
set library logging level from a user script
2023-03-25 17:02:48 -04:00
83 changed files with 4504 additions and 2316 deletions

View File

@@ -1,5 +1,78 @@
## Changes from most recent to oldest
**06 Jun 2024 - wpferguson**
* fix fujifilm_ratings running on all images
* added string library functions to sanitize windows io.popen and os.execute functions
* added database maintenance script
**05 Jun 2024 - wpferguson**
* added fix for executable_manager not being visible on windows
**30 May 2024 - kkotowicz**
* open in explorer now uses applescript on macos to open multiple files
**20 May 2024 - wpferguson**
* added string variable substitution to the string library
**16 May 2024 - wpferguson**
* fix crash in script_manager
**15 May 2024 - wpferguson**
* added metadata to scripts (name, author, purpose, help url)
**06 May 2024 - christian.sueltrop**
* added passport_guide_germany script
**08 Apr 2024 - wpferguson**
* made script_manager aware of library modules in other directories besides lib
**29 Mar 2024 - wpferguson**
* updated examples/gui_action to use NaN instead of nan
**29 Mar 2024 - dterrahe**
* add lua action script example
**28 Jan 2024 - wpferguson**
* fix script_manager crash when script existed in top level lua directory
**24 Jan 2024 - wpferguson**
* don't set lib visibility unless we are in lighttable mode
**15 Jan 2024 - MStraeten**
* update x-touch.lua with support for primaries slider
**14 Jan 2024 - wpferguson**
* added cycle_group_leader script
* added hif_group_leader script
* added jpg_group_leader script
**28 Oct 2023 - ddittmar**
* Added select non existing image script
**17 Oct 2023 - wpferguson**
* script_manager wrap username in quotes to handle spaces in username
**20 Sep 2023 - wpferguson**
* script_manager explicitly set stopped scripts to false
**18 Aug 2023 - wpferguson**
* swap the position of executable_manager and script_manager due to windows gtk bug
**17 Jul 2023 - wpferguson**
* update check for update instructions
* update flatpak readme
**16 Jul 2023 - wpferguson**
* added script_data.show function to contrib/gpx_export
**15 Jul 2023 - wpferguson**
* script_manager updates
* added check_max_api_version for the case where the API no longer supports the required
functions
**14 Jul 2023 - spaceChRis**
* add tooltip to filter manager
**25 Mar 2023 - wpferguson**
* Added script_manager darktable shortcut integration
* Moved filename/path/extension string functions to string library

View File

@@ -39,8 +39,11 @@ Name|Standalone|OS |Purpose
change_group_leader|Yes|LMW|Change which image leads group
[clear_GPS](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/clear_gps)|Yes|LMW|Reset GPS information for selected images
[CollectHelper](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/collecthelper)|Yes|LMW|Add buttons to selected images module to manipulate the collection
color_profile_manager|Yes|LMW|Manage darktable input and output color profiles
[copy_attach_detach_tags](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/copy_attach_detach_tags)|Yes|LMW|Copy and paste tags from/to images
[cr2hdr](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/cr2hdr)|Yes|L|Process image created with Magic Lantern Dual ISO
cycle_group_leader|Yes|LMW|cycle through images of a group making each the group leader in turn
dbmaint|Yes|LMW|find and remove database entries for missing film rolls and images
[enfuseAdvanced](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/enfuseadvanced)|No|LMW|Merge multiple images into Dynamic Range Increase (DRI) or Depth From Focus (DFF) images
[exportLUT](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/exportlut)|Yes|LMW|Create a LUT from a style and export it
[ext_editor](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/ext_editor)|No|LW|Export pictures to collection and edit them with up to nine user-defined external editors
@@ -51,14 +54,18 @@ change_group_leader|Yes|LMW|Change which image leads group
[geoToolbox](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/geotoolbox)|No|LMW|A toolbox of geo functions
[gimp](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/gimp)|No|LMW|Open an image in GIMP for editing and return the result
[gpx_export](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/gpx_export)|No|LMW|Export a GPX track file from selected images GPS data
harmonic_armature|Yes|LMW|provide a harmonic armature guide
hif_group_leader|Yes|LMW|change the group leader in a raw+heif image pair to the heif image
[HDRMerge](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/hdrmerge)|No|LMW|Combine the selected images into an HDR DNG and return the result
[hugin](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/hugin)|No|LMW|Combine selected images into a panorama and return the result
[image_stack](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/image_stack)|No|LMW|Combine a stack of images to remove noise or transient objects
[image_time](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/image_time)|Yes|LMW|Adjust the EXIF image time
jpg_group_leader|Yes|LMW|change the group leader for a raw+jpg pair to the jpg image
[kml_export](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/kml_export)|No|L|Export photos with a KML file for usage in Google Earth
[LabelsToTags](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/labelstotags)|Yes|LMW|Apply tags based on color labels and ratings
[OpenInExplorer](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/openinexplorer)|No|LMW|Open the selected images in the system file manager
[passport_guide](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/passport_guide)|Yes|LMW|Add passport cropping guide to darkroom crop tool
passport_guide_germany|Yes|LMW|Add passport cropping guide for German passports to darkroom crop tool
[pdf_slideshow](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/pdf_slideshow)|No|LM|Export images to a PDF slideshow
[photils](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/photils)|No|LM|Automatic tag suggestions for your images
[quicktag](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/quicktag)|Yes|LMW|Create shortcuts for quickly applying tags
@@ -81,6 +88,7 @@ Name|Standalone|OS |Purpose
[api_version](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/api_version)|Yes|LMW|Print the current API version
[darkroom_demo](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/darkroom_demo)|Yes|LMW|Demonstrate changing images in darkoom
[gettextExample](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/gettextexample)|Yes|LM|How to use translation
gui_actions|Yes|LMW|demonstrate controlling the GUI using darktable.gui.action calls
[hello_world](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/hello_world)|Yes|LMW|Prints hello world when darktable starts
[lighttable_demo](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/lighttable_demo)|Yes|LMW|Demonstrate controlling lighttable mode, zoom, sorting and filtering
[moduleExample](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/moduleexample)|Yes|LMW|How to create a lighttable module
@@ -89,6 +97,7 @@ Name|Standalone|OS |Purpose
[preferenceExamples](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/preferenceexamples)|Yes|LMW|How to use preferences in a script
[printExamples](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/printexamples)|Yes|LMW|How to use various print functions from a script
[running_os](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/examples/running_os)|Yes|LMW|Print out the running operating system
x-touch|Yes|LMW|demonstrate how to use an x-touch mini MIDI controller to control the darktable GUI
### Tools
@@ -118,6 +127,8 @@ The following third-party projects are listed for information only. Think of thi
* [nbremond77/darktable](https://github.com/nbremond77/darktable/tree/master/scripts)
* [s5k6/dtscripts](https://github.com/s5k6/dtscripts)
* [ChristianBirzer/darktable_extra_scripts](https://github.com/ChristianBirzer/darktable_extra_scripts)
* [fjb2020/darktable-scripts](https://github.com//fjb2020/darktable-scripts)
* [bastibe/Darktable-Film-Simulation-Panel](https://github.com/bastibe/Darktable-Film-Simulation-Panel)
## Download and Install

View File

@@ -43,23 +43,29 @@ du.check_min_api_version("7.0.0", "AutoGrouper")
local MOD = 'autogrouper'
local gettext = dt.gettext
gettext.bindtextdomain(MOD, dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "AutoGrouper",
purpose = _("automatically group images by time interval"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/AutoGrouper/"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local gettext = dt.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("AutoGrouper",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("AutoGrouper", msgid)
end
local Ag = {}
Ag.module_installed = false
Ag.event_registered = false

View File

@@ -47,32 +47,38 @@ In the "Selected Images" module click on "Collect on this Image"
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
local previous = nil
local all_active = false
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("CollectHelper",dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("7.0.0", "CollectHelper")
dt.gettext.bindtextdomain("CollectHelper", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "CollectHelper",
purpose = _("add collection helper buttons"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/CollectHelper/"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function _(msgid)
return gettext.dgettext("CollectHelper", msgid)
end
-- FUNCTION --
local function CheckSingleImage(selection)
if #selection ~= 1 then
dt.print(_("Please select a single image"))
dt.print(_("please select a single image"))
return true
end
return false
@@ -205,47 +211,47 @@ end
dt.gui.libs.image.register_action(
"CollectHelper_prev", _("collect: previous"),
function() PreviousCollection() end,
_("Sets the Collect parameters to be the previously active parameters")
_("sets the collect parameters to be the previously active parameters")
)
if dt.preferences.read('module_CollectHelper','folder','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_folder", _("collect: folder"),
function() CollectOnFolder(_ , false) end,
_("Sets the Collect parameters to be the selected images's folder")
_("sets the collect parameters to be the selected images's folder")
)
end
if dt.preferences.read('module_CollectHelper','colors','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_labels", _("collect: color label(s)"),
function() CollectOnColors(_ , false) end,
_("Sets the Collect parameters to be the selected images's color label(s)")
_("sets the collect parameters to be the selected images's color label(s)")
)
end
if dt.preferences.read('module_CollectHelper','all_and','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_and", _("collect: all (AND)"),
function() CollectOnAll_AND() end,
_("Sets the Collect parameters based on all activated CollectHelper options")
_("sets the collect parameters based on all activated CollectHelper options")
)
end
-- PREFERENCES --
dt.preferences.register("module_CollectHelper", "all_and", -- name
"bool", -- type
_('CollectHelper: All'), -- label
_('Will create a collect parameter set that utilizes all enabled CollectHelper types (AND)'), -- tooltip
_('CollectHelper: all'), -- label
_('will create a collect parameter set that utilizes all enabled CollectHelper types (and)'), -- tooltip
true -- default
)
dt.preferences.register("module_CollectHelper", "colors", -- name
"bool", -- type
_('CollectHelper: Color Label(s)'), -- label
_('Enable the button that allows you to swap to a collection based on selected image\'s COLOR LABEL(S)'), -- tooltip
_('CollectHelper: color label(s)'), -- label
_('enable the button that allows you to swap to a collection based on selected image\'s color label(s)'), -- tooltip
true -- default
)
dt.preferences.register("module_CollectHelper", "folder", -- name
"bool", -- type
_('CollectHelper: Folder'), -- label
_('Enable the button that allows you to swap to a collection based on selected image\'s FOLDER location'), -- tooltip
_('CollectHelper: folder'), -- label
_('enable the button that allows you to swap to a collection based on selected image\'s folder location'), -- tooltip
true -- default
)

View File

@@ -51,10 +51,26 @@ local dsys = require 'lib/dtutils.system'
du.check_min_api_version("7.0.0", "HDRmerge")
-- Tell gettext where to find the .mo file translating messages for a particular domain
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("HDRMerge", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "HDRmerge",
purpose = _("merge bracketed images into an HDR DNG image"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/HDRmerge"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -66,13 +82,6 @@ local os_path_seperator = '/'
if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end
local CURR_API_STRING = dt.configuration.api_version_string
-- Tell gettext where to find the .mo file translating messages for a particular domain
local gettext = dt.gettext
gettext.bindtextdomain('HDRMerge', dt.configuration.config_dir..'/lua/locale/')
local function _(msgid)
return gettext.dgettext('HDRMerge', msgid)
end
local temp
local HDRM = { --HDRMerge Program Table
name = 'HDRMerge',
@@ -208,7 +217,7 @@ end
local function main()
PreCall({HDRM}) --check if furst run then check if install OK
if HDRM.install_error then
dt.print_error(_('HDRMerge install issue'))
dt.print_error('HDRMerge install issue')
dt.print(_('HDRMerge install issue, please ensure the binary path is proper'))
return
end
@@ -277,7 +286,7 @@ local function main()
end
dt.print(_('HDRMerge completed successfully'))
else
dt.print_error(_('HDRMerge failed'))
dt.print_error('HDRMerge failed')
dt.print(_('HDRMerge failed'))
end
@@ -378,7 +387,7 @@ local lbl_import = dt.new_widget('section_label'){
}
GUI.Target.style = dt.new_widget('combobox'){
label = _('apply style on import'),
tooltip = _('Apply selected style on auto-import to newly created image'),
tooltip = _('apply selected style on auto-import to newly created image'),
selected = 1,
_('none'),
changed_callback = function(self)
@@ -407,9 +416,9 @@ GUI.Target.copy_tags = dt.new_widget('check_button'){
temp = dt.preferences.read(mod, 'active_add_tags', 'string')
if temp == '' then temp = nil end
GUI.Target.add_tags = dt.new_widget('entry'){
tooltip = _('Additional tags to be added on import. Seperate with commas, all spaces will be removed'),
tooltip = _('additional tags to be added on import, seperate with commas, all spaces will be removed'),
text = temp,
placeholder = _('Enter tags, seperated by commas'),
placeholder = _('enter tags, seperated by commas'),
editable = true
}
GUI.run = dt.new_widget('button'){
@@ -418,7 +427,7 @@ GUI.run = dt.new_widget('button'){
clicked_callback = function() main() end
}
GUI.exes.HDRMerge = dt.new_widget('file_chooser_button'){
title = _('Select HDRmerge executable'),
title = _('select HDRmerge executable'),
value = df.get_executable_path_preference(HDRM.name),
is_directory = false
}

View File

@@ -52,10 +52,25 @@ local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "LabelsToTags")
local gettext = darktable.gettext.gettext
darktable.gettext.bindtextdomain("LabelsToTags", darktable.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "LabelsToTags",
purpose = _("allows the mass-application of tags using color labels and ratings as a guide"),
author = "August Schwerdfeger (august@schwerdfeger.name)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/LabelsToTags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -68,7 +83,7 @@ local ltt = {}
ltt.module_installed = false
ltt.event_registered = false
local LIB_ID = "LabelsToTags"
local LIB_ID = _("LabelsToTags")
-- Helper functions: BEGIN
@@ -109,23 +124,23 @@ end
local initialAvailableMappings = {
["Colors"] = { ["+*****"] = { "Red" },
["*+****"] = { "Yellow" },
["**+***"] = { "Green" },
["***+**"] = { "Blue" },
["****+*"] = { "Purple" } },
["Single colors"] = { ["+----*"] = { "Red", "Only red" },
["-+---*"] = { "Yellow", "Only yellow" },
["--+--*"] = { "Green", "Only green" },
["---+-*"] = { "Blue", "Only blue" },
["----+*"] = { "Purple", "Only purple" } },
["Ratings"] = { ["*****0"] = { "No stars", "Not rejected" },
["*****1"] = { "One star", "Not rejected" },
["*****2"] = { "Two stars", "Not rejected" },
["*****3"] = { "Three stars", "Not rejected" },
["*****4"] = { "Four stars", "Not rejected" },
["*****5"] = { "Five stars", "Not rejected" },
["*****R"] = { "Rejected" } }
[_("colors")] = { ["+*****"] = { _("red") },
["*+****"] = { _("yellow") },
["**+***"] = { _("green") },
["***+**"] = { _("blue") },
["****+*"] = { _("purple") } },
[_("single colors")] = { ["+----*"] = { _("red"), _("only red") },
["-+---*"] = { _("yellow"), _("only yellow") },
["--+--*"] = { _("green"), _("only green") },
["---+-*"] = { _("blue"), _("only blue") },
["----+*"] = { _("purple"), _("only purple") } },
[_("ratings")] = { ["*****0"] = { _("no stars"), _("not rejected") },
["*****1"] = { _("one star"), _("not rejected") },
["*****2"] = { _("two stars"), _("not rejected") },
["*****3"] = { _("three stars"), _("not rejected") },
["*****4"] = { _("four stars"), _("not rejected") },
["*****5"] = { _("five stars"), _("not rejected") },
["*****R"] = { _("rejected") } }
}
local availableMappings = {}
@@ -140,14 +155,14 @@ end
local function getComboboxTooltip()
if availableMappings == nil or next(availableMappings) == nil then
return("No registered mappings -- using defaults")
return(_("no registered mappings -- using defaults"))
else
return("Select a label-to-tag mapping")
return(_("select a label-to-tag mapping"))
end
end
local mappingComboBox = darktable.new_widget("combobox"){
label = "mapping",
label = _("mapping"),
value = 1,
tooltip = getComboboxTooltip(),
reset_callback = function(selfC)
@@ -170,7 +185,7 @@ local mappingComboBox = darktable.new_widget("combobox"){
}
local function doTagging(selfC)
local job = darktable.gui.create_job(string.format("labels to tags (%d image" .. (#(darktable.gui.action_images) == 1 and "" or "s") .. ")",#(darktable.gui.action_images)),true)
local job = darktable.gui.create_job(string.format(_("labels to tags (%d image%s)"), #(darktable.gui.action_images), (#(darktable.gui.action_images) == 1 and "" or "s")), true)
job.percent = 0.0
local pctIncrement = 1.0 / #(darktable.gui.action_images)

View File

@@ -51,33 +51,39 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
--Check API version
du.check_min_api_version("7.0.0", "OpenInExplorer")
dt.gettext.bindtextdomain("OpenInExplorer", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "OpenInExplorer",
purpose = _("open a selected file in the system file manager"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/OpenInExplorer"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("OpenInExplorer",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("OpenInExplorer", msgid)
end
local act_os = dt.configuration.running_os
local PS = act_os == "windows" and "\\" or "/"
--Detect OS and quit if it is not supported.
if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then
dt.print(_("OpenInExplorer plug-in only supports Linux, macOS, and Windows at this time"))
dt.print(_("OpenInExplorer plug-in only supports linux, macos, and windows at this time"))
dt.print_error("OpenInExplorer plug-in only supports Linux, macOS, and Windows at this time")
return
end
@@ -93,11 +99,11 @@ local function check_if_links_dir_exists()
local dir_exists = true
if not links_dir then
--Just for paranoic reasons. I tried, but I couldn't devise a setting for a nil value.
dt.print(_("No links directory selected.\nPlease check the dt preferences (lua options)"))
dt.print(_("no links directory selected\nplease check the dt preferences (lua options)"))
dt.print_error("OpenInExplorer: No links directory selected")
dir_exists = false
elseif not df.check_if_file_exists(links_dir) then
dt.print(string.format(_("Links directory '%s' not found.\nPlease check the dt preferences (lua options)"), links_dir))
dt.print(string.format(_("links directory '%s' not found\nplease check the dt preferences (lua options)"), links_dir))
dt.print_error(string.format("OpenInExplorer: Links directory '%s' not found", links_dir))
dir_exists = false
end
@@ -112,9 +118,26 @@ open_dir.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesk
local open_files = {}
open_files.windows = "explorer.exe /select, %s"
open_files.macos = "open -Rn %s"
open_files.macos = "osascript -e 'tell application \"Finder\" to (reveal {%s}) activate'"
open_files.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass %d %s ""]]
reveal_file_osx_cmd = "\"%s\" as POSIX file"
--Call the osx Finder with each selected image selected.
--For images in multiple folders, Finder will open a separate window for each
local function call_list_of_files_osx(selected_images)
local cmds = {}
for _, image in pairs(selected_images) do
current_image = image.path..PS..image.filename
-- AppleScript needs double quoted strings, and the whole command is wrapped in single quotes.
table.insert(cmds, string.format(reveal_file_osx_cmd, string.gsub(string.gsub(current_image, "\"", "\\\""), "'", "'\"'\"'")))
end
reveal_cmd = table.concat(cmds, ",")
run_cmd = string.format(open_files.macos, reveal_cmd)
dt.print_log("OSX run_cmd = "..run_cmd)
dsys.external_command(run_cmd)
end
--Call the file mangager for each selected image on Linux.
--There is one call to busctl containing a list of all the image file names.
local function call_list_of_files(selected_images)
@@ -154,7 +177,7 @@ local function set_links(selected_images)
end
]]
if dsys.external_command(run_cmd) ~= 0 then
dt.print(_("Failed to create links. Missing rights?"))
dt.print(_("failed to create links, missing rights?"))
dt.print_error("OpenInExplorer: Failed to create links")
return
end
@@ -170,18 +193,20 @@ end
local function open_in_fmanager()
local images = dt.gui.selection()
if #images == 0 then
dt.print(_("Please select an image"))
dt.print(_("please select an image"))
else
if use_links and not check_if_links_dir_exists() then
return
end
if #images > 15 and not use_links then
dt.print(_("Please select fewer images (max. 15)"))
dt.print(_("please select fewer images (max. 15)"))
elseif use_links then
set_links(images)
else
if act_os == "linux" then
call_list_of_files(images)
elseif act_os == "macos" then
call_list_of_files_osx(images)
else
call_file_by_file(images)
end
@@ -203,7 +228,7 @@ end
dt.gui.libs.image.register_action(
"OpenInExplorer", _("show in file explorer"),
function() open_in_fmanager() end,
_("Open the file manager at the selected image's location")
_("open the file manager at the selected image's location")
)
@@ -211,17 +236,17 @@ if act_os ~= "windows" then
dt.preferences.register("OpenInExplorer", "linked_image_files_dir", -- name
"directory", -- type
_("OpenInExplorer: linked files directory"), -- label
_("Directory to store the links to the file names. Requires restart to take effect"), -- tooltip
_("directory to store the links to the file names, requires restart to take effect"), -- tooltip
"Links to image files", -- default
dt.new_widget("file_chooser_button"){
title = _("Select directory"),
title = _("select directory"),
is_directory = true,
}
)
dt.preferences.register("OpenInExplorer", "use_links", -- name
"bool", -- type
_("OpenInExplorer: use links"), -- label
_("Use links instead of multiple windows. Requires restart to take effect"), -- tooltip
_("use links instead of multiple windows, requires restart to take effect"), -- tooltip
false, -- default
""
)

View File

@@ -65,10 +65,26 @@ local MODULE_NAME = "RL_out_sharp"
-- check API version
du.check_min_api_version("7.0.0", MODULE_NAME)
-- translation
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("RL_out_sharp", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "RL_out_sharp",
purpose = _("Richardson-Lucy output sharpening using GMic"),
author = "Marco Carrarini <marco.carrarini@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/RL_out_sharp"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -77,20 +93,24 @@ script_data.show = nil -- only required for libs since the destroy_method only h
-- OS compatibility
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- translation
local gettext = dt.gettext
gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
end
-- initialize module preferences
if not dt.preferences.read(MODULE_NAME, "initialized", "bool") then
dt.preferences.write(MODULE_NAME, "sigma", "string", "0.7")
dt.preferences.write(MODULE_NAME, "iterations", "string", "10")
dt.preferences.write(MODULE_NAME, "jpg_quality", "string", "95")
dt.preferences.write(MODULE_NAME, "initialized", "bool", true)
end
-- preserve original image metadata in the output image -----------------------
local function preserve_metadata(original, sharpened)
local exiftool = df.check_if_bin_exists("exiftool")
if exiftool then
dtsys.external_command("exiftool -overwrite_original_in_place -tagsFromFile " .. original .. " " .. sharpened)
else
dt.print_log(MODULE .. " exiftool not found, metadata not preserved")
end
end
-- setup export ---------------------------------------------------------------
@@ -137,7 +157,7 @@ local function export2RL(storage, image_table, extra_data)
for image, temp_name in pairs(image_table) do
i = i + 1
dt.print(_("sharpening image ")..i.." ...")
dt.print(string.format(_("sharpening image %d ..."), i))
-- create unique filename
new_name = output_folder..PS..df.get_basename(temp_name)..".jpg"
new_name = df.create_unique_filename(new_name)
@@ -154,7 +174,10 @@ local function export2RL(storage, image_table, extra_data)
if result ~= 0 then
dt.print(_("sharpening error"))
return
end
end
-- copy metadata from input_file to output_file
preserve_metadata(input_file, output_file)
-- delete temp image
os.remove(temp_name)

134
contrib/auto_snapshot.lua Normal file
View File

@@ -0,0 +1,134 @@
--[[
auto_snapshot.lua - automatically take a snapshot when an image is loaded in darkroom
Copyright (C) 2024 Bill Ferguson <wpferguson@gamil.com>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
auto_snapshot -
automatically take a snapshot when an image is loaded in darkroom
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* start the script from script_manager
* open an image in darkroom
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gamil.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local log = require "lib/dtutils.log"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE <const> = "auto_snapshot"
local DEFAULT_LOG_LEVEL <const> = log.error
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE) -- choose the minimum version that contains the features you need
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain(MODULE , dt.configuration.config_dir .. "/lua/locale/")
local function _(msgid)
return gettext(MODULE, msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
script_data.metadata = {
name = "auto_snapshot", -- name of script
purpose = _("automatically take a snapshot when an image is loaded in darkroom"), -- purpose of script
author = "Bill Ferguson <wpferguson@gamil.com>", -- your name and optionally e-mail address
help = "" -- URL to help/documentation
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
-- - - - - - - - - - - - - - - - - - - - - - - -
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local auto_snapshot = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.preferences.register(MODULE, "always_create_snapshot", "bool", "always automatically create_snapshot",
"auto_snapshot - create a snapshot even if the image is altered", false)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
dt.destroy_event(MODULE, "darkroom-image-loaded")
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.register_event(MODULE, "darkroom-image-loaded",
function(event, clean, image)
local always = dt.preferences.read(MODULE, "always_create_snapshot", "bool")
if clean and always then
dt.gui.libs.snapshots.take_snapshot()
elseif clean and not image.is_altered then
dt.gui.libs.snapshots.take_snapshot()
end
end
)
return script_data

View File

@@ -39,13 +39,28 @@ GPLv2
local darktable = require "darktable"
local du = require "lib/dtutils"
local filelib = require "lib/dtutils.file"
local syslib = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "autostyle")
local gettext = darktable.gettext.gettext
darktable.gettext.bindtextdomain("autostyle", darktable.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "autostyle",
purpose = _("automatically apply a style based on image EXIF tag"),
author = "Marc Cousin <cousinmarc@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/autostyle/"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -92,19 +107,19 @@ local function autostyle_apply_one_image (image)
-- check they all exist (correct syntax)
if (not tag) then
darktable.print("EXIF TAG not found in " .. pref)
darktable.print(string.format(_("EXIF tag not found in %s"), pref))
return 0
end
if (not value) then
darktable.print("value to match not found in " .. pref)
darktable.print(string.format(_("value to match not found in %s"), pref))
return 0
end
if (not style_name) then
darktable.print("style name not found in " .. pref)
darktable.print(string.format(_("style name not found in %s"), pref))
return 0
end
if not filelib.check_if_bin_exists("exiftool") then
darktable.print("Can't find exiftool")
darktable.print(_("can't find exiftool"))
return 0
end
@@ -118,7 +133,7 @@ local function autostyle_apply_one_image (image)
end
end
if (not style) then
darktable.print("style not found for autostyle: " .. style_name)
darktable.print(string.format(_("style not found for autostyle: %s"), style_name))
return 0
end
@@ -127,7 +142,7 @@ local function autostyle_apply_one_image (image)
--darktable.print_error("dr_attr:" .. auto_dr_attr)
-- If the lookup fails, stop here
if (not ok) then
darktable.print("Couldn't get attribute " .. auto_dr_attr .. " from exiftool's output")
darktable.print(string.format(_("couldn't get attribute %s from exiftool's output"), auto_dr_attr))
return 0
end
if auto_dr_attr == value then
@@ -154,7 +169,7 @@ local function autostyle_apply(shortcut)
images_submitted = images_submitted + 1
images_processed = images_processed + autostyle_apply_one_image(image)
end
darktable.print("Applied auto style to " .. images_processed .. " out of " .. images_submitted .. " image(s)")
darktable.print(string.format(_("applied auto style to %d out of %d image(s)"), images_processed, images_submitted))
end
local function destroy()
@@ -164,9 +179,9 @@ end
-- Registering events
darktable.register_event("autostyle", "shortcut", autostyle_apply,
"Apply your chosen style from exiftool tags")
_("apply your chosen style from exiftool tags"))
darktable.preferences.register("autostyle", "exif_tag", "string", "Autostyle: EXIF_tag=value=>style", "apply a style automatically if an EXIF_tag matches value. Find the tag with exiftool", "")
darktable.preferences.register("autostyle", "exif_tag", "string", "Autostyle: EXIF_tag=value=>style", _("apply a style automatically if an EXIF tag matches value, find the tag with exiftool"), "")
darktable.register_event("autostyle", "post-import-image",
autostyle_apply_one_image_event)

View File

@@ -36,28 +36,34 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
local MODULE = "change_group_leader"
dt.gettext.bindtextdomain(MODULE, dt.configuration.config_dir .."/lua/locale/")
du.check_min_api_version("3.0.0", MODULE)
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "change_group_leader",
purpose = _("automatically change the leader of raw+jpg paired image groups"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/change_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain(MODULE, dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE, msgid)
end
-- create a namespace to contain persistent data and widgets
chg_grp_ldr = {}
@@ -121,7 +127,7 @@ end
local function process_image_groups(images)
if #images < 1 then
dt.print(_("No images selected."))
dt.print(_("no images selected"))
dt.print_log(MODULE .. "no images seletected, returning...")
else
local mode = cgl.widgets.mode.value
@@ -161,7 +167,7 @@ cgl.widgets.mode = dt.new_widget("combobox"){
}
cgl.widgets.execute = dt.new_widget("button"){
label = _("Execute"),
label = _("execute"),
clicked_callback = function()
process_image_groups(dt.gui.action_images)
end

View File

@@ -39,29 +39,34 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("clear_GPS", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "clear_GPS",
purpose = _("remove GPS data from selected image(s)"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/clear_gps/"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local gettext = dt.gettext
-- not a number
local NaN = 0/0
du.check_min_api_version("7.0.0", "clear_GPS")
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("clear_GPS",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("clear_GPS", msgid)
end
local function clear_GPS(images)
for _, image in ipairs(images) do
-- set the location information to Not a Number (NaN) so it displays correctly
@@ -81,13 +86,13 @@ script_data.destroy = destroy
dt.gui.libs.image.register_action(
"clear_GPS", _("clear GPS data"),
function(event, images) clear_GPS(images) end,
_("Clear GPS data from selected images")
_("clear GPS data from selected images")
)
dt.register_event(
"clear_GPS", "shortcut",
function(event, shortcut) clear_GPS(dt.gui.action_images) end,
_("Clear GPS data")
_("clear GPS data")
)
return script_data

View File

@@ -45,6 +45,7 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "color_profile_manager")
@@ -52,13 +53,12 @@ du.check_min_api_version("7.0.0", "color_profile_manager")
-- L O C A L I Z A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext
local gettext = dt.gettext.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("color_profile_manager", dt.configuration.config_dir .. "/lua/locale/")
dt.gettext.bindtextdomain("color_profile_manager", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext("color_profile_manager", msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -119,13 +119,13 @@ end
local function add_profile(file, dir)
df.file_copy(file, dir)
dt.print(_("added color profile " .. file .. " to " .. dir))
dt.print(string.format(_("added color profile %s to %s"), file, dir))
dt.print_log("color profile " .. file .. " added to " .. dir)
end
local function remove_profile(file, dir)
os.remove(dir .. PS .. file)
dt.print(_("removed color profile " .. file .. " from " .. dir))
dt.print(string.format(_("removed color profile %s from %s"), file, dir))
dt.print_log("color profile " .. file .. " removed from " .. dir)
end
@@ -364,6 +364,13 @@ end
local script_data = {}
script_data.metadata = {
name = "color_profile_manager",
purpose = _("manage external darktable color profiles"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/color_profile_manager"
}
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"

View File

@@ -40,26 +40,32 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "copy_attach_detach_tags")
dt.gettext.bindtextdomain("copy_attach_detach_tags", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "copy_attach_detach_tags",
purpose = _("shortcuts to copy, paste, replace, or remove tags from images"),
author = "Christian Kanzian",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/copy_attach_detach_tags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("copy_attach_detach_tags",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("copy_attach_detach_tags", msgid)
end
local cadt = {}
cadt.module_installed = false
cadt.event_registered = false
@@ -99,7 +105,7 @@ local function mcopy_tags()
end
end
dt.print(_('Image tags copied ...'))
dt.print(_('image tags copied ...'))
--create UI tag list
local taglist = ""
@@ -121,7 +127,7 @@ local function mcopy_tags()
local function attach_tags()
if next(image_tags) == nil then
dt.print(_('No tag to attach, please copy tags first.'))
dt.print(_('no tag to attach, please copy tags first.'))
return true
end
@@ -145,7 +151,7 @@ local function attach_tags()
end
end
end
dt.print(_('Tags attached ...'))
dt.print(_('tags attached ...'))
end
local function detach_tags()
@@ -161,13 +167,13 @@ local function detach_tags()
end
end
end
dt.print(_('Tags removed from image(s).'))
dt.print(_('tags removed from image(s).'))
end
local function replace_tags()
detach_tags()
attach_tags()
dt.print(_('Tags replaced'))
dt.print(_('tags replaced'))
end
local function install_module()

View File

@@ -37,10 +37,25 @@ local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "cr2hdr")
local gettext = darktable.gettext.gettext
darktable.gettext.bindtextdomain("cr2hdr", darktable.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "cr2hdr",
purpose = _("process Magic Lantern dual ISO images"),
author = "Till Theato <theato@ttill.de>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/cr2hdr"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -87,7 +102,7 @@ end
local function convert_images()
if next(queue) == nil then return end
job = darktable.gui.create_job("Dual ISO conversion", true, stop_conversion)
job = darktable.gui.create_job(_("dual ISO conversion"), true, stop_conversion)
for key,image in pairs(queue) do
if job.valid then
job.percent = (key-1)/#queue
@@ -98,7 +113,7 @@ local function convert_images()
end
local success_count = 0
for _ in pairs(processed_files) do success_count = success_count + 1 end
darktable.print("Dual ISO conversion successful on " .. success_count .. "/" .. #queue .. " images.")
darktable.print(string.format(_("dual ISO conversion successful on %d/%d images."), success_count, #queue))
job.valid = false
processed_files = {}
queue = {}
@@ -122,13 +137,13 @@ local function destroy()
end
darktable.register_event("cr2hdr", "shortcut",
convert_action_images, "Run cr2hdr (Magic Lantern DualISO converter) on selected images")
convert_action_images, _("run cr2hdr (Magic Lantern DualISO converter) on selected images"))
darktable.register_event("cr2hdr", "post-import-image",
file_imported)
darktable.register_event("cr2hdr", "post-import-film",
film_imported)
darktable.preferences.register("cr2hdr", "onimport", "bool", "Invoke on import", "If true then cr2hdr will try to proccess every file during importing. Warning: cr2hdr is quite slow even in figuring out on whether the file is Dual ISO or not.", false)
darktable.preferences.register("cr2hdr", "onimport", "bool", _("invoke on import"), _("if true then cr2hdr will try to proccess every file during importing\nwarning: cr2hdr is quite slow even in figuring out on whether the file is dual ISO or not."), false)
script_data.destroy = destroy

View File

@@ -1,6 +1,6 @@
--[[
cycle_group_leader.lua - change image grouip leader
cycle_group_leader.lua - change image group leader
Copyright (C) 2024 Bill Ferguson <wpferguson@gmail.com>
@@ -54,30 +54,36 @@ local MODULE = "cycle_group_leader"
du.check_min_api_version("7.0.0", MODULE)
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("cycle_group_leader", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.metadata = {
name = "cycle_group_leader",
purpose = _("change image group leader"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/cycle_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain(MODULE, dt.configuration.config_dir .. "/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE, msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -100,7 +106,7 @@ end
local function cycle_group_leader(image)
local group_images = image:get_group_members()
if #group_images < 2 then
hinter_msg(_("No images to cycle to in group"))
hinter_msg(_("no images to cycle to in group"))
return
else
local position = nil
@@ -147,7 +153,7 @@ dt.register_event(MODULE, "shortcut",
-- ignore the film roll, it contains all the images, not just the imported
local images = dt.gui.selection()
if #images < 1 then
dt.print(_("No image selected. Please select an image and try again"))
dt.print(_("no image selected, please select an image and try again"))
else
cycle_group_leader(images[1])
end

314
contrib/dbmaint.lua Normal file
View File

@@ -0,0 +1,314 @@
--[[
dbmaint.lua - perform database maintenance
Copyright (C) 2024 Bill Ferguson <wpferguson@gamil.com>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
dbmaint - perform database maintenance
Perform database maintenance to clean up missing images and filmstrips.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* start dbmaint from script_manager
* scan for missing film rolls or missing images
* look at the results and choose to delete or not
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gamil.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local log = require "lib/dtutils.log"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE <const> = "dbmaint"
local DEFAULT_LOG_LEVEL <const> = log.error
local PS <const> = dt.configuration.running_os == "windows" and "\\" or "/"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE) -- choose the minimum version that contains the features you need
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain(MODULE , dt.configuration.config_dir .. "/lua/locale/")
local function _(msgid)
return gettext(MODULE, msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
script_data.metadata = {
name = "dbmaint",
purpose = _("perform database maintenance"),
author = "Bill Ferguson <wpferguson@gamil.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/dbmaint/"
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
-- - - - - - - - - - - - - - - - - - - - - - - -
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local dbmaint = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- G L O B A L V A R I A B L E S
-- - - - - - - - - - - - - - - - - - - - - - - -
dbmaint.main_widget = nil
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A L I A S E S
-- - - - - - - - - - - - - - - - - - - - - - - -
local namespace = dbmaint
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function scan_film_rolls()
local missing_films = {}
for _, filmroll in ipairs(dt.films) do
if not df.check_if_file_exists(filmroll.path) then
table.insert(missing_films, filmroll)
end
end
return missing_films
end
local function scan_images(film)
local missing_images = {}
if film then
for i = 1, #film do
local image = film[i]
log.log_msg(log.debug, "checking " .. image.filename)
if not df.check_if_file_exists(image.path .. PS .. image.filename) then
log.log_msg(log.info, image.filename .. " not found")
table.insert(missing_images, image)
end
end
end
return missing_images
end
local function remove_missing_film_rolls(list)
for _, filmroll in ipairs(list) do
filmroll:delete(true)
end
end
-- force the lighttable to reload
local function refresh_lighttable(film)
local rules = dt.gui.libs.collect.filter()
dt.gui.libs.collect.filter(rules)
end
local function remove_missing_images(list)
local film = list[1].film
for _, image in ipairs(list) do
image:delete()
end
refresh_lighttable(film)
end
local function install_module()
if not namespace.module_installed then
dt.register_lib(
MODULE, -- Module name
_("DB maintenance"), -- Visible name
true, -- expandable
true, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 0}}, -- containers
namespace.main_widget,
nil,-- view_enter
nil -- view_leave
)
namespace.module_installed = true
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- U S E R I N T E R F A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
dbmaint.list_widget = dt.new_widget("text_view"){
editable = false,
reset_callback = function(this)
this.text = ""
end
}
dbmaint.chooser = dt.new_widget("combobox"){
label = "scan for",
selected = 1,
"film rolls", "images",
reset_callback = function(this)
this.selected = 1
end
}
dbmaint.scan_button = dt.new_widget("button"){
label = "scan",
tooltip = "click to scan for missing film rolls/files",
clicked_callback = function(this)
local found = nil
local found_text = ""
if dbmaint.chooser.value == "film rolls" then
found = scan_film_rolls()
if #found > 0 then
for _, film in ipairs(found) do
local dir_name = du.split(film.path, PS)
found_text = found_text .. dir_name[#dir_name] .. "\n"
end
end
else
log.log_msg(log.debug, "checking path " .. dt.collection[1].path .. " for missing files")
found = scan_images(dt.collection[1].film)
if #found > 0 then
for _, image in ipairs(found) do
found_text = found_text .. image.filename .. "\n"
end
end
end
if #found > 0 then
dbmaint.list_widget.text = found_text
dbmaint.found = found
dbmaint.remove_button.sensitive = true
end
end,
reset_callback = function(this)
dbmaint.found = nil
end
}
dbmaint.remove_button = dt.new_widget("button"){
label = "remove",
tooltip = "remove missing film rolls/images",
sensitive = false,
clicked_callback = function(this)
if dbmaint.chooser.value == "film rolls" then
remove_missing_film_rolls(dbmaint.found)
else
remove_missing_images(dbmaint.found)
end
dbmaint.found = nil
dbmaint.list_widget.text = ""
this.sensitive = false
end,
reset_callback = function(this)
this.sensitive = false
end
}
dbmaint.main_widget = dt.new_widget("box"){
orientation = "vertical",
dt.new_widget("section_label"){label = "missing items"},
dbmaint.list_widget,
dt.new_widget("label"){label = ""},
dbmaint.chooser,
dt.new_widget("label"){label = ""},
dbmaint.scan_button,
dbmaint.remove_button
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
dt.gui.libs[MODULE].visible = false
if namespace.event_registered then
dt.destroy_event(MODULE, "view-changed")
end
return
end
local function restart()
dt.gui.libs[MODULE].visible = true
return
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not namespace.event_registered then
dt.register_event(MODULE, "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
namespace.event_registered = true
end
end
return script_data

View File

@@ -67,22 +67,31 @@ if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end
du.check_min_api_version("7.0.0", "enfuseAdvanced")
-- Tell gettext where to find the .mo file translating messages for a particular domain
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("enfuseAdvanced", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "enfuseAdvanced",
purpose = _("focus stack or exposure blend images"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/enfuseAdvanced"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
local gettext = dt.gettext
gettext.bindtextdomain('enfuseAdvanced',dt.configuration.config_dir..'/lua/locale/')
local function _(msgid)
return gettext.dgettext('enfuseAdvanced', msgid)
end
-- INITS --
local AIS = {
name = 'align_image_stack',
@@ -260,7 +269,7 @@ local function ExeUpdate(prog_tbl) --updates executable paths and verifies them
if not prog.bin then
prog.install_error = true
dt.preferences.write(mod, 'bin_exists', 'bool', false)
dt.print(_('issue with ')..prog.name.._(' executable'))
dt.print(string.format(_("issue with %s executable"), prog.name))
else
prog.bin = CleanSpaces(prog.bin)
end
@@ -377,7 +386,7 @@ local function SaveToPreference(preset) --save the present values of enfuse GUI
dt.preferences.write(mod, preset..argument, arg_data.style, temp)
end
end
dt.print(_('saved to ')..preset)
dt.print(string.format(_("saved to %s"), preset))
end
local function LoadFromPreference(preset) --load values from the specified 'preset' into the GUI elements
@@ -393,7 +402,7 @@ local function LoadFromPreference(preset) --load values from the specified 'pres
dt.preferences.write(mod, 'active_'..argument, arg_data.style, temp)
end
end
dt.print(_('loaded from ')..preset)
dt.print(string.format(_("loaded from %s"), preset))
end
local function remove_temp_files(images_to_remove) --deletes all files specified by the input string
@@ -428,7 +437,7 @@ local function support_format(storage, format) --tells dt we only support TIFF e
end
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) --outputs message to user showing script export status
dt.print(_('export for image fusion ')..tostring(math.floor(number))..' / '..tostring(math.floor(total)))
dt.print(string.format(_("export for image fusion %d / %d"), math.floor(number), math.floor(total)))
end
local function main(storage, image_table, extra_data)
@@ -456,8 +465,8 @@ local function main(storage, image_table, extra_data)
job.valid = false
if resp ~= 0 then
remove_temp_files(images_to_remove)
dt.print_error(AIS.name.._(' failed'))
dt.print(AIS.name.._(' failed'))
dt.print(string.format(_("%s failed"), AIS.name))
dt.print_error(AIS.name .. ' failed')
return
end
end
@@ -483,8 +492,8 @@ local function main(storage, image_table, extra_data)
local resp = dsys.external_command(run_cmd)
if resp ~= 0 then
remove_temp_files(images_to_remove)
dt.print_error(ENF.name.._(' failed'))
dt.print(ENF.name.._(' failed'))
dt.print_error(ENF.name..' failed')
dt.print(string.format(_("%s failed"), ENF.name))
return
end
@@ -729,7 +738,7 @@ GUI.ENF.hard_masks = dt.new_widget('check_button'){
GUI.ENF.save_masks = dt.new_widget('check_button'){
label = _('save masks'),
value = dt.preferences.read(mod, 'active_save_masks', 'bool'),
tooltip = _('Save the generated weight masks to your home directory,\nenblend saves masks as 8 bit grayscale, \ni.e. single channel images. \nfor accuracy we recommend to choose a lossless format.'),
tooltip = _('save the generated weight masks to your home directory,\nenblend saves masks as 8 bit grayscale, \ni.e. single channel images. \nfor accuracy we recommend to choose a lossless format.'),
clicked_callback = function(self) dt.preferences.write(mod, 'active_save_masks', 'bool', self.value) end,
reset_callback = function(self) self.value = false end
}
@@ -882,7 +891,7 @@ GUI.Target.output_directory = dt.new_widget('file_chooser_button'){
GUI.Target.source_location = dt.new_widget('check_button'){
label = _('save to source image location'),
value = dt.preferences.read(mod, 'active_source_location', 'bool'),
tooltip = _('If checked ignores the location above and saves output image(s) to the same location as the source images.'),
tooltip = _('if checked ignores the location above and saves output image(s) to the same location as the source images.'),
clicked_callback = function(self) dt.preferences.write(mod, 'active_source_location', 'bool', self.value) end,
reset_callback = function(self) self.value = true end
}
@@ -916,8 +925,8 @@ GUI.Target.auto_import = dt.new_widget('check_button'){
}
temp = dt.preferences.read(mod, 'active_apply_style_ind', 'integer')
GUI.Target.apply_style = dt.new_widget('combobox'){
label = _('Apply Style on Import'),
tooltip = _('Apply selected style on auto-import to newly created blended image'),
label = _('apply style on Import'),
tooltip = _('apply selected style on auto-import to newly created blended image'),
selected = 1,
'none',
changed_callback = function(self)
@@ -938,16 +947,16 @@ GUI.Target.apply_style.selected = temp
GUI.Target.copy_tags = dt.new_widget('check_button'){
label = _('copy tags'),
value = dt.preferences.read(mod, 'active_copy_tags', 'bool'),
tooltip = _('Copy tags from first image.'),
tooltip = _('copy tags from first image.'),
clicked_callback = function(self) dt.preferences.write(mod, 'active_copy_tags', 'bool', self.value) end,
reset_callback = function(self) self.value = true end
}
temp = dt.preferences.read(mod, 'active_add_tags', 'string')
if temp == '' then temp = nil end
GUI.Target.add_tags = dt.new_widget('entry'){
tooltip = _('Additional tags to be added on import. Seperate with commas, all spaces will be removed'),
tooltip = _('additional tags to be added on import, seperate with commas, all spaces will be removed'),
text = temp,
placeholder = 'Enter tags, seperated by commas',
placeholder = _('enter tags, seperated by commas'),
editable = true
}
temp = dt.preferences.read(mod, 'active_current_preset_ind', 'integer')

View File

@@ -33,23 +33,30 @@ local ds = require("lib/dtutils.system")
du.check_min_api_version("7.0.0", "exportLUT")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("exportLUT", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "exportLUT",
purpose = _("export a style as a LUT"),
author = "Noah Clarke",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/exportLUT"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local gettext = dt.gettext
gettext.bindtextdomain("exportLUT",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("exportLUT", msgid)
end
du.check_min_api_version("5.0.0", "exportLUT")
local eL = {}
@@ -64,13 +71,13 @@ local mkdir_command = 'mkdir -p '
if dt.configuration.running_os == 'windows' then mkdir_command = 'mkdir ' end
local file_chooser_button = dt.new_widget("file_chooser_button"){
title = _("Identity_file_chooser"),
title = _("identity_file_chooser"),
value = "",
is_directory = false
}
local export_chooser_button = dt.new_widget("file_chooser_button"){
title = _("Export_location_chooser"),
title = _("export_location_chooser"),
value = "",
is_directory = true
}
@@ -106,9 +113,9 @@ end
local function export_luts()
local identity = dt.database.import(file_chooser_button.value)
if(type(identity) ~= "userdata") then
dt.print(_("Invalid identity lut file"))
dt.print(_("invalid identity lut file"))
else
local job = dt.gui.create_job(_('Exporting styles as haldCLUTs'), true, end_job)
local job = dt.gui.create_job(_('exporting styles as haldCLUTs'), true, end_job)
local size = 1
@@ -127,9 +134,9 @@ local function export_luts()
io_lut:write_image(identity, output_path(style.name, job))
count = count + 1
job.percent = count / size
dt.print(_("Exported: ") .. output_path(style.name, job))
dt.print(string.format(_("exported: %s"), output_path(style.name, job)))
end
dt.print(_("Done exporting haldCLUTs"))
dt.print(_("done exporting haldCLUTs"))
job.valid = false
identity:reset()
end

View File

@@ -75,10 +75,26 @@ local dtsys = require "lib/dtutils.system"
local MODULE_NAME = "ext_editor"
du.check_min_api_version("7.0.0", MODULE_NAME)
-- translation
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("ext_editor", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "ext_editor",
purpose = _("edit images with external editors"),
author = "Marco Carrarini, marco.carrarini@gmail.com",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/ext_editor"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -94,13 +110,6 @@ ee.event_registered = false
ee.widgets = {}
-- translation
local gettext = dt.gettext
gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
end
-- maximum number of external programs, can be increased to necessity
local MAX_EDITORS = 9
@@ -156,7 +165,7 @@ local function UpdateProgramList(combobox, button_edit, button_edit_copy, update
button_edit.sensitive = active
button_edit_copy.sensitive = active
if update_button_pressed then dt.print(n_entries.._(" editors configured")) end
if update_button_pressed then dt.print(string.format(_("%d editors configured"), n_entries)) end
end
@@ -223,17 +232,17 @@ local function OpenWith(images, choice, copy)
-- physical copy, check result, return if error
local copy_success = df.file_copy(name, new_name)
if not copy_success then
dt.print(_("error copying file ")..name)
dt.print(string.format(_("error copying file %s"), name))
return
end
end
-- launch the external editor, check result, return if error
local run_cmd = bin.." "..df.sanitize_filename(new_name)
dt.print(_("launching ")..friendly_name.."...")
dt.print(string.format(_("launching %s..."), friendly_name))
local result = dtsys.external_command(run_cmd)
if result ~= 0 then
dt.print(_("error launching ")..friendly_name)
dt.print(string.format(_("error launching %s"), friendly_name))
return
end
@@ -326,7 +335,7 @@ local function export2collection(storage, image_table, extra_data)
-- move image to collection folder, check result, return if error
move_success = df.file_move(temp_name, new_name)
if not move_success then
dt.print(_("error moving file ")..temp_name)
dt.print(string.format(_("error moving file %s"), temp_name))
return
end
@@ -378,7 +387,7 @@ end
local function restart()
for i = 1, MAX_EDITORS do
dt.register_event(MODULE_NAME .. i, "shortcut",
program_shortcut, _("edit with program ")..string.format("%02d", i))
program_shortcut, string.format(_("edit with program %02d"), i))
end
dt.register_storage("exp2coll", _("collection"), nil, export2collection)
dt.gui.libs[MODULE_NAME].visible = true
@@ -476,11 +485,11 @@ dt.register_storage("exp2coll", _("collection"), nil, export2collection)
-- register the new preferences -----------------------------------------------
for i = MAX_EDITORS, 1, -1 do
dt.preferences.register(MODULE_NAME, "program_path_"..i, "file",
_("executable for external editor ")..i,
_("select executable for external editor") , _("(None)"))
string.format(_("executable for external editor %d"), i),
_("select executable for external editor") , _("(none)"))
dt.preferences.register(MODULE_NAME, "program_name_"..i, "string",
_("name of external editor ")..i,
string.format(_("name of external editor %d"), i),
_("friendly name of external editor"), "")
end
dt.preferences.register(MODULE_NAME, "show_in_darkrooom", "bool",
@@ -491,7 +500,7 @@ dt.preferences.register(MODULE_NAME, "show_in_darkrooom", "bool",
-- register the new shortcuts -------------------------------------------------
for i = 1, MAX_EDITORS do
dt.register_event(MODULE_NAME .. i, "shortcut",
program_shortcut, _("edit with program ")..string.format("%02d", i))
program_shortcut, string.format(_("edit with program %02d"), i))
end

View File

@@ -44,7 +44,7 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
-- constants
@@ -54,10 +54,23 @@ local OUTPUT = dt.configuration.tmp_dir .. PS .. "facerecognition.txt"
du.check_min_api_version("7.0.0", MODULE)
dt.gettext.bindtextdomain("face_recognition", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "face_recognition",
purpose = _("use facial recognition to tag images"),
author = "Sebastian Witt",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/face_recognition"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -69,13 +82,6 @@ local fc = {}
fc.module_installed = false
fc.event_registered = false
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("face_recognition", dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("face_recognition", msgid)
end
local function build_image_table(images)
local image_table = {}
local file_extension = ""
@@ -135,7 +141,7 @@ local function do_export(img_tbl, images)
job.percent = 0.0
for export,img in pairs(img_tbl) do
exp_cnt = exp_cnt + 1
dt.print(string.format(_("Exporting image %i of %i images"), exp_cnt, images))
dt.print(string.format(_("exporting image %i of %i images"), exp_cnt, images))
exporter:write_image(img, export, upsize)
job.percent = job.percent + percent_step
end
@@ -205,7 +211,7 @@ local function face_recognition ()
local bin_path = df.check_if_bin_exists("face_recognition")
if not bin_path then
dt.print(_("Face recognition not found"))
dt.print(_("face recognition not found"))
return
end
@@ -257,7 +263,7 @@ local function face_recognition ()
local command = bin_path .. " --cpus " .. nrCores .. " --tolerance " .. tolerance .. " " .. knownPath .. " " .. path .. " > " .. OUTPUT
os.setlocale()
dt.print_log("Face recognition: Running command: " .. command)
dt.print(_("Starting face recognition..."))
dt.print(_("starting face recognition..."))
dtsys.external_command(command)
@@ -265,9 +271,9 @@ local function face_recognition ()
local f = io.open(OUTPUT, "rb")
if not f then
dt.print(_("Face recognition failed"))
dt.print(_("face recognition failed"))
else
dt.print(_("Face recognition finished"))
dt.print(_("face recognition finished"))
f:close ()
end
@@ -399,7 +405,7 @@ fc.category_tags = dt.new_widget("entry"){
fc.tolerance = dt.new_widget("slider"){
label = _("tolerance"),
tooltip = ("detection tolerance - 0.6 default - lower if too many faces detected"),
tooltip = _("detection tolerance - 0.6 default - lower if too many faces detected"),
soft_min = 0.0,
hard_min = 0.0,
soft_max = 1.0,
@@ -482,12 +488,12 @@ table.insert(widgets, fc.num_cores)
table.insert(widgets, fc.export_format)
table.insert(widgets, dt.new_widget("box"){
orientation = "horizontal",
dt.new_widget("label"){ label = _("width ")},
dt.new_widget("label"){ label = _("width")},
fc.width,
})
table.insert(widgets, dt.new_widget("box"){
orientation = "horizontal",
dt.new_widget("label"){ label = _("height ")},
dt.new_widget("label"){ label = _("height")},
fc.height,
})
table.insert(widgets, fc.execute)

View File

@@ -60,13 +60,28 @@ cameras may behave in other ways.
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "fujifilm_dynamic_range")
dt.gettext.bindtextdomain("fujifilm_dynamic_range", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "fujifilm_dynamic_range",
purpose = _("compensate for Fujifilm raw files made using \"dynamic range\""),
author = "Dan Torop <dant@pnym.net>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/fujifilm_dynamic_range"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -111,6 +126,17 @@ local function detect_dynamic_range(event, image)
-- note that scene-referred workflow exposure preset also pushes exposure up by 0.5 EV
image.exif_exposure_bias = image.exif_exposure_bias + tonumber(raf_result)
dt.print_log("[fujifilm_dynamic_range] raw exposure bias " .. tostring(raf_result))
-- handle any duplicates
if #image:get_group_members() > 1 then
local basename = df.get_basename(image.filename)
local grouped_images = image:get_group_members()
for _, img in ipairs(grouped_images) do
if string.match(img.filename, basename) and img.duplicate_index > 0 then
-- its a duplicate
img.exif_exposure_bias = img.exif_exposure_bias + tonumber(raf_result)
end
end
end
end
local function destroy()

View File

@@ -26,26 +26,37 @@ Dependencies:
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "fujifilm_ratings")
dt.gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "fujifilm_ratings",
purpose = _("import Fujifilm in-camera ratings"),
author = "Ben Mendis <ben.mendis@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/fujifilm_ratings"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("fujifilm_ratings", msgid)
end
local function detect_rating(event, image)
if not string.match(image.filename, "%.RAF$") and not string.match(image.filename, "%.raf$") then
return
end
if not df.check_if_bin_exists("exiftool") then
dt.print_error(_("exiftool not found"))
return
@@ -53,25 +64,25 @@ local function detect_rating(event, image)
local RAF_filename = df.sanitize_filename(tostring(image))
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
local command = "exiftool -Rating " .. JPEG_filename
dt.print_error(command)
dt.print_log(command)
local output = io.popen(command)
local jpeg_result = output:read("*all")
output:close()
if string.len(jpeg_result) > 0 then
jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1")
image.rating = tonumber(jpeg_result)
dt.print_error(_("Using JPEG Rating: ") .. tostring(jpeg_result))
dt.print_log("using JPEG rating: " .. jpeg_result)
return
end
command = "exiftool -Rating " .. RAF_filename
dt.print_error(command)
dt.print_log(command)
output = io.popen(command)
local raf_result = output:read("*all")
output:close()
if string.len(raf_result) > 0 then
raf_result = string.gsub(raf_result, "^Rating.*(%d)", "%1")
image.rating = tonumber(raf_result)
dt.print_error(_("Using RAF Rating: ") .. tostring(raf_result))
dt.print_log("using RAF rating: " .. raf_result)
end
end

View File

@@ -35,26 +35,33 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "geoJSON_export")
dt.gettext.bindtextdomain("geoJSON_export", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "geoJSON_export",
purpose = _("export a geoJSON file from geo data"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/geoJSON_export"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("geoJSON_export",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("geoJSON_export", msgid)
end
-- Sort a table
local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua
-- collect the keys
@@ -80,7 +87,7 @@ local function spairs(_table, order) -- Code copied from http://stackoverflow.co
end
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data)
dt.print(string.format(_("Export Image %i/%i"), number, total))
dt.print(string.format(_("export image %i/%i"), number, total))
end
local function create_geoJSON_file(storage, image_table, extra_data)
@@ -309,19 +316,19 @@ dt.preferences.register("geoJSON_export",
"CreateMapBoxHTMLFile",
"bool",
_("geoJSON export: Create an additional HTML file"),
_("Creates a HTML file, that loads the geoJASON file. (Needs a MapBox key"),
_("creates an HTML file that loads the geoJSON file. (needs a MapBox key"),
false )
dt.preferences.register("geoJSON_export",
"mapBoxKey",
"string",
_("geoJSON export: MapBox Key"),
_("https://www.mapbox.com/studio/account/tokens"),
_("geoJSON export: MapBox key"),
"https://www.mapbox.com/studio/account/tokens",
'' )
dt.preferences.register("geoJSON_export",
"OpengeoJSONFile",
"bool",
_("geoJSON export: Open geoJSON file after export"),
_("Opens the geoJSON file after the export with the standard program for geoJSON files"),
_("geoJSON export: open geoJSON file after export"),
_("opens the geoJSON file after the export with the standard program for geoJSON files"),
false )
local handle = io.popen("xdg-user-dir DESKTOP")
@@ -333,8 +340,8 @@ end
dt.preferences.register("geoJSON_export",
"ExportDirectory",
"directory",
_("geoJSON export: Export directory"),
_("A directory that will be used to export the geoJSON files"),
_("geoJSON export: export directory"),
_("a directory that will be used to export the geoJSON files"),
result )
-- Register

View File

@@ -28,26 +28,33 @@ require "geoToolbox"
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "geoToolbox")
dt.gettext.bindtextdomain("geoToolbox", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "geoToolbox",
purpose = _("geodata tools"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/geoToolbox"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("geoToolbox",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("geoToolbox", msgid)
end
local gT = {}
gT.module_installed = false
@@ -56,7 +63,7 @@ gT.event_registered = false
-- <GUI>
local labelDistance = dt.new_widget("label")
labelDistance.label = _("Distance:")
labelDistance.label = _("distance:")
local label_copy_gps_lat = dt.new_widget("check_button")
{
@@ -300,9 +307,9 @@ local function copy_gps()
end
end
label_copy_gps_lat.label = _("latitude: ") .. copy_gps_latitude
label_copy_gps_lon.label = _("longitude: ") ..copy_gps_longitude
label_copy_gps_ele.label = _("elevation: ") .. copy_gps_elevation
label_copy_gps_lat.label = string.format(_("latitude: "), copy_gps_latitude)
label_copy_gps_lon.label = string.format(_("longitude: "),copy_gps_longitude)
label_copy_gps_ele.label = string.format(_("elevation: "), copy_gps_elevation)
return
end
@@ -488,12 +495,12 @@ local function calc_distance()
if (distance < 1) then
distance = distance * 1000
distanceUnit = _("m")
distanceUnit = "m"
else
distanceUnit = _("km")
distanceUnit = "km"
end
return string.format(_("Distance: %.2f %s"), distance, distanceUnit)
return string.format(_("distance: %.2f %s"), distance, distanceUnit)
end
local function print_calc_distance()
@@ -516,12 +523,12 @@ local altitude_filename = dt.new_widget("entry")
text = "altitude.csv",
placeholder = "altitude.csv",
editable = true,
tooltip = _("Name of the exported file"),
tooltip = _("name of the exported file"),
reset_callback = function(self) self.text = "text" end
}
local function altitude_profile()
dt.print(_("Start export"))
dt.print(_("start export"))
local sel_images = dt.gui.action_images
local lat1 = 0;
@@ -582,7 +589,7 @@ local function altitude_profile()
file = io.open(exportDirectory.."/"..exportFilename, "w")
file:write(csv_file)
file:close()
dt.print(_("File created in ")..exportDirectory)
dt.print(string.format(_("file created in %s"), exportDirectory))
end
@@ -612,14 +619,14 @@ end
local function restart()
dt.register_event("geoToolbox_cd", "shortcut",
print_calc_distance, _("Calculate the distance from latitude and longitude in km"))
print_calc_distance, _("calculate the distance from latitude and longitude in km"))
dt.register_event("geoToolbox", "mouse-over-image-changed",
toolbox_calc_distance)
dt.register_event("geoToolbox_wg", "shortcut",
select_with_gps, _("Select all images with GPS information"))
select_with_gps, _("select all images with GPS information"))
dt.register_event("geoToolbox_ng", "shortcut",
select_without_gps, _("Select all images without GPS information"))
select_without_gps, _("select all images without GPS information"))
dt.gui.libs["geoToolbox"].visible = true
end
@@ -642,20 +649,20 @@ gT.widget = dt.new_widget("box")
dt.new_widget("button")
{
label = _("select geo images"),
tooltip = _("Select all images with GPS information"),
tooltip = _("select all images with GPS information"),
clicked_callback = select_with_gps
},
dt.new_widget("button")
{
label = _("select non-geo images"),
tooltip = _("Select all images without GPS information"),
tooltip = _("select all images without GPS information"),
clicked_callback = select_without_gps
},
separator,--------------------------------------------------------
dt.new_widget("button")
{
label = _("copy GPS data"),
tooltip = _("Copy GPS data"),
tooltip = _("copy GPS data"),
clicked_callback = copy_gps
},
label_copy_gps_lat,
@@ -664,7 +671,7 @@ gT.widget = dt.new_widget("box")
dt.new_widget("button")
{
label = _("paste GPS data"),
tooltip = _("Paste GPS data"),
tooltip = _("paste GPS data"),
clicked_callback = paste_gps
},
separator2,--------------------------------------------------------
@@ -694,14 +701,14 @@ gT.widget = dt.new_widget("box")
dt.new_widget("button")
{
label = _("open in Gnome Maps"),
tooltip = _("Open location in Gnome Maps"),
tooltip = _("open location in Gnome Maps"),
clicked_callback = open_location_in_gnome_maps
},
separator4,--------------------------------------------------------
dt.new_widget("button")
{
label = _("reverse geocode"),
tooltip = _("This just shows the name of the location, but doesn't add it as tag"),
tooltip = _("this just shows the name of the location, but doesn't add it as tag"),
clicked_callback = reverse_geocode
},
separator5,--------------------------------------------------------
@@ -711,7 +718,7 @@ gT.widget = dt.new_widget("box")
dt.new_widget("button")
{
label = _("export altitude CSV file"),
tooltip = _("Create an altitude profile using the GPS data in the metadata"),
tooltip = _("create an altitude profile using the GPS data in the metadata"),
clicked_callback = altitude_profile
},
labelDistance
@@ -739,19 +746,19 @@ dt.preferences.register("geoToolbox",
"mapBoxKey",
"string",
_("geoToolbox export: MapBox Key"),
_("https://www.mapbox.com/studio/account/tokens"),
"https://www.mapbox.com/studio/account/tokens",
'' )
-- Register
dt.register_event("geoToolbox_cd", "shortcut",
print_calc_distance, _("Calculate the distance from latitude and longitude in km"))
print_calc_distance, _("calculate the distance from latitude and longitude in km"))
dt.register_event("geoToolbox", "mouse-over-image-changed",
toolbox_calc_distance)
dt.register_event("geoToolbox_wg", "shortcut",
select_with_gps, _("Select all images with GPS information"))
select_with_gps, _("select all images with GPS information"))
dt.register_event("geoToolbox_ng", "shortcut",
select_without_gps, _("Select all images without GPS information"))
select_without_gps, _("select all images without GPS information"))
script_data.destroy = destroy
script_data.restart = restart

View File

@@ -69,27 +69,33 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
local gimp_widget = nil
du.check_min_api_version("7.0.0", "gimp")
dt.gettext.bindtextdomain("gimp", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "gimp",
purpose = _("export and edit with GIMP"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/gimp"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("gimp",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("gimp", msgid)
end
local function group_if_not_member(img, new_img)
local image_table = img:get_group_members()
local is_member = false
@@ -109,7 +115,7 @@ end
local function show_status(storage, image, format, filename,
number, total, high_quality, extra_data)
dt.print(string.format(_("Export Image %i/%i"), number, total))
dt.print(string.format(_("export image %i/%i"), number, total))
end
local function gimp_edit(storage, image_table, extra_data) --finalize
@@ -119,7 +125,7 @@ local function gimp_edit(storage, image_table, extra_data) --finalize
local gimp_executable = df.check_if_bin_exists("gimp")
if not gimp_executable then
dt.print_error(_("GIMP not found"))
dt.print_error("GIMP not found")
return
end
@@ -142,7 +148,7 @@ local function gimp_edit(storage, image_table, extra_data) --finalize
img_list = img_list ..exp_img.. " "
end
dt.print(_("Launching GIMP..."))
dt.print(_("launching GIMP..."))
local gimpStartCommand
gimpStartCommand = gimp_executable .. " " .. img_list
@@ -213,7 +219,7 @@ gimp_widget = dt.new_widget("check_button"){
end
}
dt.register_storage("module_gimp", _("Edit with GIMP"), show_status, gimp_edit, nil, nil, gimp_widget)
dt.register_storage("module_gimp", _("edit with GIMP"), show_status, gimp_edit, nil, nil, gimp_widget)
--
script_data.destroy = destroy

View File

@@ -29,22 +29,28 @@ local gettext = dt.gettext
dl.check_min_api_version("7.0.0", "gpx_export")
gettext.bindtextdomain("gpx_export", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext("gpx_export", msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "gpx_export",
purpose = _("export gpx information to a file"),
author = "Jannis_V",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/gpx_export"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("gpx_export",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("gpx_export", msgid)
end
local gpx = {}
gpx.module_installed = false
gpx.event_registered = false
@@ -132,11 +138,11 @@ local function create_gpx_file()
local file = io.open(path, "w")
if (file == nil) then
dt.print(_("invalid path: ")..path)
dt.print(string.format(_("invalid path: %s"), path))
else
file:write(gpx_file)
file:close()
dt.print(_("gpx file created: ")..path)
dt.print(string.format(_("gpx file created: "), path))
end
end

View File

@@ -32,17 +32,30 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("2.0.0", "harmonic_armature_guide")
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("harmonic_armature_guide",dt.configuration.config_dir.."/lua/locale/")
dt.gettext.bindtextdomain("harmonic_armature_guide", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext("harmonic_armature_guide", msgid)
return gettext(msgid)
end
local script_data = {}
script_data.metadata = {
name = "harmonic_armature_guide",
purpose = _("harmonic artmature guide"),
author = "Hubert Kowalski",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/harmonic_armature_guide"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
dt.guides.register_guide("harmonic armature",
-- draw
function(cairo, x, y, width, height, zoom_scale)
@@ -76,3 +89,11 @@ function()
return dt.new_widget("label"){label = _("harmonic armature"), halign = "start"}
end
)
local function destroy()
-- nothing to destroy
end
script_data.destroy = destroy
return script_data

View File

@@ -58,30 +58,36 @@ local MODULE = "hif_group_leader"
du.check_min_api_version("7.0.0", MODULE)
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("hif_group_leader", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.metadata = {
name = "hif_group_leader",
purpose = _("make hif image group leader"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/hif_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain(MODULE, dt.configuration.config_dir .. "/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE, msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
@@ -182,7 +188,7 @@ dt.register_event(MODULE .. "_collect", "shortcut",
local images = dt.collection
make_existing_hif_group_leader(images)
end,
_("Make hif group leader for collection")
_("make hif group leader for collection")
)
dt.register_event(MODULE .. "_select", "shortcut",
@@ -190,7 +196,7 @@ dt.register_event(MODULE .. "_select", "shortcut",
local images = dt.gui.selection()
make_existing_hif_group_leader(images)
end,
_("Make hif group leader for selection")
_("make hif group leader for selection")
)
return script_data

View File

@@ -40,7 +40,7 @@ local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local log = require "lib/dtutils.log"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
local namespace = 'module_hugin'
local user_pref_str = 'prefer_gui'
@@ -56,22 +56,28 @@ local PQ = dt.configuration.running_os == "windows" and '"' or "'"
-- works with darktable API version from 5.0.0 on
du.check_min_api_version("7.0.0", "hugin")
dt.gettext.bindtextdomain("hugin", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "hugin",
purpose = _("stitch images into a panorama"),
author = "Wolfgang Goetz",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/hugin"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("hugin",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("hugin", msgid)
end
local function user_preference_changed(widget)
user_prefer_gui = widget.value
dt.preferences.write(namespace, user_pref_str, "bool", user_prefer_gui)
@@ -201,7 +207,7 @@ local function create_panorama(storage, image_table, extra_data) --finalize
if df.check_if_file_exists(src_path) then
log.msg(log.debug, "found ", src_path, " importing to ", dst_path)
df.file_move(src_path, dst_path)
dt.print(_("importing file "..dst_path))
dt.print(string.format(_("importing file %s"), dst_path))
dt.database.import(dst_path)
end
end
@@ -227,7 +233,7 @@ hugin_widget = dt.new_widget("box") {
orientation = "vertical",
dt.new_widget("check_button")
{
label = _(" launch hugin gui"),
label = _("launch hugin gui"),
value = user_prefer_gui,
tooltip = _('launch hugin in gui mode'),
clicked_callback = user_preference_changed

View File

@@ -64,7 +64,7 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
local job = nil
-- path separator constant
@@ -73,22 +73,28 @@ local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- works with LUA API version 5.0.0
du.check_min_api_version("7.0.0", "image_stack")
dt.gettext.bindtextdomain("image_stack", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "image_stack",
purpose = _("process a stack of images"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/image_stack"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("image_stack",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("image_stack", msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- GUI definitions
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -259,7 +265,7 @@ end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data)
dt.print(string.format(_("Export Image %i/%i"), number, total))
dt.print(string.format(_("export image %i/%i"), number, total))
end
-- read the gui and populate the align_image_stack arguments
@@ -452,7 +458,7 @@ local function copy_image_attributes(from, to, ...)
to.rights = from.rights
to.description = from.description
else
dt.print_error(_("Unrecognized option to copy_image_attributes: " .. arg))
dt.print_error("Unrecognized option to copy_image_attributes: " .. arg)
end
end
end
@@ -496,7 +502,7 @@ local function image_stack(storage, image_table, extra_data)
if image_count < 2 then
dt.print(_("ERROR: at least 2 images required for image stacking, exiting..."))
dt.print_error(_(image_count .. " image(s) selected, at least 2 required"))
dt.print_error(image_count .. " image(s) selected, at least 2 required")
return
end
@@ -520,13 +526,13 @@ local function image_stack(storage, image_table, extra_data)
job.percent = job.percent + percent_step
else
dt.print(_("ERROR: image alignment failed"))
dt.print_error(_("image alignment failed"))
dt.print_error("image alignment failed")
cleanup(img_list)
return
end
else
dt.print(_("ERROR: align_image_stack not found"))
dt.print_error(_("align_image_stack not found"))
dt.print_error("align_image_stack not found")
cleanup(img_list)
return
end
@@ -540,7 +546,7 @@ local function image_stack(storage, image_table, extra_data)
local ignore_tif_tags = " -quiet -define tiff:ignore-tags=40965,42032,42033,42034,42036,18246,18249,36867,34864,34866 "
if convert_executable then
local convert_command = convert_executable .. ignore_tif_tags .. convert_arguments
dt.print_log(_("convert command is " .. convert_command))
dt.print_log("convert command is " .. convert_command)
dt.print(_("processing image stack"))
local result = dtsys.external_command(convert_command)
if result == 0 then
@@ -554,7 +560,7 @@ local function image_stack(storage, image_table, extra_data)
local import_filename = df.create_unique_filename(film_roll_path .. PS .. df.get_filename(output_filename))
df.file_move(output_filename, import_filename)
imported_image = dt.database.import(import_filename)
local created_tag = dt.tags.create(_("Created with|image_stack"))
local created_tag = dt.tags.create(_("created with|image_stack"))
dt.tags.attach(created_tag, imported_image)
-- all the images are the same except for time, so just copy the attributes
-- from the first
@@ -568,7 +574,7 @@ local function image_stack(storage, image_table, extra_data)
if tag_source then
dt.print(_("tagging source images"))
local source_tag = dt.tags.create(_("Source file|" .. imported_image.filename))
local source_tag = dt.tags.create(_("source file|" .. imported_image.filename))
for img, _ in pairs(image_table) do
dt.tags.attach(source_tag, img)
end
@@ -580,7 +586,7 @@ local function image_stack(storage, image_table, extra_data)
end
else
dt.print(_("ERROR: convert executable not found"))
dt.print_error(_("convert executable not found"))
dt.print_error("convert executable not found")
cleanup(img_list)
end
job.valid = false
@@ -592,7 +598,7 @@ end
dt.preferences.register("align_image_stack", "align_use_gpu", -- name
"bool", -- type
_('align image stack: use GPU for remaping'), -- label
_('align image stack: use GPU for remapping'), -- label
_('set the GPU remapping for image align'), -- tooltip
false)

View File

@@ -107,7 +107,8 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local ds = require "lib/dtutils.string"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
local img_time = {}
img_time.module_installed = false
@@ -115,22 +116,29 @@ img_time.event_registered = false
du.check_min_api_version("7.0.0", "image_time")
dt.gettext.bindtextdomain("image_time", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "image_time",
purpose = _("synchronize image time for images shot with different cameras or adjust or set image time"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/image_time"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("image_time",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("image_time", msgid)
end
local PS = dt.configuration.runnin_os == "windows" and "\\" or "/"
local ERROR = -1
@@ -175,7 +183,7 @@ local function calculate_difference(images)
img_time.diff_entry.text = calc_time_difference(images[1], images[2])
img_time.btn.sensitive = true
else
dt.print(_("Error: 2 images must be selected"))
dt.print(_("ERROR: 2 images must be selected"))
end
end
@@ -249,7 +257,7 @@ local function _get_windows_image_file_creation_time(image)
end
p:close()
else
dt.print(_("unable to get information for ") .. image.filename)
dt.print(string.format(_("unable to get information for %s"), image.filename))
datetime = ERROR
end
return datetime
@@ -266,7 +274,7 @@ local function _get_nix_image_file_creation_time(image)
end
p:close()
else
dt.print(_("unable to get information for ") .. image.filename)
dt.print(string.format(_("unable to get information for %s"), image.filename))
datetime = ERROR
end
return datetime
@@ -314,7 +322,7 @@ local function reset_time(images)
image.exif_datetime_taken = get_original_image_time(image)
end
else
dt.print_error(_("reset time: no images selected"))
dt.print_error("reset time: no images selected")
dt.print(_("please select the images that need their time reset"))
end
end
@@ -430,8 +438,8 @@ end
img_time.widgets = {
-- name, type, tooltip, placeholder,
{"ayr", "combobox", _("years"), _("years to adjust by, 0 - ?"), {seq(0,20)}, 1},
{"amo", "combobox", _("months"), ("months to adjust by, 0-12"), {seq(0,12)}, 1},
{"ady", "combobox", _("days"), ("days to adjust by, 0-31"), {seq(0,31)}, 1},
{"amo", "combobox", _("months"), _("months to adjust by, 0-12"), {seq(0,12)}, 1},
{"ady", "combobox", _("days"), _("days to adjust by, 0-31"), {seq(0,31)}, 1},
{"ahr", "combobox", _("hours"), _("hours to adjust by, 0-23"), {seq(0,23)}, 1},
{"amn", "combobox", _("minutes"), _("minutes to adjust by, 0-59"), {seq(0,59)}, 1},
{"asc", "combobox", _("seconds"), _("seconds to adjust by, 0-59"), {seq(0,59)}, 1},
@@ -457,13 +465,13 @@ end
img_time.syr.selected = #img_time.syr
img_time.diff_entry = dt.new_widget("entry"){
tooltip = _("Time difference between images in seconds"),
placeholder = _("Select 2 images and use the calculate button"),
tooltip = _("time difference between images in seconds"),
placeholder = _("select 2 images and use the calculate button"),
text = "",
}
img_time.calc_btn = dt.new_widget("button"){
label = _("Calculate"),
label = _("calculate"),
tooltip = _("calculate time difference between 2 images"),
clicked_callback = function()
calculate_difference(dt.gui.action_images)

View File

@@ -58,30 +58,36 @@ local MODULE = "jpg_group_leader"
du.check_min_api_version("7.0.0", MODULE)
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("jpg_group_leader", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.metadata = {
name = "jpg_group_leader",
purpose = _("make jpg image group leader"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/jpg_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain(MODULE, dt.configuration.config_dir .. "/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE, msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
@@ -182,7 +188,7 @@ dt.register_event(MODULE .. "_collect", "shortcut",
local images = dt.collection
make_existing_jpg_group_leader(images)
end,
_("Make jpg group leader for collection")
_("make jpg group leader for collection")
)
dt.register_event(MODULE .. "_select", "shortcut",
@@ -190,7 +196,7 @@ dt.register_event(MODULE .. "_select", "shortcut",
local images = dt.gui.selection()
make_existing_jpg_group_leader(images)
end,
_("Make jpg group leader for selection")
_("make jpg group leader for selection")
)
return script_data

View File

@@ -39,30 +39,36 @@ local df = require "lib/dtutils.file"
local ds = require "lib/dtutils.string"
local dsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
du.check_min_api_version("7.0.0", "kml_export")
dt.gettext.bindtextdomain("kml_export", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "kml_export",
purpose = _("export KML/KMZ data to a file"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/kml_export"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("kml_export",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("kml_export", msgid)
end
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data)
dt.print(string.format(_("Export Image %i/%i"), number, total))
dt.print(string.format(_("export image %i/%i"), number, total))
end
-- Add duplicate index to filename
@@ -320,14 +326,14 @@ if dt.configuration.running_os == "windows" then
"OpenKmlFile",
"bool",
_("KML export: Open KML file after export"),
_("Opens the KML file after the export with the standard program for KML files"),
_("opens the KML file after the export with the standard program for KML files"),
false )
else
dt.preferences.register("kml_export",
"OpenKmlFile",
"bool",
_("KML export: Open KML/KMZ file after export"),
_("Opens the KML file after the export with the standard program for KML files"),
_("KML export: open KML/KMZ file after export"),
_("opens the KML file after the export with the standard program for KML files"),
false )
end
@@ -346,23 +352,23 @@ end
dt.preferences.register("kml_export",
"ExportDirectory",
"directory",
_("KML export: Export directory"),
_("A directory that will be used to export the KML/KMZ files"),
_("KML export: export directory"),
_("a directory that will be used to export the KML/KMZ files"),
defaultDir )
if dt.configuration.running_os ~= "linux" then
dt.preferences.register("kml_export",
"magickPath", -- name
"file", -- type
_("KML export: ImageMagick binary Location"), -- label
_("Install location of magick[.exe]. Requires restart to take effect."), -- tooltip
_("KML export: ImageMagick binary location"), -- label
_("install location of magick[.exe], requires restart to take effect"), -- tooltip
"magick") -- default
end
dt.preferences.register("kml_export",
"CreatePath",
"bool",
_("KML export: Connect images with path"),
_("KML export: connect images with path"),
_("connect all images with a path"),
false )
@@ -370,16 +376,16 @@ if dt.configuration.running_os == "linux" then
dt.preferences.register("kml_export",
"CreateKMZ",
"bool",
_("KML export: Create KMZ file"),
_("Compress all imeges to one KMZ file"),
_("KML export: create KMZ file"),
_("compress all imeges to one KMZ file"),
true )
end
-- Register
if dt.configuration.running_os == "windows" then
dt.register_storage("kml_export", _("KML Export"), nil, create_kml_file)
dt.register_storage("kml_export", _("KML export"), nil, create_kml_file)
else
dt.register_storage("kml_export", _("KML/KMZ Export"), nil, create_kml_file)
dt.register_storage("kml_export", _("KML/KMZ export"), nil, create_kml_file)
end
script_data.destroy = destroy

View File

@@ -37,17 +37,30 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("2.0.0", "passport_guide")
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("passport_guide",dt.configuration.config_dir.."/lua/locale/")
dt.gettext.bindtextdomain("passport_guide", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext("passport_guide", msgid)
return gettext(msgid)
end
local script_data = {}
script_data.metadata = {
name = "passport_guide",
purpose = _("guides for cropping passport photos"),
author = "Kåre Hampf",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/passport_guide"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
dt.guides.register_guide("passport",
-- draw
function(cairo, x, y, width, height, zoom_scale)
@@ -91,5 +104,13 @@ function()
end
)
local function destroy()
-- nothing to destroy
end
script_data.destroy = destroy
return script_data
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on; hl Lua;
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

View File

@@ -45,12 +45,26 @@ local gettext = dt.gettext
du.check_min_api_version("2.0.0", "passport_guide_germany")
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("passport_guide_germany",dt.configuration.config_dir.."/lua/locale/")
dt.gettext.bindtextdomain("passport_guide_germany",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("passport_guide_germany", msgid)
end
local script_data = {}
script_data.metadata = {
name = "passport_guide_germany",
purpose = _("guides for cropping passport and ID card (\"Personalausweis\") photos based on the \"Passbild-Schablone\" from the German Federal Ministry of the Interior and Community"),
author = "menschmachine",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/passport_guide_germany"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
dt.guides.register_guide("Passport Photo Germany",
-- draw
function(cairo, x, y, width, height, zoom_scale)
@@ -101,5 +115,13 @@ function()
end
)
local function destroy()
-- noting to destroy
end
script_data.destroy = destroy
return script_data
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on; hl Lua;
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

View File

@@ -42,17 +42,16 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("pdf_slideshow",dt.configuration.config_dir.."/lua/locale/")
dt.gettext.bindtextdomain("pdf_slideshow", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext("pdf_slideshow", msgid)
return gettext(msgid)
end
if not df.check_if_bin_exists("pdflatex") then
dt.print_error(_("pdflatex not found"))
dt.print_error("pdflatex not found")
return
end
@@ -62,6 +61,13 @@ du.check_min_api_version("7.0.0", "pdf_slideshow")
local script_data = {}
script_data.metadata = {
name = "pdf_slideshow",
purpose = _("generates a PDF slideshow (via Latex) containing all selected images one per slide"),
author = "Pascal Obry",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/pdf_slideshow"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -231,7 +237,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
local result = dt.control.execute(command)
if result ~= 0 then
dt.print(_("problem running pdflatex")) -- this one is probably usefull to the user
error(_("problem running ")..command)
error("problem running "..command)
end
-- open the PDF
@@ -241,7 +247,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
local result = dt.control.execute(command)
if result ~= 0 then
dt.print(_("problem running pdf viewer")) -- this one is probably usefull to the user
error(_("problem running ")..command)
error("problem running "..command)
end
-- finally do some clean-up

View File

@@ -44,10 +44,24 @@ local dtsys = require "lib/dtutils.system"
local MODULE_NAME = "photils"
du.check_min_api_version("7.0.0", MODULE_NAME)
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("photils", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "photils",
purpose = _("suggest tags based on image classification"),
author = "Tobias Scheck",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/photils"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -55,9 +69,6 @@ script_data.show = nil -- only required for libs since the destroy_method only h
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local gettext = dt.gettext
gettext.bindtextdomain(MODULE_NAME,
dt.configuration.config_dir .. PS .. "lua" .. PS .. "locale" .. PS)
local exporter = dt.new_format("jpeg")
exporter.quality = 80
@@ -66,10 +77,6 @@ exporter.max_width = 224
-- helper functions
local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
end
local function num_keys(tbl)
local num = 0
for _ in pairs(tbl) do num = num + 1 end
@@ -178,7 +185,7 @@ function PHOTILS.image_changed()
end
function PHOTILS.tagged_image_has_changed()
GUI.warning.label = _("The suggested tags were not generated\n for the currently selected image!")
GUI.warning.label = _("the suggested tags were not generated\n for the currently selected image!")
end
function PHOTILS.paginate()
@@ -235,7 +242,7 @@ end
function PHOTILS.attach_tags()
local num_selected = #dt.gui.selection()
local job = dt.gui.create_job(_("Apply tag to image"), true)
local job = dt.gui.create_job(_("apply tag to image"), true)
for i = 1, num_selected, 1 do
local image = dt.gui.selection()[i]
@@ -247,7 +254,7 @@ function PHOTILS.attach_tags()
job.percent = i / num_selected
end
dt.print(_("Tags successfully attached to image"))
dt.print(_("tags successfully attached to image"))
job.valid = false
end
@@ -313,11 +320,11 @@ function PHOTILS.on_tags_clicked()
local images = dt.gui.selection()
if #images == 0 then
dt.print(_("No image selected."))
dt.print(_("no image selected."))
dt.control.sleep(2000)
else
if #images > 1 then
dt.print(_("This plugin can only handle a single image."))
dt.print(_("this plugin can only handle a single image."))
dt.gui.selection({images[1]})
dt.control.sleep(2000)
end
@@ -428,9 +435,9 @@ end
if not photils_installed then
GUI.warning_label.label = _("photils-cli not found")
dt.print_log(_("photils-cli not found"))
dt.print_log("photils-cli not found")
else
GUI.warning_label.label = _("Select an image, click \"get tags\" and get \nsuggestions for tags.")
GUI.warning_label.label = _("select an image, click \"get tags\" and get \nsuggestions for tags.")
end
GUI.pagination = dt.new_widget("box") {
@@ -473,9 +480,9 @@ dt.preferences.register(MODULE_NAME,
"export_image_before_for_tags",
"bool",
_("photils: use exported image for tag request"),
_("If enabled, the image passed to photils for tag suggestion is based on the exported, already edited image. " ..
"Otherwise, the embedded thumbnail of the RAW file will be used for tag suggestion." ..
"The embedded thumbnail could speedup the tag suggestion but can fail if the RAW file is not supported."),
_("if enabled, the image passed to photils for tag suggestion is based on the exported, already edited image. " ..
"otherwise, the embedded thumbnail of the RAW file will be used for tag suggestion." ..
"the embedded thumbnail could speedup the tag suggestion but can fail if the RAW file is not supported."),
true)
dt.register_event("photils", "mouse-over-image-changed",

View File

@@ -49,10 +49,25 @@ local debug = require "darktable.debug"
du.check_min_api_version("7.0.0", "quicktag")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("quicktag", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "quicktag",
purpose = _("use buttons to quickly apply tags assigned to them"),
author = "Christian Kanzian",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/quicktag"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -62,15 +77,6 @@ qt.module_installed = false
qt.event_registered = false
qt.widget_table = {}
local gettext = dt.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("quicktag",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("quicktag", msgid)
end
-- maximum length of button labels
dt.preferences.register("quickTag",
"labellength",

View File

@@ -44,10 +44,25 @@ local du = require "lib/dtutils"
-- added version check
du.check_min_api_version("7.0.0", "rate_group")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("rate_group", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "rate_group",
purpose = _("rate all images in a group"),
author = "Dom H (dom@hxy.io)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rate_group"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -62,9 +77,9 @@ local function apply_rating(rating)
end
end
if rating < 0 then
dt.print("rejecting group(s)")
dt.print(_("rejecting group(s)"))
else
dt.print("applying rating " ..rating.. " to group(s)")
dt.print(string.format(_("applying rating %d to group(s)"), rating))
end
end
@@ -81,37 +96,38 @@ end
dt.register_event("rg_reject", "shortcut",
function(event, shortcut)
apply_rating(-1)
end, "Reject group")
end, _("reject group"))
dt.register_event("rg0", "shortcut",
function(event, shortcut)
apply_rating(0)
end, "Rate group 0")
end, string.format(_("rate group %d"), 0)
)
dt.register_event("rg1", "shortcut",
function(event, shortcut)
apply_rating(1)
end, "Rate group 1")
end, string.format(_("rate group %d"), 1))
dt.register_event("rg2", "shortcut",
function(event, shortcut)
apply_rating(2)
end, "Rate group 2")
end, string.format(_("rate group %d"), 2))
dt.register_event("rg3", "shortcut",
function(event, shortcut)
apply_rating(3)
end, "Rate group 3")
end, string.format(_("rate group %d"), 3))
dt.register_event("rg4", "shortcut",
function(event, shortcut)
apply_rating(4)
end, "Rate group 4")
end, string.format(_("rate group %d"), 4))
dt.register_event("rg5", "shortcut",
function(event, shortcut)
apply_rating(5)
end, "Rate group 5")
end, string.format(_("rate group %d"), 5))
script_data.destroy = destroy

View File

@@ -36,10 +36,25 @@ local debug = require "darktable.debug"
du.check_min_api_version("7.0.0", "rename-tags")
du.deprecated("contrib/rename-tags.lua","darktable release 4.0")
local gettext = darktable.gettext.gettext
darktable.gettext.bindtextdomain("rename-tags", darktable.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "rename-tags",
purpose = _("rename an existing tag"),
author = "Sebastian Witt (se.witt@gmx.net)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rename-tags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -50,8 +65,8 @@ rt.module_installed = false
rt.event_registered = false
-- GUI entries
local old_tag = darktable.new_widget("entry") { tooltip = "Enter old tag" }
local new_tag = darktable.new_widget("entry") { tooltip = "Enter new tag" }
local old_tag = darktable.new_widget("entry") { tooltip = _("enter old tag") }
local new_tag = darktable.new_widget("entry") { tooltip = _("enter new tag") }
local function rename_reset()
old_tag.text = ''
@@ -62,11 +77,11 @@ end
local function rename_tags()
-- If entries are empty, return
if old_tag.text == '' then
darktable.print ("Old tag can't be empty")
darktable.print (_("old tag can't be empty"))
return
end
if new_tag.text == '' then
darktable.print ("New tag can't be empty")
darktable.print (_("new tag can't be empty"))
return
end
@@ -76,12 +91,12 @@ local function rename_tags()
local ot = darktable.tags.find (old_tag.text)
if not ot then
darktable.print ("Old tag does not exist")
darktable.print (_("old tag does not exist"))
return
end
-- Show job
local job = darktable.gui.create_job ("Renaming tag", true)
local job = darktable.gui.create_job (_("renaming tag"), true)
old_tag.editable = false
new_tag.editable = false
@@ -104,7 +119,7 @@ local function rename_tags()
darktable.tags.delete (ot)
job.valid = false
darktable.print ("Renamed tags for " .. count .. " images")
darktable.print (string.format(_("renamed tags for %d images"), count))
old_tag.editable = true
new_tag.editable = true
@@ -115,7 +130,7 @@ end
local function install_module()
if not rt.module_installed then
darktable.register_lib ("rename_tags", "rename tag", true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rt.rename_widget, nil, nil)
darktable.register_lib ("rename_tags", _("rename tag"), true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rt.rename_widget, nil, nil)
rt.module_installed = true
end
end
@@ -131,13 +146,13 @@ end
-- GUI
local old_widget = darktable.new_widget ("box") {
orientation = "horizontal",
darktable.new_widget("label") { label = "Old tag" },
darktable.new_widget("label") { label = _("old tag") },
old_tag
}
local new_widget = darktable.new_widget ("box") {
orientation = "horizontal",
darktable.new_widget("label") { label = "New tag" },
darktable.new_widget("label") { label = _("new tag") },
new_tag
}
@@ -146,7 +161,7 @@ rt.rename_widget = darktable.new_widget ("box") {
reset_callback = rename_reset,
old_widget,
new_widget,
darktable.new_widget("button") { label = "Go", clicked_callback = rename_tags }
darktable.new_widget("button") { label = _("go"), clicked_callback = rename_tags }
}
if darktable.gui.current_view().id == "lighttable" then

View File

@@ -46,13 +46,12 @@ local df = require "lib/dtutils.file"
du.check_min_api_version("7.0.0", "rename_images")
local gettext = dt.gettext
local gettext = dt.gettext.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("rename_images",dt.configuration.config_dir.."/lua/locale/")
dt.gettext.bindtextdomain("rename_images", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext("rename_images", msgid)
return gettext(msgid)
end
-- namespace variable
@@ -72,6 +71,13 @@ rename.event_registered = false
-- script_manager integration
local script_data = {}
script_data.metadata = {
name = "rename_images",
purpose = _("rename an image file or files"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rename_images"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -86,7 +92,7 @@ local MODULE_NAME = "rename_images"
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local USER = os.getenv("USERNAME")
local HOME = os.getenv(dt.configuration.running_os == "windows" and "HOMEPATH" or "HOME")
local PICTURES = HOME .. PS .. dt.configuration.running_os == "windows" and "My Pictures" or "Pictures"
local PICTURES = HOME .. PS .. dt.configuration.running_os == "windows" and _("My Pictures") or _("Pictures")
local DESKTOP = HOME .. PS .. "Desktop"
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -158,8 +164,8 @@ local function substitute_list(str)
if rename.substitutes[var] then
str = string.gsub(str, "%$%("..var.."%)", rename.substitutes[var])
else
dt.print_error(_("unrecognized variable " .. var))
dt.print(_("unknown variable " .. var .. ", aborting..."))
dt.print_error("unrecognized variable " .. var)
dt.print(string.format(_("unknown variable %s, aborting..."), var))
return -1
end
end
@@ -208,9 +214,10 @@ end
local function do_rename(images)
if #images > 0 then
local first_image = images[1]
local pattern = rename.widgets.pattern.text
dt.preferences.write(MODULE_NAME, "pattern", "string", pattern)
dt.print_log(_("pattern is " .. pattern))
dt.print_log("pattern is " .. pattern)
if string.len(pattern) > 0 then
local datetime = os.date("*t")
@@ -250,7 +257,8 @@ local function do_rename(images)
stop_job(job)
local collect_rules = dt.gui.libs.collect.filter()
dt.gui.libs.collect.filter(collect_rules)
dt.print(_("renamed " .. #images .. " images"))
dt.gui.views.lighttable.set_image_visible(first_image)
dt.print(string.format(_("renamed %d images"), #images))
else -- pattern length
dt.print_error("no pattern supplied, returning...")
dt.print(_("please enter the new name or pattern"))

View File

@@ -29,11 +29,12 @@ du.check_min_api_version("9.1.0", MODULE)
-- figure out the path separator
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local gettext = dt.gettext
gettext.bindtextdomain(MODULE, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("select_non_existing", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE, msgid)
return gettext(msgid)
end
local function stop_job(job)
@@ -73,5 +74,13 @@ dt.gui.libs.select.register_selection(
_("select all non-existing images in the current images"))
local script_data = {}
script_data.metadata = {
name = "select_non_existing",
purpose = _("enable selection of non-existing images"),
author = "Dirk Dittmar",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/select_non_existing"
}
script_data.destroy = destroy
return script_data

View File

@@ -20,26 +20,32 @@ Enable selection of untagged images (darktable|* tags are ignored)
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "select_untagged")
dt.gettext.bindtextdomain("select_untagged", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "select_untagged",
purpose = _("enable selection of untagged images"),
author = "Jannis_V",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/select_untagged"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("select_untagged",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("select_untagged", msgid)
end
local function stop_job(job)
job.valid = false
end

View File

@@ -27,26 +27,32 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "slideshowMusic")
dt.gettext.bindtextdomain("slideshowMusic", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "slideshowMusic",
purpose = _("play music during a slideshow"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/slideshowMusic"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("slideshowMusic",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("slideshowMusic", msgid)
end
local function playSlideshowMusic(_, old_view, new_view)
local filename, playMusic
@@ -54,7 +60,7 @@ local function playSlideshowMusic(_, old_view, new_view)
playMusic = dt.preferences.read("slideshowMusic","PlaySlideshowMusic","bool")
if not df.check_if_bin_exists("rhythmbox-client") then
dt.print_error(_("rhythmbox-client not found"))
dt.print_error("rhythmbox-client not found")
return
end
@@ -70,7 +76,7 @@ local function playSlideshowMusic(_, old_view, new_view)
if (old_view and old_view.id == "slideshow") then
stopCommand = "rhythmbox-client --pause"
--dt.print_error(stopCommand)
dt.control.execute( stopCommand)
dt.control.execute(stopCommand)
end
end
end
@@ -83,12 +89,12 @@ function destroy()
end
-- Preferences
dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", _("Slideshow background music file"), "", "")
dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", _("slideshow background music file"), "", "")
dt.preferences.register("slideshowMusic",
"PlaySlideshowMusic",
"bool",
_("Play slideshow background music"),
_("Plays music with rhythmbox if a slideshow starts"),
_("play slideshow background music"),
_("plays music with rhythmbox if a slideshow starts"),
true)
-- Register
dt.register_event("slideshow_music", "view-changed",

View File

@@ -80,10 +80,23 @@ local dtutils_system = require("lib/dtutils.system")
local LIB_ID = "transfer_hierarchy"
dtutils.check_min_api_version("7.0.0", LIB_ID)
darktable.gettext.bindtextdomain("transfer_hierarchy", darktable.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return darktable.gettext.gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "transfer_hierarchy",
purpose = _("allows the moving or copying of images from one directory tree to another, while preserving the existing hierarchy"),
author = "August Schwerdfeger (august@schwerdfeger.name)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/transfer_hierarchy"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -96,12 +109,6 @@ local PATH_SEGMENT_REGEX = "(" .. PATH_SEPARATOR .. "?)([^" .. PATH_SEPARATOR ..
unpack = unpack or table.unpack
gmatch = string.gfind or string.gmatch
darktable.gettext.bindtextdomain(LIB_ID, darktable.configuration.config_dir .. PATH_SEPARATOR .. "lua" .. PATH_SEPARATOR .. "locale" .. PATH_SEPARATOR)
local function _(msgid)
return darktable.gettext.dgettext(LIB_ID, msgid)
end
-- Header material: END
@@ -151,7 +158,7 @@ end
-- Widgets and business logic: BEGIN
local sourceTextBox = darktable.new_widget("entry") {
tooltip = _("Lowest directory containing all selected images"),
tooltip = _("lowest directory containing all selected images"),
editable = false
}
sourceTextBox.reset_callback = function() sourceTextBox.text = "" end
@@ -268,17 +275,17 @@ local function doTransfer(transferFunc)
films[film] = destBase .. string.sub(film.path, #sourceBase+1)
if not pathExists(films[film]) then
if createDirectory(films[film]) == nil then
darktable.print(_("transfer hierarchy: ERROR: could not create directory: " .. films[film]))
darktable.print(string.format(_("transfer hierarchy: ERROR: could not create directory: %s"), films[film]))
return
end
end
if not pathIsDirectory(films[film]) then
darktable.print(_("transfer hierarchy: ERROR: not a directory: " .. films[film]))
darktable.print(string.format(_("transfer hierarchy: ERROR: not a directory: %s"), films[film]))
return
end
destFilms[film] = darktable.films.new(films[film])
if destFilms[film] == nil then
darktable.print(_("transfer hierarchy: ERROR: could not create film: " .. film.path))
darktable.print(string.format(_("transfer hierarchy: ERROR: could not create film: %s"), film.path))
end
end
@@ -287,7 +294,7 @@ local function doTransfer(transferFunc)
srcFilms[img] = img.film
end
local job = darktable.gui.create_job(string.format(_("transfer hierarchy") .. " (%d image" .. (#(darktable.gui.action_images) == 1 and "" or "s") .. ")", #(darktable.gui.action_images)), true, stopTransfer)
local job = darktable.gui.create_job(string.format(_("transfer hierarchy (%d image%s)"), #(darktable.gui.action_images), (#(darktable.gui.action_images) == 1 and "" or "s")), true, stopTransfer)
job.percent = 0.0
local pctIncrement = 1.0 / #(darktable.gui.action_images)
for _,img in ipairs(darktable.gui.action_images) do
@@ -345,7 +352,7 @@ th.transfer_widget = darktable.new_widget("box") {
},
darktable.new_widget("button") {
label = _("copy"),
tooltip = _("Copy all selected images"),
tooltip = _("copy all selected images"),
clicked_callback = doCopy
}
}

View File

@@ -37,14 +37,27 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "video_ffmpeg")
dt.gettext.bindtextdomain("video_ffmpeg", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "video_ffmpeg",
purpose = _("timelapse video plugin based on ffmpeg"),
author = "Dominik Markiewicz",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contib/video_ffmpeg"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -53,12 +66,6 @@ script_data.show = nil -- only required for libs since the destroy_method only h
local MODULE_NAME = "video_ffmpeg"
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
end
---- DECLARATIONS
@@ -294,7 +301,7 @@ else
end
local output_directory_chooser = dt.new_widget("file_chooser_button"){
title = _("Select export path"),
title = _("select export path"),
is_directory = true,
tooltip =_("select the target directory for the timelapse. \nthe filename is created automatically."),
value = string_pref_read("export_path", defaultVideoDir),
@@ -375,7 +382,7 @@ local module_widget = dt.new_widget("box") {
---- EXPORT & REGISTRATION
local function show_status(enf_storage, image, format, filename, number, total, high_quality, extra_data)
dt.print(_("export ")..tostring(number).." / "..tostring(total))
dt.print(string.format(_("export %d / %d", number), total))
end
local function init_export(storage, img_format, images, high_quality, extra_data)
@@ -465,7 +472,7 @@ end
dt.register_storage(
"module_video_ffmpeg",
_(MODULE_NAME),
_("video ffmpeg"),
show_status,
finalize_export,
nil,

BIN
data/icons/blank20.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
data/icons/path20.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@@ -23,6 +23,16 @@ USAGE
]]
local dt = require "darktable"
-- translation facilities
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("api_version", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- script_manager integration to allow a script to be removed
-- without restarting darktable
local function destroy()
@@ -30,12 +40,21 @@ local function destroy()
end
local result = dt.configuration.api_version_string
dt.print_error("API Version: "..result)
dt.print_log("API Version: " .. result)
dt.print(string.format(_("API version: %s"), result))
-- set the destroy routine so that script_manager can call it when
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "api_version",
purpose = _("display api_version example"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/api_version"
}
script_data.destroy = destroy
return script_data

View File

@@ -40,7 +40,7 @@ local du = require "lib/dtutils"
-- V E R S I O N C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("5.0.2", "darkroom_mode") -- darktable 3.0
du.check_min_api_version("5.0.2", "darkroom_demo") -- darktable 3.0
-- script_manager integration to allow a script to be removed
-- without restarting darktable
@@ -52,17 +52,18 @@ end
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE_NAME = "darkroom"
local MODULE_NAME = "darkroom_demo"
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- T R A N S L A T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext
gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("darkroom_demo", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -92,13 +93,13 @@ dt.gui.current_view(dt.gui.views.darkroom)
local max_images = 10
dt.print(_("Showing images, with a pause in between each"))
dt.print(_("showing images, with a pause in between each"))
sleep(1500)
-- display first 10 images of collection pausing for a second between each
for i, img in ipairs(dt.collection) do
dt.print(_("Displaying image " .. i))
dt.print(string.format(_("displaying image "), i))
dt.gui.views.darkroom.display_image(img)
sleep(1500)
if i == max_images then
@@ -108,7 +109,7 @@ end
-- return to lighttable view
dt.print(_("Restoring view"))
dt.print(_("restoring view"))
sleep(1500)
dt.gui.current_view(current_view)
@@ -116,6 +117,14 @@ dt.gui.current_view(current_view)
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "darkroom_demo",
purpose = _("example demonstrating how to control image display in darkroom mode"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/darkroom_demo"
}
script_data.destroy = destroy
return script_data

View File

@@ -67,27 +67,33 @@ end
-- Not translated Text
dt.print_error("Hello World!")
local gettext = dt.gettext
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("gettextExample", dt.configuration.config_dir .."/lua/locale/")
-- Translate a string using the darktable textdomain
dt.print_error(gettext.gettext("image"))
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("gettextExample",dt.configuration.config_dir.."/lua/locale/")
-- Translate a string using the specified textdomain
dt.print_error(gettext.dgettext("gettextExample", 'Hello World!'))
dt.print_error(gettext("image"))
-- Define a local function called _ to make the code more readable and have it call dgettext
-- with the proper domain.
local function _(msgid)
return gettext.dgettext("gettextExample", msgid)
return gettext(msgid)
end
dt.print_error(_('Hello World!'))
dt.print_error(_("hello world!"))
-- set the destroy routine so that script_manager can call it when
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "gettextExample",
purpose = _("example of how translations works"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/gettextExample"
}
script_data.destroy = destroy
return script_data

View File

@@ -4,6 +4,29 @@ local NaN = 0/0
local wg = {}
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("gui_action", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "gui_action",
purpose = _("example of how to use darktable.gui.action() calls"),
author = "Diederik ter Rahe",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/gui_action"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
wg.action = dt.new_widget("entry"){
text = "lib/filter/view",
placeholder = "action path",
@@ -103,3 +126,18 @@ dt.register_lib(
},
}
)
local function restart()
dt.gui.libs["execute_action"].visible = true
end
local function destroy()
dt.gui.libs["execute_action"].visible = false
end
script_data.destroy = destroy
script_data.destroy_method = "hide"
script_data.restart = restart
script_data.show = restart
return script_data

View File

@@ -29,20 +29,38 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
-- translation facilities
du.check_min_api_version("2.0.0", "hello_world")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("hello_world", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- script_manager integration to allow a script to be removed
-- without restarting darktable
local function destroy()
-- nothing to destroy
end
dt.print("hello, world")
dt.print(_("hello, world"))
-- set the destroy routine so that script_manager can call it when
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "hello_world",
purpose = _("example of how to print a message to the screen"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/hello_world"
}
script_data.destroy = destroy
return script_data

View File

@@ -59,11 +59,12 @@ end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- T R A N S L A T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext
gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("lighttable_demo", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -145,17 +146,17 @@ sleep(2000)
for n, layout in ipairs(layouts) do
dt.gui.libs.lighttable_mode.layout(layout)
dt.print(_("set lighttable layout to " .. layout))
dt.print_log(_("set lighttable layout to " .. layout))
dt.print(string.format(_("set lighttable layout to %s"), layout))
dt.print_log("set lighttable layout to " .. layout)
sleep(1500)
for i = 1, 10 do
dt.gui.libs.lighttable_mode.zoom_level(i)
dt.print(_("Set zoom level to " .. i))
dt.print(string.format(_("set zoom level to %d"), i))
sleep(1500)
end
for i = 9, 1, -1 do
dt.gui.libs.lighttable_mode.zoom_level(i)
dt.print(_("Set zoom level to " .. i))
dt.print(string.format(_("set zoom level to %d"), i))
sleep(1500)
end
end
@@ -174,12 +175,12 @@ dt.print_log("starting sorts")
for n, sort in ipairs(sorts) do
dt.gui.libs.filter.sort(sort)
dt.print(_("set lighttable sort to " .. sort))
dt.print(string.format(_("set lighttable sort to %s"), sort))
sleep(1500)
for m, sort_order in ipairs(sort_orders) do
dt.gui.libs.filter.sort_order(sort_order)
dt.print(_("sort order set to " .. sort_order))
dt.print(string.format(_("sort order set to %s"), sort_order))
sleep(1500)
end
end
@@ -190,12 +191,12 @@ dt.print(_("lighttable filtering demonstration"))
for n, rating in ipairs(ratings) do
dt.gui.libs.filter.rating(rating)
dt.print(_("set filter to " .. rating))
dt.print(string.format(_("set filter to %s"), rating))
sleep(1500)
for m, rating_comparator in ipairs(rating_comparators) do
dt.gui.libs.filter.rating_comparator(rating_comparator)
dt.print(_("set rating comparator to " .. rating_comparator))
dt.print(string.format(_("set rating comparator to %s"), rating_comparator))
sleep(1500)
end
end
@@ -215,6 +216,14 @@ current_sort_order = dt.gui.libs.filter.sort_order(current_sort_order)
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "lighttable_demo",
purpose = _("example demonstrating how to control lighttable display modes"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/lighttable_demo"
}
script_data.destroy = destroy
return script_data

View File

@@ -35,10 +35,26 @@ local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "moduleExample")
-- https://www.darktable.org/lua-api/index.html#darktable_gettext
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("moduleExample", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "moduleExample",
purpose = _("example of how to create a lighttable module"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/moduleExample"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -46,15 +62,6 @@ script_data.show = nil -- only required for libs since the destroy_method only h
-- translation
-- https://www.darktable.org/lua-api/index.html#darktable_gettext
local gettext = dt.gettext
gettext.bindtextdomain("moduleExample", dt.configuration.config_dir .. "/lua/locale/")
local function _(msgid)
return gettext.dgettext("moduleExample", msgid)
end
-- declare a local namespace and a couple of variables we'll need to install the module
local mE = {}
mE.widgets = {}
@@ -80,9 +87,9 @@ local function install_module()
orientation = "vertical",
dt.new_widget("button")
{
label = _("MyButton"),
label = _("my button"),
clicked_callback = function (_)
dt.print(_("Button clicked"))
dt.print(_("button clicked"))
end
},
table.unpack(mE.widgets),
@@ -105,10 +112,10 @@ local function restart()
end
-- https://www.darktable.org/lua-api/types_lua_check_button.html
local check_button = dt.new_widget("check_button"){label = _("MyCheck_button"), value = true}
local check_button = dt.new_widget("check_button"){label = _("my check_button"), value = true}
-- https://www.darktable.org/lua-api/types_lua_combobox.html
local combobox = dt.new_widget("combobox"){label = _("MyCombobox"), value = 2, "8", "16", "32"}
local combobox = dt.new_widget("combobox"){label = _("my combobox"), value = 2, "8", "16", "32"}
-- https://www.darktable.org/lua-api/types_lua_entry.html
local entry = dt.new_widget("entry")
@@ -117,21 +124,21 @@ local entry = dt.new_widget("entry")
placeholder = _("placeholder"),
is_password = false,
editable = true,
tooltip = _("Tooltip Text"),
tooltip = _("tooltip text"),
reset_callback = function(self) self.text = "text" end
}
-- https://www.darktable.org/lua-api/types_lua_file_chooser_button.html
local file_chooser_button = dt.new_widget("file_chooser_button")
{
title = _("MyFile_chooser_button"), -- The title of the window when choosing a file
title = _("my file_chooser_button"), -- The title of the window when choosing a file
value = "", -- The currently selected file
is_directory = false -- True if the file chooser button only allows directories to be selecte
}
-- https://www.darktable.org/lua-api/types_lua_label.html
local label = dt.new_widget("label")
label.label = _("MyLabel") -- This is an alternative way to the "{}" syntax to set a property
label.label = _("my label") -- This is an alternative way to the "{}" syntax to set a property
-- https://www.darktable.org/lua-api/types_lua_separator.html
local separator = dt.new_widget("separator"){}
@@ -139,7 +146,7 @@ local separator = dt.new_widget("separator"){}
-- https://www.darktable.org/lua-api/types_lua_slider.html
local slider = dt.new_widget("slider")
{
label = _("MySlider"),
label = _("my slider"),
soft_min = 10, -- The soft minimum value for the slider, the slider can't go beyond this point
soft_max = 100, -- The soft maximum value for the slider, the slider can't go beyond this point
hard_min = 0, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point

View File

@@ -70,13 +70,12 @@ local dtsys = require "lib/dtutils.system" -- system utilities
translations, inserting this lays the groundwork for anyone who wants to translate the strings.
]]
local gettext = dt.gettext
local gettext = dt.gettext.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("multi_os",dt.configuration.config_dir.."/lua/locale/")
dt.gettext.bindtextdomain("multi_os", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext("multi_os", msgid)
return gettext(msgid)
end
--[[
@@ -187,12 +186,12 @@ local function extract_embedded_jpeg(images)
end
else
dt.print_error(image.filename .. " is not a raw file. No image can be extracted") -- print debugging error message
dt.print(image.filename .. " is not a raw file. No image can be extracted") -- print the error to the screen
dt.print(string.format(_("%s is not a raw file, no image can be extracted"), image.filename)) -- print the error to the screen
end
end
else
dt.print_error("ufraw-batch not found. Exiting...") -- print debugging error message
dt.print("ufraw-batch not found. Exiting...") -- print the error to the screen
dt.print("ufraw-batch not found, exiting...") -- print the error to the screen
end
end
@@ -216,7 +215,7 @@ end
if dt.configuration.running_os ~= "linux" then
local executable = "ufraw-batch"
local ufraw_batch_path_widget = dt.new_widget("file_chooser_button"){
title = _("Select ufraw-batch[.exe] executable"),
title = _("select ufraw-batch[.exe] executable"),
value = df.get_executable_path_preference(executable),
is_directory = false,
changed_callback = function(self)
@@ -228,7 +227,7 @@ if dt.configuration.running_os ~= "linux" then
dt.preferences.register("executable_paths", "ufraw-batch", -- name
"file", -- type
_('multi_os: ufraw-batch location'), -- label
_('Installed location of ufraw-batch. Requires restart to take effect.'), -- tooltip
_('installed location of ufraw-batch, requires restart to take effect.'), -- tooltip
"ufraw-batch", -- default
ufraw_batch_path_widget
)
@@ -241,7 +240,7 @@ end
dt.gui.libs.image.register_action(
"multi_os", _("extract embedded jpeg"),
function(event, images) extract_embedded_jpeg(images) end,
"extract embedded jpeg"
_("extract embedded jpeg")
)
--[[
@@ -251,7 +250,7 @@ dt.gui.libs.image.register_action(
dt.register_event(
"multi_os", "shortcut",
function(event, shortcut) extract_embedded_jpeg(dt.gui.action_images) end,
"extract embedded jpeg"
_("extract embedded jpeg")
)
--[[
@@ -261,6 +260,14 @@ dt.register_event(
]]
local script_data = {}
script_data.metadata = {
name = "multi_os",
purpose = _("example module thet runs on different operating systems"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/multi_os"
}
script_data.destroy = destroy
return script_data

View File

@@ -53,17 +53,18 @@ end
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE_NAME = "panels"
local MODULE_NAME = "panels_demo"
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- T R A N S L A T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext
gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS)
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("panels_demo", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -94,29 +95,29 @@ dt.gui.panel_show_all()
-- hide center_top, center_bottom, left, top, right, bottom in order
dt.print(_("Hiding all panels, one at a tme"))
dt.print(_("hiding all panels, one at a tme"))
sleep(1500)
for i = 1, #panels do
dt.print(_("Hiding " .. panels[i]))
dt.print(_("hiding " .. panels[i]))
dt.gui.panel_hide(panels[i])
sleep(1500)
end
-- display left, then top, then right, then bottom
dt.print(_("Make panels visible, one at a time"))
dt.print(_("make panels visible, one at a time"))
sleep(1500)
for i = #panels, 1, -1 do
dt.print(_("Showing " .. panels[i]))
dt.print(_("showing " .. panels[i]))
dt.gui.panel_show(panels[i])
sleep(1500)
end
-- hide all
dt.print(_("Hiding all panels"))
dt.print(_("hiding all panels"))
sleep(1500)
dt.gui.panel_hide_all()
@@ -124,7 +125,7 @@ sleep(1500)
-- show all
dt.print(_("Showing all panels"))
dt.print(_("showing all panels"))
sleep(1500)
dt.gui.panel_show_all()
@@ -132,7 +133,7 @@ sleep(1500)
-- restore
dt.print(_("Restoring panels to starting configuration"))
dt.print(_("restoring panels to starting configuration"))
for i = 1, #panels do
if panel_status[i] then
dt.gui.panel_show(panels[i])
@@ -145,6 +146,14 @@ end
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "panels_demo",
purpose = _("example demonstrating how to contol panel visibility"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/panels_demo"
}
script_data.destroy = destroy
return script_data

View File

@@ -24,28 +24,47 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
-- translation facilities
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("preferenceExamples", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
local script_data = {}
script_data.metadata = {
name = "preferenceExamples",
purpose = _("example to show the different preference types that are possible"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/preferenceExamples"
}
du.check_min_api_version("2.0.1", "preferenceExamples")
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesString", -- name
"string", -- type
"Example String", -- label
"Example String Tooltip", -- tooltip
_("example string"), -- label
_("example string tooltip"), -- tooltip
"String") -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesBool", -- name
"bool", -- type
"Example Boolean", -- label
"Example Boolean Tooltip", -- tooltip
_("example boolean"), -- label
_("example boolean tooltip"), -- tooltip
true) -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesInteger", -- name
"integer", -- type
"Example Integer", -- label
"Example Integer Tooltip", -- tooltip
_("example integer"), -- label
_("example integer tooltip"), -- tooltip
2, -- default
1, -- min
99) -- max
@@ -53,8 +72,8 @@ dt.preferences.register("preferenceExamples", -- script: This is a string
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesFloat", -- name
"float", -- type
"Example Float", -- label
"Example Float Tooltip", -- tooltip
_("example float"), -- label
_("example float tooltip"), -- tooltip
1.3, -- default
1, -- min
99, -- max
@@ -63,22 +82,30 @@ dt.preferences.register("preferenceExamples", -- script: This is a string
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesFile", -- name
"file", -- type
"Example File", -- label
"Example File Tooltip", -- tooltip
_("example file"), -- label
_("example file tooltip"), -- tooltip
"") -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesDirectory", -- name
"directory", -- type
"Example Directory", -- label
"Example Directory Tooltip", -- tooltip
_("example directory"), -- label
_("example directory tooltip"), -- tooltip
"") -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesEnum", -- name
"enum", -- type
"Example Enum", -- label
"Example Enum Tooltip", -- tooltip
_("example enum"), -- label
_("example enum tooltip"), -- tooltip
"Enum 1", -- default
"Enum 1", "Enum 2") -- values
local function destroy()
-- nothing to destroy
end
script_data.destroy = destroy
return script_data

View File

@@ -24,6 +24,16 @@ local du = require "lib/dtutils"
du.check_min_api_version("5.0.0", "printExamples")
-- translation facilities
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("printExamples", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- script_manager integration to allow a script to be removed
-- without restarting darktable
local function destroy()
@@ -32,7 +42,7 @@ end
-- Will print a string to the darktable control log (the long
-- overlayed window that appears over the main panel).
dt.print("print")
dt.print(_("print"))
-- This function will print its parameter if the Lua logdomain is
-- activated. Start darktable with the "-d lua" command line option
@@ -48,6 +58,14 @@ dt.print_log("print log")
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "printExamples",
purpose = _("example showing the different types of printing messages"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/printExamples"
}
script_data.destroy = destroy
return script_data

View File

@@ -30,18 +30,36 @@ local du = require "lib/dtutils"
du.check_min_api_version("5.0.0", "running_os")
-- translation facilities
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("running_os", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- script_manager integration to allow a script to be removed
-- without restarting darktable
local function destroy()
-- nothing to destroy
end
dt.print("You are running: "..dt.configuration.running_os)
dt.print(string.format(_("you are running: %s"), dt.configuration.running_os))
-- set the destroy routine so that script_manager can call it when
-- it's time to destroy the script and then return the data to
-- script_manager
local script_data = {}
script_data.metadata = {
name = "running_os",
purpose = _("example of how to determine the operating system being used"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/running_os"
}
script_data.destroy = destroy
return script_data

View File

@@ -55,6 +55,29 @@ local du = require "lib/dtutils"
du.check_min_api_version("9.2.0", "x-touch")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("gui_action", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "x-touch",
purpose = _("example of how to control an x-touch midi device"),
author = "Diederik ter Rahe",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/x-touch"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- set up 8 mimic sliders with the same function
for k = 1,8 do
dt.gui.mimic("slider", "knob ".. k,
@@ -161,3 +184,11 @@ for k = 1,8 do
return dt.gui.action(which, element, effect, size)
end)
end
local function destroy()
-- nothing to destroy
end
script_data.destroy = destroy
return script_data

View File

@@ -82,8 +82,7 @@ dtutils.libdoc.functions["check_max_api_version"] = {
run against the current api version. This function is used when a part of the Lua API that
the script relies on is removed. If the maximum api version is not met, then an
error message is printed saying the script_name failed to load, then an error is thrown causing the
program to stop executing.
program to stop executing.]],
Return_Value = [[result - true if the maximum api version is available, false if not.]],
Limitations = [[When using the default handler on a script being executed from the luarc file, the error thrown
will stop the luarc file from executing any remaining statements. This limitation does not apply to script_manger.]],

View File

@@ -861,9 +861,6 @@ dtutils_file.libdoc.functions["create_tmp_file"] = {
function dtutils_file.create_tmp_file()
local tmp_file = os.tmpname()
if dt.configuration.running_os == "windows" then
tmp_file = dt.configuration.tmp_dir .. tmp_file -- windows os.tmpname() defaults to root directory
end
local f = io.open(tmp_file, "w")
if not f then

View File

@@ -199,7 +199,7 @@ function dtutils_log.msg(level, ...)
table.remove(args, 1)
end
local log_msg = level.label
if level.engine ~= dt_screen and call_level ~= 0 then
if level.engine ~= dt_print and call_level ~= 0 then
log_msg = log_msg .. dtutils_log.caller(call_level, level.caller_info) .. " "
elseif log_msg:len() > 2 then
log_msg = log_msg .. " "

View File

@@ -1,6 +1,12 @@
local dtutils_string = {}
local dt = require "darktable"
local du = require "lib/dtutils"
local log = require "lib/dtutils.log"
local DEFAULT_LOG_LEVEL = log.error
dtutils_string.log_level = DEFAULT_LOG_LEVEL
dtutils_string.libdoc = {
Name = [[dtutils.string]],
@@ -48,6 +54,8 @@ dtutils_string.libdoc.functions["strip_accents"] = {
}
function dtutils_string.strip_accents( str )
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
local tableAccents = {}
tableAccents["à"] = "a"
tableAccents["á"] = "a"
@@ -111,6 +119,7 @@ function dtutils_string.strip_accents( str )
end
end
log.log_level(old_log_level)
return normalizedString
end
@@ -136,6 +145,8 @@ dtutils_string.libdoc.functions["escape_xml_characters"] = {
-- Keep &amp; first, otherwise it will double escape other characters
function dtutils_string.escape_xml_characters( str )
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
str = string.gsub(str,"&", "&amp;")
str = string.gsub(str,"\"", "&quot;")
@@ -143,6 +154,7 @@ function dtutils_string.escape_xml_characters( str )
str = string.gsub(str,"<", "&lt;")
str = string.gsub(str,">", "&gt;")
log.log_level(old_log_level)
return str
end
@@ -165,11 +177,14 @@ dtutils_string.libdoc.functions["urlencode"] = {
}
function dtutils_string.urlencode(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
log.log_level(old_log_level)
return str
end
@@ -192,38 +207,52 @@ dtutils_string.libdoc.functions["is_not_sanitized"] = {
}
local function _is_not_sanitized_posix(str)
-- A sanitized string must be quoted.
if not string.match(str, "^'.*'$") then
return true
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
-- A sanitized string must be quoted.
if not string.match(str, "^'.*'$") then
log.log_level(old_log_level)
return true
-- A quoted string containing no quote characters within is sanitized.
elseif string.match(str, "^'[^']*'$") then
return false
end
elseif string.match(str, "^'[^']*'$") then
log.log_level(old_log_level)
return false
end
-- Any quote characters within a sanitized string must be properly
-- escaped.
local quotesStripped = string.sub(str, 2, -2)
local escapedQuotesRemoved = string.gsub(quotesStripped, "'\\''", "")
if string.find(escapedQuotesRemoved, "'") then
return true
else
return false
end
-- Any quote characters within a sanitized string must be properly
-- escaped.
local quotesStripped = string.sub(str, 2, -2)
local escapedQuotesRemoved = string.gsub(quotesStripped, "'\\''", "")
if string.find(escapedQuotesRemoved, "'") then
log.log_level(old_log_level)
return true
else
log.log_level(old_log_level)
return false
end
end
local function _is_not_sanitized_windows(str)
if not string.match(str, "^\".*\"$") then
return true
else
return false
end
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
if not string.match(str, "^\".*\"$") then
log.log_level(old_log_level)
return true
else
log.log_level(old_log_level)
return false
end
end
function dtutils_string.is_not_sanitized(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
if dt.configuration.running_os == "windows" then
return _is_not_sanitized_windows(str)
log.log_level(old_log_level)
return _is_not_sanitized_windows(str)
else
return _is_not_sanitized_posix(str)
log.log_level(old_log_level)
return _is_not_sanitized_posix(str)
end
end
@@ -246,27 +275,55 @@ dtutils_string.libdoc.functions["sanitize"] = {
}
local function _sanitize_posix(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
if _is_not_sanitized_posix(str) then
return "'" .. string.gsub(str, "'", "'\\''") .. "'"
log.log_level(old_log_level)
return "'" .. string.gsub(str, "'", "'\\''") .. "'"
else
return str
log.log_level(old_log_level)
return str
end
end
local function _sanitize_windows(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
if _is_not_sanitized_windows(str) then
return "\"" .. string.gsub(str, "\"", "\"^\"\"") .. "\""
log.log_level(old_log_level)
return "\"" .. string.gsub(str, "\"", "\"^\"\"") .. "\""
else
return str
log.log_level(old_log_level)
return str
end
end
function dtutils_string.sanitize(str)
if dt.configuration.running_os == "windows" then
return _sanitize_windows(str)
else
return _sanitize_posix(str)
local function _should_be_sanitized(str)
local old_log_level = log.log_level()
local result = false
log.log_level(dtutils_string.log_level)
if string.match(str, "[^%g]") then
result = true
end
log.log_level(old_log_level)
return result
end
function dtutils_string.sanitize(str)
local old_log_level = log.log_level()
local sanitized_str = nil
log.log_level(dtutils_string.log_level)
if _should_be_sanitized(str) then
if dt.configuration.running_os == "windows" then
sanitized_str = _sanitize_windows(str)
else
sanitized_str = _sanitize_posix(str)
end
else
sanitized_str = str
end
log.log_level(old_log_level)
return sanitized_str
end
dtutils_string.libdoc.functions["sanitize_lua"] = {
@@ -288,9 +345,16 @@ dtutils_string.libdoc.functions["sanitize_lua"] = {
}
function dtutils_string.sanitize_lua(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
str = string.gsub(str, "%%", "%%%%")
str = string.gsub(str, "%-", "%%-")
str = string.gsub(str, "%(", "%%(")
str = string.gsub(str, "%)", "%%)")
str = string.gsub(str, "%[", "%%[")
str = string.gsub(str, "%]", "%%]")
str = string.gsub(str, "+", "%%+")
log.log_level(old_log_level)
return str
end
@@ -313,7 +377,9 @@ dtutils_string.libdoc.functions["split_filepath"] = {
}
function dtutils_string.split_filepath(str)
-- strip out single quotes from quoted pathnames
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
-- strip out single quotes from quoted pathnames
str = string.gsub(str, "'", "")
str = string.gsub(str, '"', '')
local result = {}
@@ -323,6 +389,7 @@ function dtutils_string.split_filepath(str)
result["basename"] = result["filetype"]
result["filetype"] = ""
end
log.log_level(old_log_level)
return result
end
@@ -344,7 +411,10 @@ dtutils_string.libdoc.functions["get_path"] = {
}
function dtutils_string.get_path(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
local parts = dtutils_string.split_filepath(str)
log.log_level(old_log_level)
return parts["path"]
end
@@ -366,7 +436,10 @@ dtutils_string.libdoc.functions["get_filename"] = {
}
function dtutils_string.get_filename(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
local parts = dtutils_string.split_filepath(str)
log.log_level(old_log_level)
return parts["filename"]
end
@@ -389,7 +462,10 @@ dtutils_string.libdoc.functions["get_basename"] = {
}
function dtutils_string.get_basename(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
local parts = dtutils_string.split_filepath(str)
log.log_level(old_log_level)
return parts["basename"]
end
@@ -411,10 +487,601 @@ dtutils_string.libdoc.functions["get_filetype"] = {
}
function dtutils_string.get_filetype(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
local parts = dtutils_string.split_filepath(str)
log.log_level(old_log_level)
return parts["filetype"]
end
dtutils_string.libdoc.functions["build_substitute_list"] = {
Name = [[build_substitute_list]],
Synopsis = [[build a list of variable substitutions]],
Usage = [[local ds = require "lib/dtutils.string"
ds.build_substitute_list(image, sequence, variable_string, [username], [pic_folder], [home], [desktop])
image - dt_lua_image_t - the image being processed
sequence - integer - the sequence number of the image being processed (exported)
variable_string - string - the substitution variable string
[username] - string - optional - user name. Will be determined if not supplied
[pic_folder] - string - optional - pictures folder name. Will be determined if not supplied
[home] - string - optional - home directory. Will be determined if not supplied
[desktop] - string - optional - desktop directory. Will be determined if not supplied]],
Description = [[build_substitute_list populates variables with values from the arguments
and determined from the system and darktable.]],
Return_Value = [[]],
Limitations = [[If the value for a variable can not be determined, or if it is not supported,
then an empty string is used for the value.]],
Example = [[]],
See_Also = [[https://docs.darktable.org/usermanual/4.6/en/special-topics/variables/]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
local substitutes = {}
local category_substitutes = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local PLACEHOLDERS = {"ROLL.NAME",
"FILE.FOLDER",
"FILE.NAME",
"FILE.EXTENSION",
"ID",
"VERSION",
"VERSION.IF.MULTI",
"VERSION.NAME",
"DARKTABLE.VERSION",
"DARKTABLE.NAME", -- Not Implemented
"SEQUENCE",
"WIDTH.SENSOR",
"HEIGHT.SENSOR",
"WIDTH.RAW",
"HEIGHT.RAW",
"WIDTH.CROP",
"HEIGHT.CROP",
"WIDTH.EXPORT",
"HEIGHT.EXPORT",
"WIDTH.MAX", -- Not Implemented
"HEIGHT.MAX", -- Not Implemented
"YEAR",
"YEAR.SHORT",
"MONTH",
"MONTH.LONG",
"MONTH.SHORT",
"DAY",
"HOUR",
"MINUTE",
"SECOND",
"MSEC",
"EXIF.YEAR",
"EXIF.YEAR.SHORT",
"EXIF.MONTH",
"EXIF.MONTH.LONG",
"EXIF.MONTH.SHORT",
"EXIF.DAY",
"EXIF.HOUR",
"EXIF.MINUTE",
"EXIF.SECOND",
"EXIF.MSEC",
"EXIF.DATE.REGIONAL", -- Not Implemented
"EXIF.TIME.REGIONAL", -- Not Implemented
"EXIF.ISO",
"EXIF.EXPOSURE",
"EXIF.EXPOSURE.BIAS",
"EXIF.APERTURE",
"EXIF.CROP.FACTOR",
"EXIF.FOCAL.LENGTH",
"EXIF.FOCAL.LENGTH.EQUIV", -- Not Implemented
"EXIF.FOCUS.DISTANCE",
"IMAGE.EXIF", -- Not Implemented
"LONGITUDE",
"LATITUDE",
"ELEVATION",
"GPS.LOCATION", -- Not Implemented
"STARS",
"RATING.ICONS", -- Not Implemented
"LABELS",
"LABELS.ICONS", -- Not Implemented
"MAKER",
"MODEL",
"LENS",
"TITLE",
"DESCRIPTION",
"CREATOR",
"PUBLISHER",
"RIGHTS",
"TAGS", -- Not Implemented
"SIDECAR.TXT", -- Not Implemented
"FOLDER.PICTURES",
"FOLDER.HOME",
"FOLDER.DESKTOP",
"OPENCL.ACTIVATED", -- Not Implemented
"USERNAME",
"NL", -- Not Implemented
"JOBCODE" -- Not Implemented
}
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local USER = os.getenv("USERNAME")
local HOME = dt.configuration.running_os == "windows" and os.getenv("HOMEPATH") or os.getenv("HOME")
local PICTURES = HOME .. PS .. (dt.configuration.running_os == "windows" and "My Pictures" or "Pictures")
local DESKTOP = HOME .. PS .. "Desktop"
local function get_colorlabels(image)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
local colorlabels = {}
if image.red then table.insert(colorlabels, "red") end
if image.yellow then table.insert(colorlabels, "yellow") end
if image.green then table.insert(colorlabels, "green") end
if image.blue then table.insert(colorlabels, "blue") end
if image.purple then table.insert(colorlabels, "purple") end
local labels = #colorlabels == 1 and colorlabels[1] or du.join(colorlabels, "_")
log.log_level(old_log_level)
return labels
end
-- find the $CATEGORYn and $CATEGORY[n,m] requests and add them to the substitute list
local function build_category_substitution_list(image, variable_string)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
for match in string.gmatch(variable_string, "%$%(.-%)?%)") do -- grab each complete variable
log.msg(log.info, "match is " .. match)
local var = string.match(match, "%$%((.-%)?)%)") -- strip of the leading $( and trailing )
log.msg(log.info, "var is " .. var)
if string.match(var, "CATEGORY%d") or string.match(var, "CATEGORY%[") then
local element
local tag
if string.match(var, "CATEGORY%d") then
element, tag = string.match(var, "CATEGORY(%d)%((.-)%)") -- get the element number and the tag to match
else
element, tag = string.match(var, "%[(%d),(.-)%]") -- new syntax
end
element = element + 1 -- add one to element since lua arrays are 1 based
log.msg(log.debug, "element is " .. element .. " and tag is " .. tag)
local tags = image:get_tags()
log.msg(log.debug, "got " .. #tags .. " from image " .. image.filename)
for _, image_tag in ipairs(tags) do
log.msg(log.debug, "checking tag " .. image_tag.name)
if string.match(image_tag.name, tag) then
fields = du.split(image_tag.name, "|")
if element <= #fields then
substitutes[var] = fields[element]
else
substitutes[var] = ""
log.msg(log.warn, "requested field for tag " .. tag .. " doesn't exist")
end
log.msg(log.info, "set substitute for " .. var .. " to " .. fields[element])
end
end
end
end
log.log_level(old_log_level)
end
-- convert image.exif_datetime_taken to system time
local function exiftime2systime(exiftime)
local yr,mo,dy,h,m,s = string.match(exiftime, "(%d-):(%d-):(%d-) (%d-):(%d-):(%d+)")
return(os.time{year=yr, month=mo, day=dy, hour=h, min=m, sec=s})
end
-- build the argument substitution list from each image
function dtutils_string.build_substition_list(image, sequence, variable_string, username, pic_folder, home, desktop)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
-- is time millisecond aware? Implemented in API 9.1.0
local is_api_9_1 = true
if dt.configuration.api_version_string < "9.1.0" then
is_api_9_1 = false
end
local datetime = os.date("*t")
local long_month = os.date("%B")
local short_month = os.date("%b")
local user_name = username or USER
local pictures_folder = pic_folder or PICTURES
local home_folder = home or HOME
local desktop_folder = desktop or DESKTOP
local labels = get_colorlabels(image)
local eyear, emon, eday, ehour, emin, esec, emsec
if dt.preferences.read("darktable", "lighttable/ui/milliseconds", "bool") and is_api_9_1 then
eyear, emon, eday, ehour, emin, esec, emsec =
string.match(image.exif_datetime_taken, "(%d+):(%d+):(%d+) (%d+):(%d+):(%d+)%.(%d+)$")
else
emsec = "0"
eyear, emon, eday, ehour, emin, esec =
string.match(image.exif_datetime_taken, "(%d+):(%d+):(%d+) (%d+):(%d+):(%d+)$")
end
local version_multi = #image:get_group_members() > 1 and image.version or ""
local replacements = {image.film.path, -- ROLL.NAME
image.path, -- FILE.FOLDER
image.filename, -- FILE.NAME
dtutils_string.get_filetype(image.filename),-- FILE.EXTENSION
image.id, -- ID
image.duplicate_index, -- VERSION
version_multi, -- VERSION.IF_MULTI
image.version_name, -- VERSION.NAME
dt.configuration.version, -- DARKTABLE.VERSION
"", -- DARKTABLE.NAME
string.format("%04d", sequence), -- SEQUENCE
image.width, -- WIDTH.SENSOR
image.height, -- HEIGHT.SENSOR
is_api_9_1 and image.p_width or "", -- WIDTH.RAW
is_api_9_1 and image.p_height or "", -- HEIGHT.RAW
is_api_9_1 and image.final_width or "", -- WIDTH.CROP
is_api_9_1 and image.final_height or "", -- HEIGHT.CROP
is_api_9_1 and image.final_width or "", -- WIDTH.EXPORT
is_api_9_1 and image.final_height or "", -- HEIGHT.EXPORT
"", -- WIDTH.MAX -- from export module
"", -- HEIGHT.MAX -- from export module
string.format("%4d", datetime.year), -- YEAR
string.sub(datetime.year, 3), -- YEAR.SHORT
string.format("%02d", datetime.month), -- MONTH
long_month, -- MONTH.LONG
short_month, -- MONTH.SHORT
string.format("%02d", datetime.day), -- DAY
string.format("%02d", datetime.hour), -- HOUR
string.format("%02d", datetime.min), -- MINUTE
string.format("%02d", datetime.sec), -- SECOND
0, -- MSEC
eyear, -- EXIF.YEAR
string.sub(eyear, 3), -- EXIF.YEAR.SHORT
emon, -- EXIF.MONTH
os.date("%B", exiftime2systime(image.exif_datetime_taken)), -- EXIF.MONTH.LONG
os.date("%b", exiftime2systime(image.exif_datetime_taken)), -- EXIF.MONTH.SHORT
eday, -- EXIF.DAY
ehour, -- EXIF.HOUR
emin, -- EXIF.MINUTE
esec, -- EXIF.SECOND
emsec, -- EXIF.MSEC
"", -- EXIF.DATE.REGIONAL - wont be implemented
"", -- EXIF.TIME.REGIONAL - wont be implemented
string.format("%d", image.exif_iso), -- EXIF.ISO
string.format("%.0f", 1./image.exif_exposure), -- EXIF.EXPOSURE
image.exif_exposure_bias, -- EXIF.EXPOSURE.BIAS
string.format("%.01f", image.exif_aperture), -- EXIF.APERTURE
string.format("%.01f", image.exif_crop),-- EXIF.CROP_FACTOR
string.format("%.0f", image.exif_focal_length), -- EXIF.FOCAL.LENGTH
string.format("%.0f", image.exif_focal_length * image.exif_crop), -- EXIF.FOCAL.LENGTH.EQUIV
image.exif_focus_distance, -- EXIF.FOCUS.DISTANCE
"", -- IMAGE.EXIF
image.longitude or "", -- LONGITUDE
image.latitude or "", -- LATITUDE
image.elevation or "", -- ELEVATION
"", -- GPS.LOCATION - wont be implemented
image.rating, -- STARS
"", -- RATING.ICONS - wont be implemented
labels, -- LABELS
"", -- LABELS.ICONS - wont be implemented
image.exif_maker, -- MAKER
image.exif_model, -- MODEL
image.exif_lens, -- LENS
image.title, -- TITLE
image.description, -- DESCRIPTION
image.creator, -- CREATOR
image.publisher, -- PUBLISHER
image.rights, -- RIGHTS
"", -- TAGS - wont be implemented
"", -- SIDECAR.TXT - wont be implemented
pictures_folder, -- FOLDER.PICTURES
home_folder, -- FOLDER.HOME
desktop_folder, -- FOLDER.DESKTOP
"", -- OPENCL.ACTIVATED - wont be implemented
user_name, -- USERNAME
"", -- NL - wont be implemented
"" -- JOBCODE - wont be implemented
}
-- populate the substitution list
for i = 1, #PLACEHOLDERS, 1 do
substitutes[PLACEHOLDERS[i]] = replacements[i]
log.msg(log.info, "setting " .. PLACEHOLDERS[i] .. " to " .. tostring(replacements[i]))
end
-- do category substitutions separately
build_category_substitution_list(image, variable_string)
log.log_level(old_log_level)
end
-- handle different versions of names
local function check_legacy_vars(var_name)
local var = var_name
if string.match(var, "_") then
var = string.gsub(var, "_", ".")
end
if string.match(var, "^HOME$") then var = "FOLDER.HOME" end
if string.match(var, "^PICTURES.FOLDER$") then var = "FOLDER.PICTURES" end
if string.match(var, "^DESKTOP$") then var = "FOLDER.DESKTOP" end
return var
end
-- get the substitution and do any string manipulations requested
local function treat(var_string)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
local ret_val = ""
-- remove the var from the string
local var = string.match(var_string, "[%a%._]+")
var = check_legacy_vars(var)
log.msg(log.info, "var_string is " .. tostring(var_string) .. " and var is " .. tostring(var))
if string.match(var_string, "CATEGORY%d") or string.match(var_string, "CATEGORY%[") then
log.msg(log.info, "substituting for " .. var_string)
ret_val = substitutes[var_string]
log.msg(log.info, "ret_val is " .. ret_val)
elseif string.match(var_string, "SEQUENCE%[") then
local start, width = string.match(var_string, "(%d+),(%d)")
local seq_val = tonumber(substitutes[var])
local pat = "%0" .. width .. "d"
substitutes[var_string] = string.format(pat, start + (seq_val - 1))
ret_val = substitutes[var_string]
else
ret_val = substitutes[var]
end
local valid_var = false
if ret_val then
valid_var = true
end
if not valid_var then
log.msg(log.error, "variable " .. var .. " is not an allowed variable, returning empty value")
log.log_level(old_log_level)
return ""
end
-- string modifications
local args = string.gsub(var_string, var, "")
log.msg(log.info, "args is " .. tostring(args))
if string.len(args) > 0 then
if string.match(args, '^%^%^') then
ret_val = string.upper(ret_val)
elseif string.match(args, "^%^") then
ret_val = string.gsub(ret_val, "^%a", string.upper, 1)
elseif string.match(args, "^,,") then
ret_val = string.lower(ret_val)
elseif string.match(args, "^,") then
ret_val = string.gsub(ret_val, "^%a", string.lower, 1)
elseif string.match(args, "^:%-?%d+:%-?%d+") then
local soffset, slen = string.match(args, ":(%-?%d+):(%-?%d+)")
log.msg(log.info, "soffset is " .. soffset .. " and slen is " .. slen)
if tonumber(soffset) >= 0 then
soffset = soffset + 1
end
log.msg(log.info, "soffset is " .. soffset .. " and slen is " .. slen)
if tonumber(soffset) < 0 and tonumber(slen) < 0 then
local temp = soffset
soffset = slen
slen = temp
end
log.msg(log.info, "soffset is " .. soffset .. " and slen is " .. slen)
ret_val = string.sub(ret_val, soffset, slen)
log.msg(log.info, "ret_val is " .. ret_val)
elseif string.match(args, "^:%-?%d+") then
local soffset= string.match(args, ":(%-?%d+)")
if tonumber(soffset) >= 0 then
soffset = soffset + 1
end
ret_val = string.sub(ret_val, soffset, -1)
elseif string.match(args, "^-%$%(.-%)") then
local replacement = string.match(args, "-%$%(([%a%._]+)%)")
replacement = check_legacy_vars(replacement)
if string.len(ret_val) == 0 then
ret_val = substitutes[replacement]
end
elseif string.match(args, "^-.+$") then
local replacement = string.match(args, "-(.+)$")
if string.len(ret_val) == 0 then
ret_val = replacement
end
elseif string.match(args, "^+.+") then
local replacement = string.match(args, "+(.+)")
if string.len(ret_val) > 0 then
ret_val = replacement
end
elseif string.match(args, "^#.+") then
local pattern = string.match(args, "#(.+)")
log.msg(log.info, "pattern to remove is " .. tostring(pattern))
ret_val = string.gsub(ret_val, "^" .. dtutils_string.sanitize_lua(pattern), "")
elseif string.match(args, "^%%.+") then
local pattern = string.match(args, "%%(.+)")
ret_val = string.gsub(ret_val, pattern .. "$", "")
elseif string.match(args, "^//.-/.+") then
local pattern, replacement = string.match(args, "//(.-)/(.+)")
ret_val = string.gsub(ret_val, pattern, replacement)
elseif string.match(args, "^/#.+/.+") then
local pattern, replacement = string.match(args, "/#(.+)/(.+)")
ret_val = string.gsub(ret_val, "^" .. pattern, replacement, 1)
elseif string.match(args, "^/%%.-/.+") then
local pattern, replacement = string.match(args, "/%%(.-)/(.+)")
ret_val = string.gsub(ret_val, pattern .. "$", replacement)
elseif string.match(args, "^/.-/.+") then
log.msg(log.info, "took replacement branch")
local pattern, replacement = string.match(args, "/(.-)/(.+)")
ret_val = string.gsub(ret_val, pattern, replacement, 1)
end
end
log.log_level(old_log_level)
return ret_val
end
dtutils_string.libdoc.functions["substitute_list"] = {
Name = [[substitute_list]],
Synopsis = [[Replace variables in a string with their computed values]],
Usage = [[local ds = require "lib/dtutils.string"
local result = ds.substitute_list(str)
str - string - the string containing the variables to be substituted for]],
Description = [[substitute_list replaces the variables in the supplied string with
values computed in build_substitution_list().]],
Return_Value = [[result - string - the input string with values substituted for the variables]],
Limitations = [[]],
Example = [[]],
See_Also = [[https://docs.darktable.org/usermanual/4.6/en/special-topics/variables/]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_string.substitute_list(str)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
-- replace the substitution variables in a string
for match in string.gmatch(str, "%$%(.-%)?%)") do
local var = string.match(match, "%$%((.-%)?)%)")
local treated_var = treat(var)
log.msg(log.info, "var is " .. var .. " and treated var is " .. tostring(treated_var))
str = string.gsub(str, "%$%(".. dtutils_string.sanitize_lua(var) .."%)", tostring(treated_var))
log.msg(log.info, "str after replacement is " .. str)
end
log.log_level(old_log_level)
return str
end
dtutils_string.libdoc.functions["clear_substitute_list"] = {
Name = [[clear_substitute_list]],
Synopsis = [[Clear the computed list of variable substitution values]],
Usage = [[local ds = require "lib/dtutils.string"
ds.clear_substitute_list()]],
Description = [[clear_substitute_list resets the list of variable replacement values]],
Return_Value = [[]],
Limitations = [[]],
Example = [[]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_string.clear_substitute_list()
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
substitutes = {}
category_substitutes = {}
log.log_level(old_log_level)
end
dtutils_string.libdoc.functions["substitute"] = {
Name = [[substitute]],
Synopsis = [[Perform all the variable substitution steps with one function call]],
Usage = [[local ds = require "lib/dtutils.string"
ds.substitute(image, sequence, variable_string, [username], [pic_folder], [home], [desktop])
image - dt_lua_image_t - the image being processed
sequence - integer - the number of the image being processed (exported)
variable_string - string - the substitution variable string
[username] - string - optional - user name. Will be determined if not supplied
[pic_folder] - string - optional - pictures folder name. Will be determined if not supplied
[home] - string - optional - home directory. Will be determined if not supplied
[desktop] - string - optional - desktop directory. Will be determined if not supplied]],
Description = [[substitute initializes the substitution list by calling clear_substitute_list(),
then builds the substitutions by calling build_substitute_list() and finally does the
substitution by calling substitute_list(), then returns the result string.]],
Return_Value = [[result - string - the input string with values substituted for the variables]],
Limitations = [[]],
Example = [[]],
See_Also = [[https://docs.darktable.org/usermanual/4.6/en/special-topics/variables/]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_string.substitute(image, sequence, variable_string, username, pic_folder, home, desktop)
local old_log_level = log.log_level()
log.log_level(dtutils_string.log_level)
dtutils_string.clear_substitute_list()
dtutils_string.build_substitute_list(image, sequence, variable_string, username, pic_folder, home, desktop)
local str = dtutils_string.substitute_list(variable_string)
log.log_level(old_log_level)
return str
end
return dtutils_string

View File

@@ -1,6 +1,7 @@
local dtutils_system = {}
local dt = require "darktable"
local ds = require "lib/dtutils.string"
dtutils_system.libdoc = {
Name = [[dtutils.system]],
@@ -118,6 +119,7 @@ dtutils_system.libdoc.functions["launch_default_app"] = {
License = [[]],
Copyright = [[]],
}
function dtutils_system.launch_default_app(path)
local open_cmd = "xdg-open "
if (dt.configuration.running_os == "windows") then
@@ -128,5 +130,4 @@ function dtutils_system.launch_default_app(path)
return dtutils_system.external_command(open_cmd .. path)
end
return dtutils_system

View File

@@ -34,10 +34,25 @@ local cjson = require "cjson"
du.check_min_api_version("2.0.0", "check_for_updates")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("check_for_updates", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "check_for_updates",
purpose = _("check for newer darktable releases"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/check_for_updates"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again

View File

@@ -27,14 +27,27 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "copy_paste_metadata")
dt.gettext.bindtextdomain("copy_paste_metadata", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "copy_paste_metadata",
purpose = _("adds keyboard shortcuts and buttons to copy/paste metadata between images"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/copy_paste_metadata"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -58,13 +71,6 @@ local publisher = ""
local rights = ""
local tags = {}
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("copy_paste_metadata",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("copy_paste_metadata", msgid)
end
local function copy(image)
if not image then
have_data = false
@@ -147,13 +153,13 @@ dt.gui.libs.image.register_action(
dt.register_event(
"capmd1", "shortcut",
function(event, shortcut) copy(dt.gui.action_images[1]) end,
"copy metadata"
_("copy metadata")
)
dt.register_event(
"capmd2", "shortcut",
function(event, shortcut) paste(dt.gui.action_images) end,
"paste metadata"
_("paste metadata")
)
script_data.destroy = destroy

View File

@@ -33,10 +33,25 @@ local du = require "lib/dtutils"
du.check_min_api_version("2.0.0", "delete_long_tags")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("delete_long_tags", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "delete_long_tags",
purpose = _("delete all tags longer than a set length"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/delete_long_tags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -59,7 +74,7 @@ local long_tags = {}
for _,t in ipairs(dt.tags) do
local len = #t.name
if len > max_length then
print("deleting tag `"..t.name.."' (length: "..len..")")
dt.print_log("deleting tag `"..t.name.."' (length: "..len..")")
table.insert(long_tags, t.name)
end
end

View File

@@ -37,10 +37,25 @@ local function destroy()
-- noting to destroy
end
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("delete_unused_tags", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "delete_unused_tags",
purpose = _("delete unused tags"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/delete_unused_tags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -56,7 +71,7 @@ for _, t in ipairs(dt.tags) do
end
for _,name in pairs(unused_tags) do
print("deleting tag `" .. name .. "'")
dt.print_log("deleting tag `" .. name .. "'")
tag = dt.tags.find(name)
tag:delete()
end

View File

@@ -39,31 +39,37 @@ local dtsys = require "lib/dtutils.system"
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "enfuse")
dt.gettext.bindtextdomain("enfuse", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "enfuse",
purpose = _("exposure blend images"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/enfuse"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("enfuse",dt.configuration.config_dir..PS .. "lua" .. PS .. "locale" .. PS)
local enf = {}
enf.event_registered = false
enf.module_installed = false
enf.lib_widgets = {}
local function _(msgid)
return gettext.dgettext("enfuse", msgid)
end
local function install_module()
if not enf.module_installed then
dt.register_lib(
@@ -132,7 +138,7 @@ if enfuse_installed then
exposure_mu = dt.new_widget("slider")
{
label = "exposure mu",
tooltip = "center also known as MEAN of Gaussian weighting function (0 <= MEAN <= 1); default: 0.5",
tooltip = _("center also known as mean of gaussian weighting function (0 <= mean <= 1); default: 0.5"),
hard_min = 0,
hard_max = 1,
value = dt.preferences.read("enfuse", "exposure_mu", "float")
@@ -141,7 +147,7 @@ if enfuse_installed then
exposure_mu = dt.new_widget("slider")
{
label = "exposure optimum",
tooltip = "optimum exposure value, usually the maximum of the weighting function (0 <= OPTIMUM <=1); default 0.5",
tooltip = _("optimum exposure value, usually the maximum of the weighting function (0 <= optimum <=1); default 0.5"),
hard_min = 0,
hard_max = 1,
value = dt.preferences.read("enfuse", "exposure_optimum", "float")
@@ -151,7 +157,7 @@ if enfuse_installed then
local depth = dt.new_widget("combobox")
{
label = "depth",
tooltip = "the number of bits per channel of the output image",
tooltip = _("the number of bits per channel of the output image"),
value = dt.preferences.read("enfuse", "depth", "integer"),
changed_callback = function(w) dt.preferences.write("enfuse", "depth", "integer", w.selected) end,
"8", "16", "32"
@@ -160,14 +166,14 @@ if enfuse_installed then
local blend_colorspace = dt.new_widget("combobox")
{
label = "blend colorspace",
tooltip = "Force blending in selected colorspace",
tooltip = _("force blending in selected colorspace"),
changed_callback = function(w) dt.preferences.write("enfuse", "blend_colorspace", "string", w.selected) end,
"", "identity", "ciecam"
}
local enfuse_button = dt.new_widget("button")
{
label = enfuse_installed and "run enfuse" or "enfuse not installed",
label = enfuse_installed and _("run enfuse") or _("enfuse not installed"),
clicked_callback = function ()
-- remember exposure_mu
-- TODO: find a way to save it whenever the value changes
@@ -185,7 +191,7 @@ if enfuse_installed then
end
local f = io.open(response_file, "w")
if not f then
dt.print(string.format(_("Error writing to `%s`"), response_file))
dt.print(string.format(_("error writing to '%s'"), response_file))
os.remove(response_file)
return
end
@@ -208,9 +214,9 @@ if enfuse_installed then
if dt.configuration.running_os == "windows" then
tmp_exported = dt.configuration.tmp_dir .. tmp_exported -- windows os.tmpname() defaults to root directory
end
dt.print(string.format(_("Converting raw file '%s' to tiff..."), i.filename))
dt.print(string.format(_("converting raw file '%s' to tiff..."), i.filename))
tiff_exporter:write_image(i, tmp_exported, false)
dt.print_log(string.format("Raw file '%s' converted to '%s'", i.filename, tmp_exported))
dt.print_log(string.format("raw file '%s' converted to '%s'", i.filename, tmp_exported))
cnt = cnt + 1
f:write(tmp_exported.."\n")
@@ -218,14 +224,14 @@ if enfuse_installed then
-- other images will be skipped
else
dt.print(string.format(_("Skipping %s..."), i.filename))
dt.print(string.format(_("skipping %s..."), i.filename))
n_skipped = n_skipped + 1
end
end
f:close()
-- bail out if there is nothing to do
if cnt == 0 then
dt.print(_("No suitable images selected, nothing to do for enfuse"))
dt.print(_("no suitable images selected, nothing to do for enfuse"))
os.remove(response_file)
return
end
@@ -251,7 +257,7 @@ if enfuse_installed then
..blend_colorspace_option
.." -o \""..output_image.."\" \"@"..response_file.."\""
if dtsys.external_command( command) > 0 then
dt.print(_("Enfuse failed, see terminal output for details"))
dt.print(_("enfuse failed, see terminal output for details"))
os.remove(response_file)
return
end
@@ -299,7 +305,7 @@ if enfuse_installed then
else
dt.print_error("enfuse executable not found")
error("enfuse executable not found")
dt.print(_("Could not find enfuse executable. Not loading enfuse exporter..."))
dt.print(_("could not find enfuse executable, not loading enfuse exporter..."))
end
script_data.destroy = destroy

View File

@@ -38,12 +38,27 @@ local dt = require "darktable"
local du = require "lib/dtutils"
require "darktable.debug"
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("generate_image_txt", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
du.check_min_api_version("7.0.0", "generate_image_txt")
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "generate_image_txt",
purpose = _("overlay metadata on the selected image(s)"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/generate_image_txt"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -52,21 +67,21 @@ script_data.show = nil -- only required for libs since the destroy_method only h
dt.preferences.register("generate_image_txt",
"enabled",
"bool",
"create txt sidecars to display with images",
"the txt files created get shown when the lighttable is zoomed in to one image. also enable the txt overlay setting in the gui tab",
_("create txt sidecars to display with images"),
_("the txt files created get shown when the lighttable is zoomed in to one image. also enable the txt overlay setting in the gui tab"),
false)
dt.preferences.register("generate_image_txt",
"command",
"string",
"command to generate the txt sidecar",
"the output of this command gets written to the txt file. use $(FILE_NAME) for the image file",
_("command to generate the txt sidecar"),
_("the output of this command gets written to the txt file. use $(FILE_NAME) for the image file"),
"exiv2 $(FILE_NAME)")
local check_command = function(command)
if not command:find("$(FILE_NAME)", 1, true) then
dt.print("the command for txt sidecars looks bad. better check the preferences")
dt.print(_("the command for txt sidecars looks bad. better check the preferences"))
end
end

View File

@@ -33,10 +33,25 @@ local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "image_path_in_ui")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("image_path_in_ui", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "image_path_in_ui",
purpose = _("print the image path in the UI"),
author = "Jérémy Rosen",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/image_path_in_ui"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again

View File

@@ -32,20 +32,42 @@ USAGE
local dt = require "darktable"
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("import_filter_manager", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
local script_data = {}
script_data.metadata = {
name = "import_filter_manager",
purpose = _("manage import filters"),
author = "Tobias Ellinghaus",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/import_filter_manager"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local import_filter_list = {}
local n_import_filters = 1
-- allow changing the filter from the preferences
dt.preferences.register("import_filter_manager", "active_filter", "string",
"import filter", "the name of the filter used for importing images", "")
_("import filter"), _("the name of the filter used for importing images"), "")
-- the dropdown to select the active filter from the import dialog
local filter_dropdown = dt.new_widget("combobox")
{
label = "import filter",
label = _("import filter"),
editable = false,
tooltip = "import filters are applied after completion of the import dialog",
tooltip = _("import filters are applied after completion of the import dialog"),
changed_callback = function(widget)
dt.preferences.write("import_filter_manager", "active_filter", "string", widget.value)
@@ -75,6 +97,12 @@ dt.register_import_filter = function(name, callback)
if name == active_filter then filter_dropdown.value = n_import_filters end
end
local function destroy()
--noting to destroy
end
script_data.destroy = destroy
return script_data
-- vim: shiftwidth=2 expandtab tabstop=2 cindent
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on;

View File

@@ -30,11 +30,33 @@ USAGE
local dt = require "darktable"
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("import_filters", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
local script_data = {}
script_data.metadata = {
name = "import_filters",
purpose = _("import filtering"),
author = "Tobias Ellinghaus & Christian Mandel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/import_filters"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- we get fed a sorted list of filenames. just setting images to ignore to nil is enough
-- ignore jpeg
dt.register_import_filter("ignore jpegs", function(event, images)
dt.print_error("ignoring all jpegs")
dt.print_log("ignoring all jpegs")
for i, img in ipairs(images) do
local extension = img:match("[^.]*$"):upper()
if (extension == "JPG") or (extension == "JPEG") then
@@ -88,5 +110,13 @@ dt.register_import_filter("prefer raw over jpeg", function(event, images)
end)
local function destroy()
-- nothing to destroy
end
script_data.destroy = destroy
return script_data
-- vim: shiftwidth=2 expandtab tabstop=2 cindent
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on;

View File

@@ -38,10 +38,25 @@ local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "save_selection")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("save_selection", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "save_selection",
purpose = _("shortcuts providing multiple selection buffers"),
author = "Jérémy Rosen",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/save_selection"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -61,16 +76,16 @@ for i = 1, buffer_count do
local saved_selection
dt.register_event("save_selection save " .. i, "shortcut", function()
saved_selection = dt.gui.selection()
end, "save to buffer " .. i)
end, string.format(_("save to buffer %d"), i))
dt.register_event("save_selection restore " .. i, "shortcut", function()
dt.gui.selection(saved_selection)
end, "restore from buffer " .. i)
end, string.format(_("restore from buffer %d"), i))
end
local bounce_buffer = {}
dt.register_event("save_selection switch", "shortcut", function()
bounce_buffer = dt.gui.selection(bounce_buffer)
end, "switch selection with temporary buffer")
end, _("switch selection with temporary buffer"))
script_data.destroy = destroy

View File

@@ -38,10 +38,25 @@ local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "selection_to_pdf")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("selection_to_pdf", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "selection_to_pdf",
purpose = _("generate a pdf file of selected images"),
author = "Jérémy Rosen & Pascal Obry",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/selection_to_pdf"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -49,16 +64,16 @@ script_data.show = nil -- only required for libs since the destroy_method only h
dt.preferences.register
("selection_to_pdf","Open with","string",
"a pdf viewer",
"Can be an absolute pathname or the tool may be in the PATH",
_("a pdf viewer"),
_("can be an absolute pathname or the tool may be in the PATH"),
"xdg-open")
local title_widget = dt.new_widget("entry") {
placeholder="Title"
placeholder = _("title")
}
local no_of_thumbs_widget = dt.new_widget("slider")
{
label = "Thumbs per Line",
label = _("thumbs per line"),
soft_min = 1, -- The soft minimum value for the slider, the slider can't go beyond this point
soft_max = 10, -- The soft maximum value for the slider, the slider can't go beyond this point
hard_min = 1, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point
@@ -66,10 +81,10 @@ local no_of_thumbs_widget = dt.new_widget("slider")
value = 4 -- The current value of the slider
}
local widget = dt.new_widget("box") {
orientation=horizontal,
dt.new_widget("label"){label = "Title:"},
orientation = horizontal,
dt.new_widget("label"){label = _("title:")},
title_widget,
dt.new_widget("label"){label = "Thumbnails per row:"},
dt.new_widget("label"){label = _("thumbnails per row:")},
no_of_thumbs_widget
}
@@ -116,7 +131,7 @@ local function destroy()
dt.print_log("done destroying")
end
dt.register_storage("export_pdf","Export thumbnails to pdf",
dt.register_storage(_("export_pdf"),_("export thumbnails to pdf"),
nil,
function(storage,image_table)
local my_title = title_widget.text
@@ -163,7 +178,7 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
local command = "pdflatex -halt-on-error -output-directory "..dir.." "..locfile
local result = dt.control.execute(command)
if result ~= 0 then
dt.print("Problem running pdflatex") -- this one is probably usefull to the user
dt.print(_("problem running pdflatex")) -- this one is probably usefull to the user
error("Problem running "..command)
end
@@ -173,7 +188,7 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
command = command.." "..pdffile
local result = dt.control.execute(command)
if result ~= 0 then
dt.print("Problem running pdf viewer") -- this one is probably usefull to the user
dt.print(_("problem running pdf viewer")) -- this one is probably usefull to the user
error("Problem running "..command)
end

View File

@@ -31,13 +31,29 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "executable_manager")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("executable_manager", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = "executable_manager",
purpose = _("manage the list of external executables used by the lua scripts"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/executable_manager"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
@@ -45,10 +61,6 @@ script_data.show = nil -- only required for libs since the destroy_method only h
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local gettext = dt.gettext
gettext.bindtextdomain("executable_manager",dt.configuration.config_dir.."/lua/locale/")
local exec_man = {} -- our own namespace
exec_man.module_installed = false
exec_man.event_registered = false
@@ -57,10 +69,6 @@ exec_man.event_registered = false
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - - - - - -
local function _(msg)
return gettext.dgettext("executable_manager", msg)
end
local function grep(file, pattern)
local result = {}
@@ -100,13 +108,19 @@ local function update_combobox_choices(combobox, choice_table, selected)
end
local function install_module()
local panel = "DT_UI_CONTAINER_PANEL_LEFT_BOTTOM"
local panel_pos = 600
if dt.configuration.running_os == "windows" then
panel = "DT_UI_CONTAINER_PANEL_LEFT_CENTER"
panel_pos = 100
end
if not exec_man.module_installed then
dt.register_lib(
"executable_manager", -- Module name
"executable manager", -- Visible name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_BOTTOM", 600}}, -- containers
{[dt.gui.views.lighttable] = {panel, panel_pos}}, -- containers
dt.new_widget("box") -- widget
{
orientation = "vertical",
@@ -142,7 +156,7 @@ local matches = grep(DARKTABLERC, "executable_paths")
-- check if we have something to manage and exit if not
if #matches == 0 then
dt.print(_("No executable paths found, exiting..."))
dt.print(_("no executable paths found, exiting..."))
return
end
@@ -167,7 +181,7 @@ for i,exec in ipairs(exec_table) do
editable = false
}
executable_path_widgets[exec] = dt.new_widget("file_chooser_button"){
title = _("select ") .. exec .. _(" executable"),
title = _(string.format("select %s executable", exec)),
value = df.get_executable_path_preference(exec),
is_directory = false,
changed_callback = function(self)
@@ -210,7 +224,7 @@ for i,exec in ipairs(exec_table) do
dt.new_widget("section_label"){label = _("reset")},
dt.new_widget("button"){
label = _("clear"),
tooltip = _("Clear path for ") .. exec,
tooltip = string.format(_("clear path for %s"), exec),
clicked_callback = function()
df.set_executable_path_preference(exec, "")
executable_path_widgets[exec].value = ""

View File

@@ -1,108 +0,0 @@
--[[
gen_18n_mo.lua - generate .mo files from .po files and put them in the correct place
Copyright (C) 2016,2018 Bill Ferguson <wpferguson@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
gen_i18n_mo - generate translation files from the source and place them in the appropriate locale directory
gen_i18n_mo finds all the .po files scattered throughout the script tree, compiles them into
.mo files and places them in the correct locale directory for use by the gettext tools.
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local log = require "lib/dtutils.log"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("5.0.0", "gen_I18n_mo")
local function destroy()
-- nothing to destroy
end
-- figure out the path separator
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local LUA_DIR = dt.configuration.config_dir .. PS .. "lua" .. PS
local LOCALE_DIR = dt.configuration.config_dir .. PS .. "lua" .. PS .. "locale" .. PS
-- check if we have msgfmt
local msgfmt_executable = df.check_if_bin_exists("msgfmt")
if msgfmt_executable then
-- find the .po files
local find_cmd = "find -L " .. LUA_DIR .. " -name \\*.po -print"
if dt.configuration.running_os == "windows" then
find_cmd = "dir /b/s " .. LUA_DIR .. "\\*.po"
end
local output = io.popen(find_cmd)
-- for each .po file....
for line in output:lines() do
local fname = df.get_filename(line)
-- get the language used... this depends on the file being named using
-- the convention /..../lang/LC_MESSAGES/file.po where lang is de_DE, fr_FR, etc.
local path_parts = du.split(line, PS)
local lang = path_parts[#path_parts - 2]
-- ensure there is a destination directory for them
local mkdir_cmd = "mkdir -p "
if dt.configuration.running_os == "windows" then
mkdir_cmd = "mkdir "
end
if not df.check_if_file_exists(LOCALE_DIR .. lang .. PS .. "LC_MESSAGES") then
log.msg(log.info, "Creating locale", lang)
os.execute(mkdir_cmd .. LOCALE_DIR .. lang .. PS .. "LC_MESSAGES")
end
-- generate the mo file
fname = string.gsub(fname, ".po$", ".mo")
log.msg(log.info, "Compiling translation to", fname)
local result = os.execute(msgfmt_executable .. " -o " .. LOCALE_DIR .. lang .. PS .. "LC_MESSAGES" .. PS .. fname .. " " .. line)
end
else
log.msg(log.screen, "ERROR: msgfmt executable not found. Please install or specifiy location in preferences.")
end
dt.preferences.register("executable_paths", "msgfmt", -- name
"file", -- type
'gen_i18n_mo: msgfmt location', -- label
'Install location of msgfmt. Requires restart to take effect.', -- tooltip
"msgfmt", -- default
dt.new_widget("file_chooser_button"){
title = "Select msgfmt[.exe] file",
value = "",
is_directory = false,
}
)
local script_data = {}
script_data.destroy = destroy
return script_data

View File

@@ -7,11 +7,20 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local log = require "lib/dtutils.log"
local libname = nil
du.check_min_api_version("3.0.0", "get_lib_manpages")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("get_lib_manpages", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
local function destroy()
-- nothing to destroy
end
@@ -79,6 +88,14 @@ for line in output:lines() do
end
local script_data = {}
script_data.metadata = {
name = "get_lib_manpages",
purpose = _("output the internal library documentation as man pages"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/get_lib_manpages"
}
script_data.destroy = destroy
return script_data

View File

@@ -6,9 +6,18 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("3.0.0", "get_libdoc")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("get_libdoc", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
local function destroy()
-- nothing to destroy
end
@@ -53,6 +62,14 @@ for line in output:lines() do
end
local script_data = {}
script_data.metadata = {
name = "get_libdoc",
purpose = _("retrieve and print the documentation to the console"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/get_libdoc"
}
script_data.destroy = destroy
return script_data

File diff suppressed because it is too large Load Diff