GTK4 FileDialog with choices option

Hi there, I’d like to create a file saving dialog with additional choices, e.g.,

  • As Draft
  • Rasterized

The since 4.10 deprecated FileChooser.add_choice function was useful for this kind of addition. With the as replacement recommended FileDialog, I only see the workaround of adding another dialog for saving options, which is not very nice UX-wise. Is there something I am missing? Do you have suggestions? Thanks in advance!

The choice API does not fit into the model of the file dialog, which is why it was not implemented in GtkFileDialog, which is meant to be a “fire and forget” API that only gives you the path of the file selected by the user. Additionally, GTK does not control the file selection dialog that the user will actually interact with, so any functionality there is going to be optional.

The suggestion is to have a dialog that allows you to set up the various options, including choosing the destination file, instead of adding more functionality to the file selection dialog itself.

Thanks for your answer

Is it possible to create such an own dialog, but still using the portal’s functions? I still want that the application is sandboxed and doesn’t have access to arbitrary files …

You don’t need to deal with the portals yourself. What I’m proposing is to create a dialog like this mock up:

Where “Select file…” will use GtkFileDialog to select the file.

This is a very rough mock up; you could add a better UI control that contains the selected file name, for instance.

Ah, yes, thanks. Sure, this is the additional dialog option I wanted to avoid ;). It always will introduce one extra click. But if this is the recommended way today, I’ll go for that.

If you don’t want an “extra click”, then you’ll have to add those controls to the main window, and apply them to the current document; as soon as you make them part of the file saving operation, they will always be an additional control/click, even if you don’t use them. That has always been the trade-off.