mirror of https://github.com/GNOME/gimp.git
app: don't remove dirname in save dialog when adding file extension
When the user provides a filename without an extension in the save dialog, we add one for them, update the filename in the dialog, and retry. However, the updated filename is made up of only the basename, leaving out the dirname part, if specified. This means that if the user enters "/somedir/somefile", the new filename becomes "somefile.xcf", which refers to the current directory, instead of "somedir". Fix this by maintaining the dirname when adding a file extension.
This commit is contained in:
parent
5bf0e3c3d2
commit
27d5dcf20a
|
@ -337,6 +337,8 @@ file_save_dialog_check_file (GtkWidget *dialog,
|
|||
if (ext)
|
||||
{
|
||||
gchar *ext_basename;
|
||||
gchar *dirname;
|
||||
gchar *filename;
|
||||
gchar *utf8;
|
||||
|
||||
GIMP_LOG (SAVE_DIALOG, "appending .%s to basename", ext);
|
||||
|
@ -346,11 +348,17 @@ file_save_dialog_check_file (GtkWidget *dialog,
|
|||
g_free (basename);
|
||||
basename = ext_basename;
|
||||
|
||||
utf8 = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
|
||||
dirname = g_path_get_dirname (gimp_file_get_utf8_name (file));
|
||||
filename = g_build_filename (dirname, basename, NULL);
|
||||
g_free (dirname);
|
||||
|
||||
utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
|
||||
utf8);
|
||||
g_free (utf8);
|
||||
|
||||
g_free (filename);
|
||||
|
||||
GIMP_LOG (SAVE_DIALOG,
|
||||
"set basename to %s, rerunning response and bailing out",
|
||||
basename);
|
||||
|
|
Loading…
Reference in New Issue