SDL icon indicating copy to clipboard operation
SDL copied to clipboard

SDL3: cannot set file dialog caption

Open d-musique opened this issue 1 year ago • 6 comments

The new file dialog API does not allow the title of the dialog to be set. This would be good to have, if only to be able to make property localized applications. (The Linux titles are hardcoded.)

SDL 3.1.3

d-musique avatar Oct 09 '24 06:10 d-musique

Good point. @Semphriss, can you find a way to fix this without changing the ABI? Maybe add a property-based dialog creation function?

slouken avatar Oct 09 '24 14:10 slouken

IIRC, there were a few options to change the appearance of file dialogs, including the title, buttons' labels, and more, but their availability varied greatly between platforms, so I initially left anything cosmetic out of the (already quite long) functions.

I can make a function like SDL_ShowFileDialogWithProperties that could support more options; is there anything else other than the title that I should add? I can try to see what different platforms support and propose what's available.

Semphriss avatar Oct 09 '24 16:10 Semphriss

IIRC, there were a few options to change the appearance of file dialogs, including the title, buttons' labels, and more, but their availability varied greatly between platforms, so I initially left anything cosmetic out of the (already quite long) functions.

That makes sense. A properties based API has more flexibility, because it can ignore anything that isn't supported on the platform.

I can try to see what different platforms support and propose what's available.

Sure, that would be great.

slouken avatar Oct 09 '24 16:10 slouken

+1 for properties API

Concerning my particular use case, only the title has importance, because other labels are already localized by OS.

The portal has its title harcoded around here; for information, I already tried replacing it with an empty string, hoping the portal might provide a default localized name in its place, but the dialog just came up with an empty title.

https://github.com/libsdl-org/SDL/blob/02f3a96476c46e4a03a2e06d5edd1d8f7aa69d4f/src/dialog/unix/SDL_portaldialog.c#L430

d-musique avatar Oct 09 '24 17:10 d-musique

@slouken I would need advice for a design decision: I noticed that some functions which accept properties have their mandatory arguments separate from the properties. For file dialogs, the only really mandatory option is the callback function. Should I:

  • have the function and its userdata pointer as separate parameters?
  • have just the function as a separate parameter, and have the userdata (and the other params) in the properties?
  • have them all in the properties?

Semphriss avatar Oct 11 '24 16:10 Semphriss

Good question. Let's have the function and userdata as separate parameters.

slouken avatar Oct 11 '24 16:10 slouken

I am able to confirm that the API works on x11, and the title/window/filters/location properties work as expected.

d-musique avatar Dec 04 '24 23:12 d-musique

I am able to confirm that the API works on x11, and the title/window/filters/location properties work as expected.

Great, thanks!

slouken avatar Dec 05 '24 00:12 slouken