aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorJames Willcox <jwillcox@gnome.org>2003-06-30 03:56:33 +0800
committerJames Willcox <jwillcox@src.gnome.org>2003-06-30 03:56:33 +0800
commit948b68574491a5c9a157aa3edb829d4a6b20ccb0 (patch)
tree5ab2fb9145b3726ef0287e54d598ca6e89766f44 /embed
parente823b1ae495d6a3f9df0acd0f73542e416bcb6a9 (diff)
downloadgsoc2013-epiphany-948b68574491a5c9a157aa3edb829d4a6b20ccb0.tar
gsoc2013-epiphany-948b68574491a5c9a157aa3edb829d4a6b20ccb0.tar.gz
gsoc2013-epiphany-948b68574491a5c9a157aa3edb829d4a6b20ccb0.tar.bz2
gsoc2013-epiphany-948b68574491a5c9a157aa3edb829d4a6b20ccb0.tar.lz
gsoc2013-epiphany-948b68574491a5c9a157aa3edb829d4a6b20ccb0.tar.xz
gsoc2013-epiphany-948b68574491a5c9a157aa3edb829d4a6b20ccb0.tar.zst
gsoc2013-epiphany-948b68574491a5c9a157aa3edb829d4a6b20ccb0.zip
Remember the directory when saving files. Fixes #115603.
2003-06-29 James Willcox <jwillcox@gnome.org> * embed/mozilla/ContentHandler.cpp: Remember the directory when saving files. Fixes #115603.
Diffstat (limited to 'embed')
-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); */