aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/ContentHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'embed/mozilla/ContentHandler.cpp')
-rw-r--r--embed/mozilla/ContentHandler.cpp52
1 files changed, 30 insertions, 22 deletions
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index 0c7465174..6206b9d9a 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -281,8 +281,11 @@ NS_IMETHODIMP GContentHandler::
nsCOMPtr<nsILocalFile> saveDir;
char *dirName;
- /* FIXME persist download dir */
- dirName = g_strdup (g_get_home_dir());
+ dirName = eel_gconf_get_string (CONF_STATE_DOWNLOADING_DIR);
+ if (dirName == NULL)
+ {
+ dirName = g_strdup (g_get_home_dir());
+ }
saveDir = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID);
saveDir->InitWithPath (NS_ConvertUTF8toUCS2(dirName));
@@ -292,37 +295,42 @@ NS_IMETHODIMP GContentHandler::
PRInt16 okToSave = nsIFilePicker::returnCancel;
- if (okToSave == nsIFilePicker::returnCancel)
- {
- nsCOMPtr<nsIFilePicker> filePicker =
- do_CreateInstance (G_FILEPICKER_CONTRACTID);
+ nsCOMPtr<nsIFilePicker> filePicker =
+ do_CreateInstance (G_FILEPICKER_CONTRACTID);
- const nsAString &title = NS_ConvertUTF8toUCS2(_("Select the destination filename"));
+ const nsAString &title = NS_ConvertUTF8toUCS2(_("Select the destination filename"));
- filePicker->Init (windowInternal,
- PromiseFlatString(title).get(),
- nsIFilePicker::modeSave);
- filePicker->SetDefaultString (aDefaultFile);
- filePicker->SetDisplayDirectory (saveDir);
+ filePicker->Init (windowInternal,
+ PromiseFlatString(title).get(),
+ nsIFilePicker::modeSave);
+ filePicker->SetDefaultString (aDefaultFile);
+ filePicker->SetDisplayDirectory (saveDir);
- filePicker->Show (&okToSave);
-
- if (okToSave == nsIFilePicker::returnOK)
- {
- filePicker->GetFile (getter_AddRefs(saveFile));
- }
- }
+ filePicker->Show (&okToSave);
- if (okToSave == nsIFilePicker::returnCancel)
- return NS_ERROR_FAILURE;
- else
+ if (okToSave == nsIFilePicker::returnOK)
{
+ filePicker->GetFile (getter_AddRefs(saveFile));
+
+ nsString uFileName;
+ saveFile->GetPath(uFileName);
+ const nsCString &aFileName = NS_ConvertUCS2toUTF8(uFileName);
+
+ char *dir = g_path_get_dirname (aFileName.get());
+
+ eel_gconf_set_string (CONF_STATE_DOWNLOADING_DIR, dir);
+ g_free (dir);
+
nsCOMPtr<nsIFile> directory;
rv = saveFile->GetParent (getter_AddRefs(directory));
NS_IF_ADDREF (*_retval = saveFile);
return NS_OK;
}
+ else
+ {
+ return NS_ERROR_FAILURE;
+ }
}
/* void showProgressDialog (in nsIHelperAppLauncher aLauncher, in nsISupports aContext); */