aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-01-19 22:06:41 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-01-19 22:06:41 +0800
commitdd0b02c40b5d202794d03299f2d190833b63bb22 (patch)
tree4e8dc109ed36ca01584e1a7d39d5649cc6adbd6e
parenteaba78e8dfd1cdad90bed57cc536cbfe40a9509e (diff)
downloadgsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar
gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.gz
gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.bz2
gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.lz
gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.xz
gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.zst
gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.zip
Add a way to store paths.
2004-01-19 Marco Pesenti Gritti <marco@gnome.org> * lib/eel-gconf-extensions.c: (tilde_compress), (eel_gconf_set_path): * lib/eel-gconf-extensions.h: Add a way to store paths. * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: * embed/mozilla/MozDownload.cpp: * embed/mozilla/MozDownload.h: Actually save the file in downloads dir and then open it. It doesnt seem to open it but it's prolly a gnome-vfs bug. * src/prefs-dialog.c: (get_download_button_label), (download_path_response_cb): Simplify the label logic using ~.
-rw-r--r--ChangeLog22
-rw-r--r--embed/mozilla/ContentHandler.cpp225
-rw-r--r--embed/mozilla/ContentHandler.h11
-rw-r--r--embed/mozilla/MozDownload.cpp40
-rw-r--r--embed/mozilla/MozDownload.h2
-rw-r--r--lib/eel-gconf-extensions.c62
-rw-r--r--lib/eel-gconf-extensions.h2
-rw-r--r--src/prefs-dialog.c24
8 files changed, 196 insertions, 192 deletions
diff --git a/ChangeLog b/ChangeLog
index bd5287f49..202349978 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2004-01-19 Marco Pesenti Gritti <marco@gnome.org>
+ * lib/eel-gconf-extensions.c: (tilde_compress),
+ (eel_gconf_set_path):
+ * lib/eel-gconf-extensions.h:
+
+ Add a way to store paths.
+
+ * embed/mozilla/ContentHandler.cpp:
+ * embed/mozilla/ContentHandler.h:
+ * embed/mozilla/MozDownload.cpp:
+ * embed/mozilla/MozDownload.h:
+
+ Actually save the file in downloads dir and then
+ open it. It doesnt seem to open it but it's prolly
+ a gnome-vfs bug.
+
+ * src/prefs-dialog.c: (get_download_button_label),
+ (download_path_response_cb):
+
+ Simplify the label logic using ~.
+
+2004-01-19 Marco Pesenti Gritti <marco@gnome.org>
+
* data/epiphany.schemas.in:
* data/glade/prefs-dialog.glade:
* embed/mozilla/ContentHandler.cpp:
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index 02f346bd2..d4c1dc4f9 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -35,7 +35,6 @@
#include "nsILocalFile.h"
#include "nsIMIMEInfo.h"
-#include "nsIDocShell.h"
#include "nsIWebNavigation.h" // Needed to create the LoadType flag
#include "ephy-prefs.h"
@@ -59,8 +58,7 @@ class GContentHandler;
NS_IMPL_ISUPPORTS1(GContentHandler, nsIHelperAppLauncherDialog)
-GContentHandler::GContentHandler() : mMimeType(nsnull),
- mUrlHelper(PR_FALSE)
+GContentHandler::GContentHandler() : mMimeType(nsnull)
{
LOG ("GContentHandler ctor")
}
@@ -98,10 +96,6 @@ NS_IMETHODIMP GContentHandler::Show(nsIHelperAppLauncher *aLauncher,
single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell));
g_signal_emit_by_name (single, "handle_content", mMimeType,
mUrl.get(), &handled);
-
- nsCOMPtr<nsIDocShell> eDocShell = do_QueryInterface(aContext);
- PRUint32 eLoadType;
- eDocShell->GetLoadType (&eLoadType);
if (!handled)
{
@@ -165,136 +159,51 @@ NS_METHOD GContentHandler::ShowProgressDialog(nsIHelperAppLauncher *aLauncher,
}
#endif
-NS_METHOD GContentHandler::FindHelperApp (void)
-{
- if (mUrlHelper)
- {
- return LaunchHelperApp ();
- }
-
- nsresult rv;
- rv = SynchroniseMIMEInfo();
- if (NS_FAILED (rv)) return NS_ERROR_FAILURE;
-
- return mLauncher->LaunchWithApplication (nsnull, PR_FALSE);
-}
-
NS_METHOD GContentHandler::LaunchHelperApp (void)
{
- if (mMimeType)
- {
- nsresult rv;
- nsCOMPtr<nsIExternalHelperAppService> helperService =
- do_GetService (NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
- NS_ENSURE_TRUE (helperService, NS_ERROR_FAILURE);
-
- nsCOMPtr<nsPIExternalAppLauncher> appLauncher =
- do_QueryInterface (helperService);
- if (appLauncher)
- {
- appLauncher->DeleteTemporaryFileOnExit(mTempFile);
- }
+ nsresult rv;
+ nsCOMPtr<nsIExternalHelperAppService> helperService;
- nsString uFileName;
- mTempFile->GetPath(uFileName);
- const nsCString &aFileName = NS_ConvertUCS2toUTF8(uFileName);
+ helperService = do_GetService (NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
+ NS_ENSURE_TRUE (helperService, NS_ERROR_FAILURE);
- const nsCString &document = (mUrlHelper) ? mUrl : aFileName;
+ nsCOMPtr<nsPIExternalAppLauncher> appLauncher = do_QueryInterface (helperService);
+ NS_ENSURE_TRUE (appLauncher, NS_ERROR_FAILURE);
+ appLauncher->DeleteTemporaryFileOnExit(mTempFile);
- char *param = g_strdup (document.get());
- GList *params = NULL;
- params = g_list_append (params, param);
- gnome_vfs_mime_application_launch (mHelperApp, params);
- g_free (param);
- g_list_free (params);
+ char *param = g_strdup (mUrl.get());
+ GList *params = NULL;
+ params = g_list_append (params, param);
+ gnome_vfs_mime_application_launch (mHelperApp, params);
+ g_free (param);
+ g_list_free (params);
- if (mUrlHelper)
- {
- mLauncher->Cancel();
- }
- }
- else
- {
- mLauncher->Cancel ();
- }
+ mLauncher->Cancel();
return NS_OK;
}
-NS_METHOD GContentHandler::GetLauncher (nsIHelperAppLauncher * *_retval)
-{
- NS_IF_ADDREF (*_retval = mLauncher);
- return NS_OK;
-}
-
-static gboolean
-application_support_scheme (GnomeVFSMimeApplication *app, const nsCString &aScheme)
+NS_METHOD GContentHandler::CheckAppSupportScheme (void)
{
GList *l;
- g_return_val_if_fail (app != NULL, FALSE);
- g_return_val_if_fail (!aScheme.IsEmpty(), FALSE);
-
- if (app->expects_uris != GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS)
- return FALSE;
+ mAppSupportScheme = PR_FALSE;
+
+ if (!mHelperApp) return NS_OK;
+
+ if (mHelperApp->expects_uris != GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS)
+ return NS_OK;
- for (l = app->supported_uri_schemes; l != NULL; l = l->next)
+ for (l = mHelperApp->supported_uri_schemes; l != NULL; l = l->next)
{
char *uri_scheme = (char *)l->data;
- g_return_val_if_fail (uri_scheme != NULL, FALSE);
- if (aScheme.Equals (uri_scheme)) return TRUE;
- }
-
- return FALSE;
-}
-
-NS_METHOD GContentHandler::SetHelperApp(GnomeVFSMimeApplication *aHelperApp,
- PRBool alwaysUse)
-{
- mHelperApp = aHelperApp;
- mUrlHelper = application_support_scheme (aHelperApp, mScheme);
-
- return NS_OK;
-}
-
-NS_METHOD GContentHandler::SynchroniseMIMEInfo (void)
-{
- nsresult rv;
- char *command_with_path;
-
- NS_ENSURE_TRUE (mLauncher, NS_ERROR_FAILURE);
- nsCOMPtr<nsIMIMEInfo> mimeInfo;
- mLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
- NS_ENSURE_TRUE (mimeInfo, NS_ERROR_FAILURE);
-
- command_with_path = g_find_program_in_path (mHelperApp->command);
- if (command_with_path == NULL) return NS_ERROR_FAILURE;
-
- nsCOMPtr<nsILocalFile> helperFile;
- NS_NewNativeLocalFile (nsDependentCString(command_with_path),
- PR_TRUE,
- getter_AddRefs(helperFile));
- NS_ENSURE_TRUE (helperFile, NS_ERROR_FAILURE);
-
- g_free (command_with_path);
-
- rv = mimeInfo->SetPreferredApplicationHandler(helperFile);
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
-
- nsMIMEInfoHandleAction mimeInfoAction;
- mimeInfoAction = nsIMIMEInfo::useHelperApp;
-
- if(mHelperApp->requires_terminal) //Information passing kludge!
- {
- rv = mimeInfo->SetApplicationDescription
- (NS_LITERAL_STRING("runInTerminal").get());
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ if (mScheme.Equals (uri_scheme))
+ {
+ mAppSupportScheme = PR_TRUE;
+ }
}
- rv = mimeInfo->SetPreferredAction(mimeInfoAction);
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
-
return NS_OK;
}
@@ -325,34 +234,6 @@ NS_METHOD GContentHandler::Init (void)
rv = mUri->GetSpec (mUrl);
rv = mUri->GetScheme (mScheme);
- ProcessMimeInfo ();
-
- return NS_OK;
-}
-
-NS_METHOD GContentHandler::ProcessMimeInfo (void)
-{
- if (mMimeType == NULL ||
- !nsCRT::strcmp(mMimeType, "application/octet-stream"))
- {
- /* FIXME: we leak the old value of mMimeType */
-
- nsresult rv;
- nsCOMPtr<nsIURL> url = do_QueryInterface(mUri, &rv);
- if (NS_SUCCEEDED(rv) && url)
- {
- nsCAutoString uriFileName;
- url->GetFileName(uriFileName);
- mMimeType = g_strdup
- (gnome_vfs_mime_type_from_name
- (uriFileName.get()));
- }
- else
- {
- mMimeType = g_strdup ("application/octet-stream");
- }
- }
-
return NS_OK;
}
@@ -367,7 +248,8 @@ NS_METHOD GContentHandler::MIMEConfirmAction ()
("", NULL, GTK_DIALOG_NO_SEPARATOR,
_("Save As..."), CONTENT_ACTION_SAVEAS,
GTK_STOCK_CANCEL, CONTENT_ACTION_NONE,
- _("Open"), CONTENT_ACTION_OPEN,
+ mAction == CONTENT_ACTION_OPEN ?
+ _("Open") : _("Download"), mAction,
NULL);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
@@ -382,13 +264,13 @@ NS_METHOD GContentHandler::MIMEConfirmAction ()
if (mPermission != EPHY_MIME_PERMISSION_SAFE)
{
text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- _("Do you really want to download the file?"),
- _("This type of file could potentially damage your documents"
- "or invade your privacy."
- "It's not safe to open it directly. You"
+ _("Download the unsafe file?"),
+ _("This type of file could potentially damage your documents "
+ "or invade your privacy. "
+ "It's not safe to open it directly. You "
"can save it instead."));
}
- if (mAction == CONTENT_ACTION_OPEN)
+ else if (mAction == CONTENT_ACTION_OPEN)
{
text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
_("Open the file in another application?"),
@@ -400,7 +282,7 @@ NS_METHOD GContentHandler::MIMEConfirmAction ()
{
text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
_("Download the file?"),
- _("It's not possible to view this file because there is no"
+ _("It's not possible to view this file because there is no "
"application installed that can open it."
"You can save it instead."));
}
@@ -439,8 +321,9 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK)) return NS_OK;
auto_downloads = eel_gconf_get_boolean (CONF_AUTO_DOWNLOADS);
- GnomeVFSMimeApplication *DefaultApp = gnome_vfs_mime_get_default_application(mMimeType);
+ mHelperApp = gnome_vfs_mime_get_default_application (mMimeType);
+ CheckAppSupportScheme ();
mPermission = ephy_embed_shell_check_mime (embed_shell, mMimeType);
mAction = CONTENT_ACTION_OPEN;
@@ -454,21 +337,31 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
{
MIMEConfirmAction ();
}
-
- if (mAction == CONTENT_ACTION_DOWNLOAD ||
- mAction == CONTENT_ACTION_SAVEAS)
+
+ nsCOMPtr<nsIMIMEInfo> mimeInfo;
+ mLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
+ NS_ENSURE_TRUE (mimeInfo, NS_ERROR_FAILURE);
+
+ if (mAction == CONTENT_ACTION_OPEN)
{
- nsCOMPtr<nsIHelperAppLauncher> launcher;
- GetLauncher (getter_AddRefs(launcher));
- NS_ENSURE_TRUE (launcher, NS_ERROR_FAILURE);
- launcher->SaveToDisk (nsnull,PR_FALSE);
+ /* HACK we use the application description to ask
+ MozDownload to open the file when download
+ is finished */
+ mimeInfo->SetApplicationDescription
+ (NS_LITERAL_STRING ("gnome-default").get());
}
- else if (mAction == CONTENT_ACTION_OPEN)
+ else
+ {
+ mimeInfo->SetApplicationDescription (nsnull);
+ }
+
+ if (mAction == CONTENT_ACTION_OPEN && mAppSupportScheme)
+ {
+ LaunchHelperApp ();
+ }
+ else if (mAction != CONTENT_ACTION_NONE)
{
- rv = SetHelperApp (DefaultApp, FALSE);
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
- rv = FindHelperApp ();
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ mLauncher->SaveToDisk (nsnull,PR_FALSE);
}
return NS_OK;
diff --git a/embed/mozilla/ContentHandler.h b/embed/mozilla/ContentHandler.h
index d07bea0f7..b692675f5 100644
--- a/embed/mozilla/ContentHandler.h
+++ b/embed/mozilla/ContentHandler.h
@@ -70,24 +70,19 @@ class GContentHandler : public nsIHelperAppLauncherDialog
private:
NS_METHOD Init ();
- NS_METHOD ProcessMimeInfo ();
- NS_METHOD FindHelperApp ();
NS_METHOD LaunchHelperApp ();
- NS_METHOD GetLauncher (nsIHelperAppLauncher * *_retval);
- NS_METHOD SetHelperApp(GnomeVFSMimeApplication *mHelperApp,
- PRBool alwaysUse);
- NS_METHOD SynchroniseMIMEInfo ();
NS_METHOD MIMEConfirmAction ();
NS_METHOD MIMEDoAction ();
-
+ NS_METHOD CheckAppSupportScheme ();
+
nsCOMPtr<nsIHelperAppLauncher> mLauncher;
nsCOMPtr<nsIURI> mUri;
nsCOMPtr<nsIFile> mTempFile;
char *mMimeType;
- PRBool mUrlHelper;
+ PRBool mAppSupportScheme;
GnomeVFSMimeApplication *mHelperApp;
ContentAction mAction;
EphyMimePermission mPermission;
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 53205702a..003573402 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -55,6 +55,7 @@
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsIRequest.h"
+#include "nsIMIMEInfo.h"
#include "netCore.h"
const char* const persistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1";
@@ -88,6 +89,7 @@ MozDownload::Init(nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisp
nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist)
{
PRBool addToView = PR_TRUE;
+ nsresult rv;
if (mEmbedPersist)
{
@@ -106,6 +108,7 @@ MozDownload::Init(nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisp
mPercentComplete = 0;
mInterval = 4000; /* in ms */
mLastUpdate = mStartTime;
+ mMIMEInfo = aMIMEInfo;
if (aPersist)
{
@@ -262,6 +265,8 @@ NS_IMETHODIMP
MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
PRUint32 aStateFlags, nsresult aStatus)
{
+ nsresult rv;
+
/* For a file download via the external helper app service, we will never get a start
notification. The helper app service has gotten that notification before it created us. */
if (!mGotFirstStateChange)
@@ -302,6 +307,41 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
mozilla_embed_persist_cancelled (mEmbedPersist);
}
}
+ else if (NS_SUCCEEDED (aStatus))
+ {
+ GnomeVFSMimeApplication *helperApp;
+ char *mimeType;
+
+ rv = mMIMEInfo->GetMIMEType (&mimeType);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ helperApp = gnome_vfs_mime_get_default_application (mimeType);
+
+ PRUnichar *description;
+ mMIMEInfo->GetApplicationDescription (&description);
+
+ /* HACK we use the application description to decide
+ if we have to open the saved file */
+ if ((strcmp (NS_ConvertUCS2toUTF8 (description).get(), "gnome-default") == 0) &&
+ helperApp)
+ {
+ GList *params = NULL;
+ char *param;
+ nsCAutoString aDest;
+
+ mDestination->GetNativePath (aDest);
+
+ param = g_strdup (aDest.get ());
+ params = g_list_append (params, param);
+ gnome_vfs_mime_application_launch (helperApp, params);
+ g_free (param);
+
+ g_list_free (params);
+ }
+
+ nsMemory::Free (mimeType);
+ gnome_vfs_mime_application_free (helperApp);
+ }
}
return NS_OK;
diff --git a/embed/mozilla/MozDownload.h b/embed/mozilla/MozDownload.h
index 9a2a94d53..084a90f8b 100644
--- a/embed/mozilla/MozDownload.h
+++ b/embed/mozilla/MozDownload.h
@@ -56,6 +56,7 @@
#include "downloader-view.h"
#include "ephy-download.h"
#include "ephy-embed-shell.h"
+#include <libgnomevfs/gnome-vfs-mime-handlers.h>
/* MozDownload
Holds information used to display a single download in the UI. This object is
@@ -111,6 +112,7 @@ public:
protected:
nsCOMPtr<nsIURI> mSource;
nsCOMPtr<nsILocalFile> mDestination;
+ nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
PRInt64 mLastUpdate;
PRInt64 mStartTime;
PRInt64 mElapsed;
diff --git a/lib/eel-gconf-extensions.c b/lib/eel-gconf-extensions.c
index 7ec18f492..a60372d45 100644
--- a/lib/eel-gconf-extensions.c
+++ b/lib/eel-gconf-extensions.c
@@ -687,3 +687,65 @@ eel_gconf_get_float (const char *key)
return result;
}
+
+static char *
+tilde_compress (const char *path)
+{
+ const char *home_dir = g_get_home_dir();
+ int home_dir_l = strlen (home_dir);
+ int ntilde = 0;
+ const char *scan;
+ int path_l, result_l;
+ char *result, *scan2;
+
+ if (path == NULL)
+ return NULL;
+
+ path_l = strlen (path);
+ for (scan = path; scan != NULL; scan++) {
+ if (path_l - (scan - path) < home_dir_l)
+ break;
+ if (strncmp (scan, home_dir, home_dir_l) == 0)
+ ntilde++;
+ }
+
+ if (ntilde == 0)
+ return g_strdup (path);
+
+ result_l = strlen (path) + ntilde - (ntilde * home_dir_l);
+ result = g_new (char, result_l + 1);
+
+ for (scan = path, scan2 = result; scan != NULL; scan2++) {
+ if (path_l - (scan - path) < home_dir_l) {
+ strcpy (scan2, scan);
+ scan2 += strlen (scan);
+ break;
+ }
+ if (strncmp (scan, home_dir, home_dir_l) == 0) {
+ *scan2 = '~';
+ scan += home_dir_l;
+ } else {
+ *scan2 = *scan;
+ scan++;
+ }
+ }
+ *scan2 = 0;
+
+ return result;
+}
+
+void
+eel_gconf_set_path (const char *key,
+ const char *value)
+{
+ char *tilde_path;
+ char *converted;
+
+ converted = g_filename_to_utf8 (value, -1, NULL, NULL, NULL);
+
+ tilde_path = tilde_compress (converted);
+ eel_gconf_set_string (key, tilde_path);
+
+ g_free (tilde_path);
+ g_free (converted);
+}
diff --git a/lib/eel-gconf-extensions.h b/lib/eel-gconf-extensions.h
index 13196d7ee..4bc6167ef 100644
--- a/lib/eel-gconf-extensions.h
+++ b/lib/eel-gconf-extensions.h
@@ -72,6 +72,8 @@ void eel_gconf_value_set_string_list (GConfValue *value,
void eel_gconf_set_float (const char *key,
gfloat float_value);
gfloat eel_gconf_get_float (const char *key);
+void eel_gconf_set_path (const char *key,
+ const char *value);
G_END_DECLS
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index c58515dee..be3bf71b4 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -1080,24 +1080,16 @@ create_language_section (EphyDialog *dialog)
static char*
get_download_button_label ()
{
- char *label, *key, *desktop_path, *home_path, *tmp;
- char *downloads_path;
+ char *key, *label;
key = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
- tmp = g_build_filename (g_get_home_dir (), "Desktop", NULL);
- desktop_path = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL);
- home_path = g_filename_to_utf8 (g_get_home_dir (), -1, NULL, NULL, NULL);
- g_free (tmp);
-
- downloads_path = g_build_filename (g_get_home_dir (), "Downloads", NULL);
-
- if (g_utf8_collate (key, desktop_path) == 0)
+ if (g_utf8_collate (key, "~/Desktop") == 0)
{
g_free (key);
label = g_strdup (_("Desktop"));
}
- else if (g_utf8_collate (key, home_path) == 0)
+ else if (g_utf8_collate (key, "~") == 0)
{
g_free (key);
/* Note that this does NOT refer to the home page but to a
@@ -1106,7 +1098,7 @@ get_download_button_label ()
* filechooser */
label = g_strdup (_("Home"));
}
- else if (g_utf8_collate (key, downloads_path) == 0)
+ else if (g_utf8_collate (key, "~/Downloads") == 0)
{
g_free (key);
label = g_strdup (_("Downloads"));
@@ -1116,8 +1108,6 @@ get_download_button_label ()
label = key;
}
- g_free (desktop_path);
- g_free (home_path);
return label;
}
@@ -1288,17 +1278,15 @@ download_path_response_cb (GtkDialog *fc, gint response, EphyDialog *dialog)
if (dir != NULL)
{
GtkWidget *button;
- char *label, *converted;
+ char *label;
- converted = g_filename_to_utf8 (dir, -1, NULL, NULL, NULL);
- eel_gconf_set_string (CONF_STATE_DOWNLOAD_DIR, converted);
+ eel_gconf_set_path (CONF_STATE_DOWNLOAD_DIR, dir);
button = ephy_dialog_get_control (dialog, properties[DOWNLOAD_PATH_BUTTON_PROP].id);
label = get_download_button_label ();
ephy_ellipsizing_label_set_text ((EphyEllipsizingLabel*) GTK_BIN (button)->child,
label);
- g_free (converted);
g_free (dir);
g_free (label);
}