aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2003-11-03 06:31:18 +0800
committerXan Lopez <xan@src.gnome.org>2003-11-03 06:31:18 +0800
commit2f10c10cd81abd29f24ace8c128a5b5d3244fbdd (patch)
tree76254bd0c48969e4840a2b97eec3fdb6d527f251 /embed/mozilla
parentbce28d78b08a72c11b9cbb8a798d7b59564fe1f2 (diff)
downloadgsoc2013-epiphany-2f10c10cd81abd29f24ace8c128a5b5d3244fbdd.tar
gsoc2013-epiphany-2f10c10cd81abd29f24ace8c128a5b5d3244fbdd.tar.gz
gsoc2013-epiphany-2f10c10cd81abd29f24ace8c128a5b5d3244fbdd.tar.bz2
gsoc2013-epiphany-2f10c10cd81abd29f24ace8c128a5b5d3244fbdd.tar.lz
gsoc2013-epiphany-2f10c10cd81abd29f24ace8c128a5b5d3244fbdd.tar.xz
gsoc2013-epiphany-2f10c10cd81abd29f24ace8c128a5b5d3244fbdd.tar.zst
gsoc2013-epiphany-2f10c10cd81abd29f24ace8c128a5b5d3244fbdd.zip
Remove the "show_details in downloader" schema.
* data/epiphany.schemas.in: Remove the "show_details in downloader" schema. * embed/ephy-embed-popup-control.c: (save_url): * embed/mozilla/ContentHandler.cpp: * embed/mozilla/EphyHeaderSniffer.cpp: * lib/ephy-prefs.h: * src/popup-commands.c: (save_property_url): Implement the new downloading mechanism in CH, also rename CONF_STATE_DOWNLOADING_DIR to CONF_STATE_DOWNLOAD_DIR.
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/ContentHandler.cpp86
-rw-r--r--embed/mozilla/EphyHeaderSniffer.cpp4
2 files changed, 35 insertions, 55 deletions
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index f79aa43bd..affcf0ccd 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -150,8 +150,6 @@
#endif
#include "ContentHandler.h"
-
-#include "FilePicker.h"
#include "MozillaPrivate.h"
#include "nsCOMPtr.h"
@@ -187,6 +185,7 @@
#include <libgnome/gnome-config.h>
#include <libgnome/gnome-util.h>
#include <libgnomevfs/gnome-vfs-mime.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
#include <bonobo/bonobo-i18n.h>
class GContentHandler;
@@ -275,66 +274,47 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile(
const PRUnichar *aSuggestedFileExtension,
nsILocalFile **_retval)
{
- nsresult rv;
+ char *path, *download_dir;
- mContext = aWindowContext;
-
- nsCOMPtr<nsIDOMWindowInternal> windowInternal =
- do_QueryInterface (aWindowContext);
-
- nsCOMPtr<nsILocalFile> saveDir;
- char *dirName;
-
- dirName = eel_gconf_get_string (CONF_STATE_DOWNLOADING_DIR);
- if (dirName == NULL)
+ download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
+ if (!download_dir)
{
- dirName = g_strdup (g_get_home_dir());
+ /* Emergency download destination */
+ download_dir = g_strdup (g_get_home_dir ());
}
- saveDir = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID);
- saveDir->InitWithPath (NS_ConvertUTF8toUCS2(dirName));
- g_free (dirName);
-
- nsCOMPtr <nsILocalFile> saveFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
-
- PRInt16 okToSave = nsIFilePicker::returnCancel;
-
- nsCOMPtr<nsIFilePicker> filePicker =
- do_CreateInstance (G_FILEPICKER_CONTRACTID);
-
- const nsAString &title = NS_ConvertUTF8toUCS2(_("Select the destination filename"));
-
- filePicker->Init (windowInternal,
- PromiseFlatString(title).get(),
- nsIFilePicker::modeSave);
- filePicker->SetDefaultString (aDefaultFile);
- filePicker->SetDisplayDirectory (saveDir);
-
- filePicker->Show (&okToSave);
-
- if (okToSave == nsIFilePicker::returnOK)
+ if (!strcmp (download_dir, "Desktop"))
{
- 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;
+ if (eel_gconf_get_boolean (CONF_DESKTOP_IS_HOME_DIR))
+ {
+ path = g_build_filename
+ (g_get_home_dir (),
+ NS_ConvertUCS2toUTF8 (aDefaultFile).get(),
+ NULL);
+ }
+ else
+ {
+ path = g_build_filename
+ (g_get_home_dir (), "Desktop",
+ NS_ConvertUCS2toUTF8 (aDefaultFile).get(),
+ NULL);
+ }
}
else
{
- return NS_ERROR_FAILURE;
+ path = g_build_filename
+ (gnome_vfs_expand_initial_tilde (download_dir),
+ NS_ConvertUCS2toUTF8 (aDefaultFile).get(),
+ NULL);
}
+ g_free (download_dir);
+
+ nsCOMPtr <nsILocalFile> destFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+ destFile->InitWithNativePath (nsDependentCString (path));
+ g_free (path);
+
+ NS_IF_ADDREF (*_retval = destFile);
+ return NS_OK;
}
#if MOZILLA_SNAPSHOT < 10
diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp
index 939394bd1..9ac0c0eca 100644
--- a/embed/mozilla/EphyHeaderSniffer.cpp
+++ b/embed/mozilla/EphyHeaderSniffer.cpp
@@ -292,7 +292,7 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
dialog = ephy_file_chooser_new (title ? title: _("Save"),
GTK_WIDGET (window),
GTK_FILE_CHOOSER_ACTION_SAVE,
- key ? key : CONF_STATE_DOWNLOADING_DIR);
+ key ? key : CONF_STATE_DOWNLOAD_DIR);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
NS_ConvertUCS2toUTF8 (defaultFileName).get());
@@ -308,7 +308,7 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
/* FIXME: how to inform user of failed save ? */
- download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOADING_DIR);
+ download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
if (!download_dir)
{
/* Emergency download destination */