[gimp] app: don't remove dirname in save dialog when adding file extension
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: don't remove dirname in save dialog when adding file extension
- Date: Sun, 9 Jul 2017 18:45:27 +0000 (UTC)
commit 27d5dcf20a3dc3189ff8cacee6a32fc060459570
Author: Ell <ell_se yahoo com>
Date: Sun Jul 9 14:34:51 2017 -0400
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.
app/dialogs/file-save-dialog.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c
index b22f88b..4457dc2 100644
--- a/app/dialogs/file-save-dialog.c
+++ b/app/dialogs/file-save-dialog.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]