--- embed/mozilla/ContentHandler.cpp	2005/09/05 19:17:34	1.1
+++ embed/mozilla/ContentHandler.cpp	2005/09/05 20:57:50
@@ -463,6 +463,8 @@ NS_METHOD GContentHandler::MIMEDoAction 
 	mLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
 	NS_ENSURE_TRUE (mimeInfo, NS_ERROR_FAILURE);
 
+	char *info = NULL;
+
 	if (mAction == CONTENT_ACTION_OPEN)
 	{
 		g_return_val_if_fail (mHelperApp, NS_ERROR_FAILURE);
@@ -473,9 +475,15 @@ NS_METHOD GContentHandler::MIMEDoAction 
 		/* The current time is fine here as the user has just clicked
 		 * a button (it is used as the time for the application opening)
 		 */
-		char *info;
 		info = g_strdup_printf ("gnome-default:%d:%s", gtk_get_current_event_time(), id);
+	}
+	else if (mAction == CONTENT_ACTION_DOWNLOAD)
+	{
+		info = g_strdup_printf ("gnome-browse-to-file:%d", gtk_get_current_event_time());
+	}
 
+	if (info != NULL)
+	{
 		nsEmbedString desc;
 		NS_CStringToUTF16 (nsEmbedCString (info),
 			           NS_CSTRING_ENCODING_UTF8, desc);
--- embed/mozilla/MozDownload.cpp	2005/09/05 19:17:43	1.1
+++ embed/mozilla/MozDownload.cpp	2005/09/05 22:11:36
@@ -496,6 +496,23 @@ MozDownload::OnStateChange (nsIWebProgre
 				gnome_vfs_mime_application_free (helperApp);
 				g_strfreev (str);
 			}
+			else if (g_str_has_prefix (cDesc.get(), "gnome-browse-to-file:"))
+			{
+				/* Format gnome-browse-to-file:<usertime> */
+				char **str = g_strsplit (cDesc.get(), ":", -1);
+				g_return_val_if_fail (g_strv_length (str) == 2, NS_ERROR_FAILURE);
+
+				char *end;
+				guint32 user_time = strtoul (str[1], &end, 0);
+
+				nsEmbedCString aDest;
+				rv = mDestination->GetSpec (aDest);
+				NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+				ephy_file_browse_to (aDest.get (), user_time);
+
+				g_strfreev (str);
+			}
 		}
 	}
         
@@ -682,6 +699,15 @@ nsresult InitiateMozillaDownload (nsIDOM
 	EphyEmbedPersistFlags ephy_flags;
 	ephy_flags = ephy_embed_persist_get_flags (EPHY_EMBED_PERSIST (embedPersist));
 
+	if (!ephy_embed_persist_get_dest (EPHY_EMBED_PERSIST (embedPersist)))
+	{
+		nsEmbedCString cPath;
+		inDestFile->GetNativePath (cPath);
+
+		ephy_embed_persist_set_dest (EPHY_EMBED_PERSIST (embedPersist),
+				cPath.get());
+	}
+
 	PRBool isHTML = (contentType &&
 			(strcmp (contentType, "text/html") == 0 ||
 			 strcmp (contentType, "text/xml") == 0 ||
--- lib/ephy-file-helpers.c	2005/09/05 19:28:02	1.1
+++ lib/ephy-file-helpers.c	2005/09/05 20:57:50
@@ -992,6 +992,27 @@ ephy_file_launch_handler (const char *mi
 
 	return ret;
 }
+
+gboolean
+ephy_file_browse_to (const char *parameter,
+		     guint32 user_time)
+{
+	GnomeVFSURI *uri, *parent_uri;
+	gboolean ret;
+
+	uri = gnome_vfs_uri_new (parameter);
+	parent_uri = gnome_vfs_uri_get_parent (uri);
+
+	/* TODO find a way to make nautilus scroll to the actual file */
+	ret = ephy_file_launch_handler ("x-directory/normal", 
+					gnome_vfs_uri_get_path (parent_uri), 
+					user_time);
+	
+	gnome_vfs_uri_unref (uri);
+	gnome_vfs_uri_unref (parent_uri);
+
+	return ret;
+}
 
 struct _EphyFileMonitor
 {
--- lib/ephy-file-helpers.h	2005/09/05 19:28:04	1.1
+++ lib/ephy-file-helpers.h	2005/09/05 20:57:50
@@ -88,6 +88,9 @@ gboolean    ephy_file_launch_handler	 (c
 					  const char *address,
 					  guint32 user_time);
 
+gboolean    ephy_file_browse_to		 (const char *parameter,
+					  guint32 user_time);
+
 EphyFileMonitor *ephy_file_monitor_add	 (const char *uri,
 					  GnomeVFSMonitorType monitor_type,
 					  guint delay,
--- src/popup-commands.c	2005/09/05 21:17:48	1.1
+++ src/popup-commands.c	2005/09/05 21:41:55
@@ -168,6 +168,24 @@ popup_cmd_copy_link_address (GtkAction *
 }
 
 static void
+save_property_url_completed_cb (EphyEmbedPersist *persist)
+{
+	if (!(ephy_embed_persist_get_flags (persist) & 
+				EPHY_EMBED_PERSIST_ASK_DESTINATION))
+	{
+		const char *dest;
+		guint32 user_time;
+
+		user_time = ephy_embed_persist_get_user_time (persist);
+		dest = ephy_embed_persist_get_dest (persist);
+		g_return_if_fail (dest != NULL);
+
+		eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
+		ephy_file_browse_to (dest, user_time);
+	}
+}
+
+static void
 save_property_url (GtkAction *action,
 		   const char *title,
 		   EphyWindow *window,
@@ -201,6 +219,9 @@ save_property_url (GtkAction *action,
 		(persist, CONF_STATE_SAVE_DIR);
 	ephy_embed_persist_set_source (persist, location);
 
+	g_signal_connect (persist, "completed",
+			  G_CALLBACK (save_property_url_completed_cb), NULL);
+
 	ephy_embed_persist_save (persist);
 
 	g_object_unref (G_OBJECT(persist));
