Index: app/file/file-save.c
===================================================================
RCS file: /cvs/gnome/gimp/app/file/file-save.c,v
retrieving revision 1.58
diff -u -3 -p -r1.58 file-save.c
--- app/file/file-save.c	3 Feb 2005 23:14:42 -0000	1.58
+++ app/file/file-save.c	6 Feb 2005 06:09:28 -0000
@@ -97,8 +97,8 @@ GimpPDBStatusType
 file_save_as (GimpImage      *gimage,
               GimpContext    *context,
               GimpProgress   *progress,
-              const gchar    *uri,
-              const gchar    *raw_filename,
+              const gchar    *input_uri,
+              const gchar    *input_raw_filename,
               PlugInProcDef  *file_proc,
               GimpRunMode     run_mode,
               gboolean        save_a_copy,
@@ -110,19 +110,35 @@ file_save_as (GimpImage      *gimage,
   GimpPDBStatusType  status;
   gint               i;
   gchar             *filename;
+  gchar             *raw_filename = NULL;
+  gboolean           add_default_extension = FALSE;
+  gchar             *uri = NULL;
 
   g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_PDB_CALLING_ERROR);
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), GIMP_PDB_CALLING_ERROR);
   g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress),
                         GIMP_PDB_CALLING_ERROR);
-  g_return_val_if_fail (uri != NULL, GIMP_PDB_CALLING_ERROR);
-  g_return_val_if_fail (raw_filename != NULL, GIMP_PDB_CALLING_ERROR);
+  g_return_val_if_fail (input_uri != NULL, GIMP_PDB_CALLING_ERROR);
+  g_return_val_if_fail (input_raw_filename != NULL, GIMP_PDB_CALLING_ERROR);
   g_return_val_if_fail (error == NULL || *error == NULL,
                         GIMP_PDB_CALLING_ERROR);
 
   if (gimp_image_active_drawable (gimage) == NULL)
     return GIMP_PDB_EXECUTION_ERROR;
 
+  if (strchr(input_raw_filename, '.') == NULL)
+    {
+      add_default_extension = TRUE;
+      raw_filename = g_strdup_printf("%s.xcf", input_raw_filename);
+      uri = g_strdup_printf("%s.xcf", input_uri);
+    }
+  else
+    {
+      add_default_extension = FALSE;
+      raw_filename = g_strdup(input_raw_filename);
+      uri = g_strdup(input_uri);
+    }
+
   if (! file_proc)
     file_proc = file_utils_find_proc (gimage->gimp->save_procs, raw_filename);
 
@@ -130,6 +146,8 @@ file_save_as (GimpImage      *gimage,
     {
       g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                    _("Unknown file type"));
+      g_free (raw_filename);
+      g_free (uri);
       return GIMP_PDB_CALLING_ERROR;
     }
 
@@ -145,6 +163,8 @@ file_save_as (GimpImage      *gimage,
               g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                            _("Not a regular file"));
               g_free (filename);
+              g_free (raw_filename);
+              g_free (uri);
               return GIMP_PDB_EXECUTION_ERROR;
             }
 
@@ -153,6 +173,8 @@ file_save_as (GimpImage      *gimage,
               g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_ACCES,
                            g_strerror (errno));
               g_free (filename);
+              g_free (raw_filename);
+              g_free (uri);
               return GIMP_PDB_EXECUTION_ERROR;
             }
         }
@@ -222,8 +244,11 @@ file_save_as (GimpImage      *gimage,
 
   g_free (return_vals);
   g_free (args);
+  g_free (raw_filename);
+  g_free (uri);
 
   g_object_unref (gimage);
 
   return status;
 }
+
