From 2f10c10cd81abd29f24ace8c128a5b5d3244fbdd Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Sun, 2 Nov 2003 22:31:18 +0000 Subject: 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. --- ChangeLog | 15 +++++++ data/epiphany.schemas.in | 11 ----- embed/ephy-embed-popup-control.c | 2 +- embed/mozilla/ContentHandler.cpp | 86 ++++++++++++++----------------------- embed/mozilla/EphyHeaderSniffer.cpp | 4 +- lib/ephy-prefs.h | 2 +- src/popup-commands.c | 2 +- 7 files changed, 53 insertions(+), 69 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ee145703..0e5da1f88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-11-02 Xan Lopez + + * 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. + 2003-11-02 Christian Persch * lib/ephy-dialog.c: (impl_run): diff --git a/data/epiphany.schemas.in b/data/epiphany.schemas.in index 1bcae6033..d7f6fded5 100644 --- a/data/epiphany.schemas.in +++ b/data/epiphany.schemas.in @@ -216,17 +216,6 @@ - - /schemas/apps/epiphany/dialogs/downloader_show_details - /apps/epiphany/dialogs/downloader_show_details - epiphany - bool - false - - Show download details - Show download details. - - /schemas/apps/epiphany/web/cache_size /apps/epiphany/web/cache_size diff --git a/embed/ephy-embed-popup-control.c b/embed/ephy-embed-popup-control.c index 650534d86..9c816840f 100644 --- a/embed/ephy-embed-popup-control.c +++ b/embed/ephy-embed-popup-control.c @@ -496,7 +496,7 @@ save_url (EphyEmbedPopupControl *popup, ephy_embed_persist_set_flags (persist, ask_dest ? EMBED_PERSIST_ASK_DESTINATION : 0); ephy_embed_persist_set_persist_key - (persist, CONF_STATE_DOWNLOADING_DIR); + (persist, CONF_STATE_DOWNLOAD_DIR); ephy_embed_persist_set_source (persist, location); ephy_embed_persist_save (persist); 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 #include #include +#include #include class GContentHandler; @@ -275,66 +274,47 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile( const PRUnichar *aSuggestedFileExtension, nsILocalFile **_retval) { - nsresult rv; + char *path, *download_dir; - mContext = aWindowContext; - - nsCOMPtr windowInternal = - do_QueryInterface (aWindowContext); - - nsCOMPtr 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 saveFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID)); - - PRInt16 okToSave = nsIFilePicker::returnCancel; - - nsCOMPtr 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 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 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 */ diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h index bac1e56a2..cdb7271da 100644 --- a/lib/ephy-prefs.h +++ b/lib/ephy-prefs.h @@ -35,7 +35,7 @@ G_BEGIN_DECLS #define CONF_STATE_SAVE_DIR "/apps/epiphany/directories/save" #define CONF_STATE_SAVE_IMAGE_DIR "/apps/epiphany/directories/saveimage" #define CONF_STATE_OPEN_DIR "/apps/epiphany/directories/open" -#define CONF_STATE_DOWNLOADING_DIR "/apps/epiphany/directories/download" +#define CONF_STATE_DOWNLOAD_DIR "/apps/epiphany/directories/download" #define CONF_STATE_UPLOAD_DIR "/apps/epiphany/directories/upload" /* System prefs */ diff --git a/src/popup-commands.c b/src/popup-commands.c index 38613e216..8771274c6 100644 --- a/src/popup-commands.c +++ b/src/popup-commands.c @@ -289,7 +289,7 @@ save_property_url (GtkAction *action, ephy_embed_persist_set_flags (persist, ask_dest ? EMBED_PERSIST_ASK_DESTINATION : 0); ephy_embed_persist_set_persist_key - (persist, CONF_STATE_DOWNLOADING_DIR); + (persist, CONF_STATE_DOWNLOAD_DIR); ephy_embed_persist_set_source (persist, location); ephy_embed_persist_save (persist); -- cgit