aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/EphyHeaderSniffer.cpp
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2003-10-29 07:22:22 +0800
committerXan Lopez <xan@src.gnome.org>2003-10-29 07:22:22 +0800
commit74b29db83dcbae7d8d1f953a4d2f831ef1144c78 (patch)
tree47cab6d9f11742fd5c199fe3c51d4bac21688646 /embed/mozilla/EphyHeaderSniffer.cpp
parent55e15cb762ccb0fa32fbab23a6afb59e9770e036 (diff)
downloadgsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.gz
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.bz2
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.lz
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.xz
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.zst
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.zip
Implement smart selection in the downloader view.
* embed/downloader-view.c: (downloader_view_remove_download): Implement smart selection in the downloader view. * data/epiphany.schemas.in: * embed/ephy-embed-popup-control.c: (embed_popup_download_link_cmd): * embed/mozilla/EphyHeaderSniffer.cpp: * lib/ephy-prefs.h: * src/popup-commands.c: (popup_cmd_download_link): Make persist downloads store the files in the download dir automatically without asking the user (key only accessible via gconf atm). CH downloads still need fixing.
Diffstat (limited to 'embed/mozilla/EphyHeaderSniffer.cpp')
-rw-r--r--embed/mozilla/EphyHeaderSniffer.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp
index fb185a0c7..939394bd1 100644
--- a/embed/mozilla/EphyHeaderSniffer.cpp
+++ b/embed/mozilla/EphyHeaderSniffer.cpp
@@ -67,6 +67,7 @@
#include "nsIDownload.h"
#include <bonobo/bonobo-i18n.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
EphyHeaderSniffer::EphyHeaderSniffer (nsIWebBrowserPersist* aPersist, MozillaEmbedPersist *aEmbedPersist,
nsIFile* aFile, nsIURI* aURL, nsIDOMDocument* aDocument, nsIInputStream* aPostData)
@@ -203,6 +204,7 @@ filechooser_response_cb (EphyFileChooser *dialog, gint response, EphyHeaderSniff
nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
{
nsresult rv;
+ char *path, *download_dir;
EmbedPersistFlags flags;
PRBool askDownloadDest;
@@ -302,13 +304,46 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
return NS_OK;
}
-
/* FIXME ask user if overwriting ? */
/* FIXME: how to inform user of failed save ? */
- nsCOMPtr<nsILocalFile> destFile;
- rv = NS_NewLocalFile(defaultFileName, PR_TRUE, getter_AddRefs(destFile));
- if (NS_FAILED(rv) || !destFile) return NS_ERROR_FAILURE;
+
+ download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOADING_DIR);
+ if (!download_dir)
+ {
+ /* Emergency download destination */
+ download_dir = g_strdup (g_get_home_dir ());
+ }
+
+ if (!strcmp (download_dir, "Desktop"))
+ {
+ if (eel_gconf_get_boolean (CONF_DESKTOP_IS_HOME_DIR))
+ {
+ path = g_build_filename
+ (g_get_home_dir (),
+ NS_ConvertUCS2toUTF8 (defaultFileName).get(),
+ NULL);
+ }
+ else
+ {
+ path = g_build_filename
+ (g_get_home_dir (), "Desktop",
+ NS_ConvertUCS2toUTF8 (defaultFileName).get(),
+ NULL);
+ }
+ }
+ else
+ {
+ path = g_build_filename
+ (gnome_vfs_expand_initial_tilde (download_dir),
+ NS_ConvertUCS2toUTF8 (defaultFileName).get(),
+ NULL);
+ }
+ g_free (download_dir);
+
+ nsCOMPtr<nsILocalFile> destFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID);
+ destFile->InitWithNativePath (nsDependentCString (path));
+ g_free (path);
return InitiateDownload (destFile);
}