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	7 Feb 2005 18:34:11 -0000
@@ -110,6 +110,8 @@ file_save_as (GimpImage      *gimage,
   GimpPDBStatusType  status;
   gint               i;
   gchar             *filename;
+  gchar             *raw_fn_with_ext = NULL;
+  gchar             *uri_with_ext = 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);
@@ -123,17 +125,31 @@ file_save_as (GimpImage      *gimage,
   if (gimp_image_active_drawable (gimage) == NULL)
     return GIMP_PDB_EXECUTION_ERROR;
 
+  if (strchr (raw_filename, '.') == NULL)
+    {
+      raw_fn_with_ext = g_strdup_printf ("%s.xcf", raw_filename);
+      uri_with_ext = g_strdup_printf ("%s.xcf", uri);
+    }
+  else
+    {
+      raw_fn_with_ext = g_strdup (raw_filename);
+      uri_with_ext = g_strdup (uri);
+    }
+
   if (! file_proc)
-    file_proc = file_utils_find_proc (gimage->gimp->save_procs, raw_filename);
+    file_proc = file_utils_find_proc (gimage->gimp->save_procs,
+                                      raw_fn_with_ext);
 
   if (! file_proc)
     {
       g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                    _("Unknown file type"));
+      g_free (raw_fn_with_ext);
+      g_free (uri_with_ext);
       return GIMP_PDB_CALLING_ERROR;
     }
 
-  filename = file_utils_filename_from_uri (uri);
+  filename = file_utils_filename_from_uri (uri_with_ext);
 
   if (filename)
     {
@@ -145,6 +161,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_fn_with_ext);
+              g_free (uri_with_ext);
               return GIMP_PDB_EXECUTION_ERROR;
             }
 
@@ -153,6 +171,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_fn_with_ext);
+              g_free (uri_with_ext);
               return GIMP_PDB_EXECUTION_ERROR;
             }
         }
@@ -171,8 +191,8 @@ file_save_as (GimpImage      *gimage,
   args[0].value.pdb_int     = run_mode;
   args[1].value.pdb_int     = gimp_image_get_ID (gimage);
   args[2].value.pdb_int     = gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gimage)));
-  args[3].value.pdb_pointer = (gpointer) (filename ? filename : uri);
-  args[4].value.pdb_pointer = (gpointer) raw_filename;
+  args[3].value.pdb_pointer = (gpointer) (filename ? filename : uri_with_ext);
+  args[4].value.pdb_pointer = (gpointer) raw_fn_with_ext;
 
   return_vals = procedural_db_execute (gimage->gimp, context, progress,
                                        proc->name, args);
@@ -191,28 +211,29 @@ file_save_as (GimpImage      *gimage,
         {
           /*  remember the "save-a-copy" filename for the next invocation  */
           g_object_set_data_full (G_OBJECT (gimage),
-                                  "gimp-image-save-a-copy", g_strdup (uri),
+                                  "gimp-image-save-a-copy", g_strdup (uri_with_ext),
                                   (GDestroyNotify) g_free);
         }
       else
 	{
           /*  reset the "save-a-copy" filename when the image URI changes  */
-          if (uri && strcmp (uri, gimp_image_get_uri (gimage)))
+          if (uri_with_ext && strcmp (uri_with_ext, gimp_image_get_uri (gimage)))
             g_object_set_data (G_OBJECT (gimage),
                                "gimp-image-save-a-copy", NULL);
 
-	  gimp_image_set_uri (gimage, uri);
+	  gimp_image_set_uri (gimage, uri_with_ext);
           gimp_image_set_save_proc (gimage, file_proc);
           gimp_image_clean_all (gimage);
 	}
 
       documents = GIMP_DOCUMENT_LIST (gimage->gimp->documents);
       imagefile = gimp_document_list_add_uri (documents,
-                                              uri, file_proc->mime_type);
+                                              uri_with_ext, 
+                                              file_proc->mime_type);
 
       gimp_imagefile_save_thumbnail (imagefile, file_proc->mime_type, gimage);
 
-      gimp_recent_list_add_uri (uri, file_proc->mime_type);
+      gimp_recent_list_add_uri (uri_with_ext, file_proc->mime_type);
     }
   else if (status != GIMP_PDB_CANCEL)
     {
@@ -222,8 +243,11 @@ file_save_as (GimpImage      *gimage,
 
   g_free (return_vals);
   g_free (args);
+  g_free (raw_fn_with_ext);
+  g_free (uri_with_ext);
 
   g_object_unref (gimage);
 
   return status;
 }
+
