Store presets for own custom Lua widget

Hello guys,

using LUA scripting, I have a custom written widget on the right module list of the darkroom view.

I am trying to enable the preset functionality (the small icon in the top right corner of each module) to store user preset.

Does somebody know how to enable this and give me a hint? Thank you very much!

1 Like

I think dt.preferences.read and write should work, have a look at this script:

Hello Tobias,

thank you very much for the quick reply. I have tried intensively your suggestions.
But still I am not able to store presets for the widget using the “sandwich” icon on the top right corner of my module.

darktable.preferences.register and darktable.preferences.write are working both fine for my code. If I register the preference I can easily manipulate it from the built-in perferences dialog under the section “lua options”. But I cannot store it as preset.

For the second button in the top right corner I successfully use the “reset_callback” of the widget that I add using darktable.register_lib. But there is no “store-presets_callback”.

Any further ideas?

There’s good news and bad news…

The good news is that there is some support in the Lua API for presets contained in src/lua/modules.c.

The bad news is that it was written 10 years ago and doesn’t appear to do much. I came across it several weeks ago and haven’t had time to play with it.

Hi Bill,

I am not very good in c, but I tried to understand it nevertheless. Unfortunately I was not able to derive how call those functions from a lua script and which parameters to hand over.

local darktable = require “darktable”
=> darktable.modules is nil.

Could someone guide me?