GtkFileDialog set_initial_folder/set_initial_file not working
While trying the new GtkFileDialog to overcome GtkFileChooserDialog deprecations on Gtk 4.10, I've come across a misbehavior:
If we use gtk_file_dialog_set_initial_folder/file functions the expected behavior does not occur and the dialog is always showing the Recent files.
After looking to the actual code, 4.10.3 branch, it's clear why it does not work:
gtk_file_dialog_set_initial_file:
void
gtk_file_dialog_set_initial_file (GtkFileDialog *self,
GFile *file)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
g_return_if_fail (file == NULL || G_IS_FILE (file));
gtk_file_dialog_set_initial_folder:
void
gtk_file_dialog_set_initial_folder (GtkFileDialog *self,
GFile *folder)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
g_return_if_fail (folder == NULL || G_IS_FILE (folder));
Steps to reproduce
- Create a GtkFileDialog
- use functions/methods to set an initial folder or file
- open the dialog and it will only show the Recent files and not what was set with the set_initial_* functions/methods
Current behavior
FileDialog only show the Recent files right after presenting itself to the user
Expected outcome
Should present the given folder or given file (and associated path)
Version information
Fedora 38 default Gtk 4.10.3
Additional information
I think that the conditions should check for non null pointers and eventually try to validate if these are GFile, eg:
gtk_file_dialog_set_initial_file:
...
g_return_if_fail (file != NULL && G_IS_FILE (file));
...
gtk_file_dialog_set_initial_folder:
...
g_return_if_fail (folder != NULL && G_IS_FILE (folder));
...
Thank you and keep up the good work