GTK4: How to replace GtkFileChooserButton

Since a recent MR, GtkFileChooserButton is no more. The MR does not discuss the reasoning for removing it, so we have no guidance on how to live without it. If it was a maintenance nightmare, then an application could build something similar but simpler, with a GtkButton that pops up a GtkFileChooserDialog, but if it was deemed bad UI/UX then that would be a bad idea. Is there a recommended strategy?

1 Like

That’s a bug in the documentation: the migration guide should mention the removal and possible replacements.

It wasn’t a maintenance nightmare, but the file chooser button widget was a bad UI.

The file chooser button would randomly show a “None” label without a pre-selected location, or pop up an arbitrarily large list of directories, except it was meant to actually select files; additionally, a popup and a modal dialog would compete for grabs, pointer, and selection, which lead to races when it came to closing the popup before showing the file selection dialog.

The file chooser button was ever meant to be used in the case where you wanted to select the folder to save a file you already named, or to specify a location for saving file types like “drafts”.

The recommended strategy is to use a button that pops up a GtkFileChooserDialog.

In general, though, it depends on the design of your UI—which is one of the reasons why the GtkFileChooserButton, with its complex interaction model and “one size fits all” approach, was not a great widget.

2 Likes

@ebassi Thanks for the insights!

It’s understandable that the guide lags the code a little :sunglasses:

In theory, the MR that removed the widget would have also added the mention in the porting guide; it was an oversight.

I’ve opened a new MR for the documentation.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.