Skip to content

Give some love to LUA preferences#20694

Open
masterpiga wants to merge 2 commits intodarktable-org:masterfrom
masterpiga:lua_config
Open

Give some love to LUA preferences#20694
masterpiga wants to merge 2 commits intodarktable-org:masterfrom
masterpiga:lua_config

Conversation

@masterpiga
Copy link
Copy Markdown
Contributor

Lua preferences UI improvements

Addresses #20692 — the flat, unsorted list of Lua preferences is replaced with a structured UI.

Co-authored with Claude.

As requested by @wpferguson.

Screen.Recording.2026-03-28.at.07.31.42.mp4

UI changes

  • Global scripts (script_manager, _scripts_install) keep their preferences at the top level, ungrouped
  • Per-script preferences are grouped behind a combobox selector; scripts are sorted alphabetically by display name
  • A section label below the combobox updates to reflect the selected script, visually grouping its preferences

New Lua API

Scripts can register a human-readable display name used in the combobox:

darktable.preferences.register_script_name("OpenInExplorer", _("open in explorer"))

Falls back to the internal script name if no display name is registered.

Bug fixes

  • Fixed ref leak in destroy_tab_lua: the extra g_object_ref before gtk_container_remove was unnecessary (the widget is already kept alive by pref_element via g_object_ref_sink) and was never balanced
  • Fixed GtkSizeGroup leak on early return when no per-script preferences exist

Code cleanup

  • Use dt_ui_label_new instead of gtk_label_new per GUI guidelines (ensures proper text ellipsization)
  • Collapsed five identical string-read cases in read_pref into a single fallthrough
  • Collapsed four identical string-write cases in write_pref into a single fallthrough
  • Merged the identical response_callback_dir and response_callback_file into response_callback_filechooser

@TurboGit TurboGit added lua scope: UI user interface and interactions labels Mar 28, 2026
@TurboGit TurboGit added this to the 5.6 milestone Mar 28, 2026
@TurboGit
Copy link
Copy Markdown
Member

I like it but I'll let @wpferguson have the final word on this.

Thanks @masterpiga and Claude.

@wpferguson
Copy link
Copy Markdown
Member

@masterpiga I like it. You can take out _scripts_installer. It's going away for 5.6, since the scripts will be bundled in the release. tools/scripts_installer will replace it and only get run when the user wants to install the latest version of the scripts.

I'm trying to decide about darktable.preferences.register_script_name. My thoughts/questions are

  • Can we do an optional second argument to dt.preferences.register(MODULE, script_data.metadata.name, ...?
  • Or maybe we could just change the arguments to dt.references.register(script_data.metadata.name, ... though I'd have to check how spaces in preferences are handled. Maybe not a good idea.
  • Or we stick with what you suggested 😄

I'll play with it a little bit.

Thanks @masterpiga and Claude

@wpferguson
Copy link
Copy Markdown
Member

wpferguson commented Mar 28, 2026

After a little testing....

Boy, it's so much nicer...

I tried option 2 above, script_data.metadata.name and it works. However, that is translatable and I'm not sure how well Lua with handle the translated string, so I think it's probably best to go with the additional function. That way we don't have compatibility issues.

It's good for me. Thanks again @masterpiga

EDIT: @TurboGit 👍 👍

@masterpiga
Copy link
Copy Markdown
Contributor Author

Glad that you like it, @wpferguson and @TurboGit :)

@wpferguson so in the end I am not sure if you asked for any changes other than the handling of _script_install. And also there, I am not sure what you mean with "remove". Should I not include it in _global_scripts? In that case it will get its own entry in the combobox. Or should it just be ignored? Or will you take care of it in a follow up?

@wpferguson
Copy link
Copy Markdown
Member

so in the end I am not sure if you asked for any changes other than the handling of _script_install

Correct

Should I not include it in _global_scripts?

Yes, it's going to go away in a few weeks (or less, I hope). If you don't include it in the _global_scripts, it will hang around as a separate entry in the combobox and then just disappear when it's removed.

@masterpiga
Copy link
Copy Markdown
Contributor Author

Thanks for clarifying, @wpferguson. Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lua scope: UI user interface and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants