Index: gnome-panel-screenshot.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/gnome-panel-screenshot.c,v
retrieving revision 1.85
diff -u -p -r1.85 gnome-panel-screenshot.c
--- gnome-panel-screenshot.c	16 May 2005 19:32:04 -0000	1.85
+++ gnome-panel-screenshot.c	6 Jul 2005 12:49:54 -0000
@@ -55,6 +55,7 @@ static char *window_title = NULL;
 static char *temporary_file = NULL;
 static gboolean drop_shadow = TRUE;
 static gboolean save_immediately = FALSE;
+static gboolean success = FALSE;
 
 /* Options */
 static gboolean take_window_shot = FALSE;
@@ -182,15 +183,32 @@ save_folder_to_gconf (ScreenshotDialog *
   gconf_client = gconf_client_get_default ();
 
   folder = screenshot_dialog_get_folder (dialog);
-  /* Error is NULL, as there's nothing we can do */
-  gconf_client_set_string (gconf_client,
-			   "/apps/gnome-screenshot/last_save_directory",
-			   folder, NULL);
+  if (folder)
+    {
+      /* Error is NULL, as there's nothing we can do */
+      gconf_client_set_string (gconf_client,
+			       "/apps/gnome-screenshot/last_save_directory",
+			       folder, NULL);
+      g_free (folder);
+    }
 
   g_object_unref (gconf_client);
 }
 
-static gboolean
+static void
+xfer_done_cb (GnomeVFSResult res,
+	      gpointer       data)
+{
+  GtkWidget *toplevel;
+  ScreenshotDialog *dialog = data;
+
+  g_print ("result: %s\n", gnome_vfs_result_to_string (res));
+
+  screenshot_dialog_set_busy (dialog, FALSE);
+  success = (res == GNOME_VFS_OK);
+}
+
+static void
 try_to_save (ScreenshotDialog *dialog,
 	     const char       *target)
 {
@@ -200,27 +218,17 @@ try_to_save (ScreenshotDialog *dialog,
 
   g_assert (temporary_file);
 
-  screenshot_dialog_set_busy (dialog, TRUE);
-
   source_uri = gnome_vfs_uri_new (temporary_file);
   target_uri = gnome_vfs_uri_new (target);
 
   result = screenshot_xfer_uri (source_uri,
 				target_uri,
-				screenshot_dialog_get_toplevel (dialog));
+				screenshot_dialog_get_toplevel (dialog),
+				xfer_done_cb,
+				dialog);
 
   gnome_vfs_uri_unref (source_uri);
   gnome_vfs_uri_unref (target_uri);
-
-  screenshot_dialog_set_busy (dialog, FALSE);
-
-  if (result == GNOME_VFS_OK)
-    {
-      save_folder_to_gconf (dialog);
-      return TRUE;
-    }
-
-  return FALSE;
 }
 
 static void
@@ -253,6 +261,14 @@ run_dialog (ScreenshotDialog *dialog)
   do
     {
       keep_going = FALSE;
+
+      if (success)
+        {
+          /* the save has been completed */
+          save_folder_to_gconf (dialog);
+          break;
+        }
+
       result = gtk_dialog_run (GTK_DIALOG (toplevel));
       switch (result)
 	{
@@ -261,20 +277,22 @@ run_dialog (ScreenshotDialog *dialog)
 	  keep_going = TRUE;
 	  break;
 	case GTK_RESPONSE_OK:
-	  uri = screenshot_dialog_get_uri (dialog);
+	  screenshot_dialog_set_busy (dialog, TRUE);
+
+	  /* make sure to save the temp file */
 	  if (temporary_file == NULL)
 	    {
 	      save_immediately = TRUE;
-	      screenshot_dialog_set_busy (dialog, TRUE);
 	      keep_going = TRUE;
+	      break;	
 	    }
-	  else
-	    {
-	      /* We've saved the temporary file.  Lets try to copy it to the
-	       * correct location */
-	      if (! try_to_save (dialog, uri))
-		keep_going = TRUE;
-	    }
+
+	  /* We've saved the temporary file.  Lets try to copy it to the
+	   * correct location */
+	  uri = screenshot_dialog_get_uri (dialog);
+	  try_to_save (dialog, uri);
+	  g_free (uri);
+	  keep_going = TRUE;
 	  break;
 	default:
 	  break;
Index: screenshot-xfer.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/screenshot-xfer.c,v
retrieving revision 1.3
diff -u -p -r1.3 screenshot-xfer.c
--- screenshot-xfer.c	10 Nov 2004 06:20:32 -0000	1.3
+++ screenshot-xfer.c	6 Jul 2005 12:49:54 -0000
@@ -18,6 +18,8 @@ typedef struct
   gboolean delete_target;
   guint timeout_id;
   gboolean canceled;
+  XferResFunc callback;
+  gpointer callback_data;
 } TransferInfo;
 
 static gboolean show_dialog_timeout (TransferInfo *transfer_info);
@@ -70,7 +72,9 @@ handle_transfer_ok (const GnomeVFSXferPr
 	{
 	  transfer_info->delete_target = TRUE;
 	}
-
+      if (transfer_info->callback)
+        transfer_info->callback (progress_info->vfs_status,
+				 transfer_info->callback_data);
       gtk_main_quit ();
       return 0;
     }
@@ -83,6 +87,9 @@ handle_transfer_ok (const GnomeVFSXferPr
 	  gtk_widget_destroy (transfer_info->progress_dialog);
 	  transfer_info->progress_dialog = NULL;
 	}
+      if (transfer_info->callback)
+        transfer_info->callback (progress_info->vfs_status,
+				 transfer_info->callback_data);
       gtk_main_quit ();
       return 0;
     }
@@ -158,7 +165,9 @@ handle_transfer_vfs_error (GnomeVFSXferP
       gtk_widget_destroy (transfer_info->progress_dialog);
       transfer_info->progress_dialog = NULL;
     }
-  gtk_main_quit ();
+  if (transfer_info->callback)
+    transfer_info->callback (progress_info->vfs_status,
+			     transfer_info->callback_data);
   return 1;
 }
 
@@ -195,7 +204,7 @@ handle_transfer_overwrite (const GnomeVF
   if (response == GTK_RESPONSE_OK)
     return GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE;
   else
-    return GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP;
+    return GNOME_VFS_XFER_OVERWRITE_ACTION_ABORT;
 
   if (need_timeout)
     add_timeout (transfer_info);
@@ -247,7 +256,9 @@ show_dialog_timeout (TransferInfo *trans
 GnomeVFSResult
 screenshot_xfer_uri (GnomeVFSURI *source_uri,
 		     GnomeVFSURI *target_uri,
-		     GtkWidget   *parent)
+		     GtkWidget   *parent,
+		     XferResFunc  callback,
+		     gpointer     callback_data)
 {
   GnomeVFSResult result;
   GList *source_uri_list = NULL;
@@ -260,6 +271,9 @@ screenshot_xfer_uri (GnomeVFSURI *source
   transfer_info = g_new0 (TransferInfo, 1);
   transfer_info->parent_dialog = parent;
   add_timeout (transfer_info);
+
+  transfer_info->callback = callback;
+  transfer_info->callback_data = callback_data;
 
   result = gnome_vfs_async_xfer (&transfer_info->handle,
 				 source_uri_list, target_uri_list,
Index: screenshot-xfer.h
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-screenshot/screenshot-xfer.h,v
retrieving revision 1.3
diff -u -p -r1.3 screenshot-xfer.h
--- screenshot-xfer.h	10 Nov 2004 06:20:32 -0000	1.3
+++ screenshot-xfer.h	6 Jul 2005 12:49:54 -0000
@@ -4,8 +4,12 @@
 #include <gtk/gtk.h>
 #include <libgnomevfs/gnome-vfs.h>
 
+typedef void (*XferResFunc) (GnomeVFSResult result, gpointer data);
+
 GnomeVFSResult screenshot_xfer_uri (GnomeVFSURI *source_uri,
 				    GnomeVFSURI *target_uri,
-				    GtkWidget   *parent);
+				    GtkWidget   *parent,
+				    XferResFunc  callback,
+				    gpointer     callback_data);
 
 #endif /* __SCREENSHOT_XFER_H__ */
