aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <descalante@igalia.com>2010-11-01 16:47:54 +0800
committerDiego Escalante Urrelo <descalante@igalia.com>2011-03-08 04:34:52 +0800
commitfdafabde40eced013ffdcb49e4f080542fbbc402 (patch)
treeeffe78b5b8c9c9a9fb785d74bbdac0ecc66afc79
parent07202bf4e9b6f7809b58b0c3e13af0a6de593e28 (diff)
downloadgsoc2013-epiphany-fdafabde40eced013ffdcb49e4f080542fbbc402.tar
gsoc2013-epiphany-fdafabde40eced013ffdcb49e4f080542fbbc402.tar.gz
gsoc2013-epiphany-fdafabde40eced013ffdcb49e4f080542fbbc402.tar.bz2
gsoc2013-epiphany-fdafabde40eced013ffdcb49e4f080542fbbc402.tar.lz
gsoc2013-epiphany-fdafabde40eced013ffdcb49e4f080542fbbc402.tar.xz
gsoc2013-epiphany-fdafabde40eced013ffdcb49e4f080542fbbc402.tar.zst
gsoc2013-epiphany-fdafabde40eced013ffdcb49e4f080542fbbc402.zip
ephy-file-helpers: only one downloads_dir function
Remove all the ambiguity, we always throw downloads to the same place or the Desktop. Bug #618443
-rw-r--r--lib/ephy-file-helpers.c71
-rw-r--r--lib/ephy-file-helpers.h1
-rw-r--r--src/prefs-dialog.c34
3 files changed, 7 insertions, 99 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index aa4627ec6..5a6bc335b 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -106,41 +106,6 @@ ephy_file_tmp_dir (void)
}
/**
- * ephy_file_downloads_dir:
- *
- * Gets the basename for Epiphany's Downloads dir. This depends on the current
- * locale. For the full path to the downloads directory see
- * ephy_file_get_downloads_dir().
- *
- * Returns: a newly-allocated string containing the downloads dir basename.
- **/
-char *
-ephy_file_downloads_dir (void)
-{
- const char *translated_folder;
- const char *xdg_download_dir;
- char *desktop_dir, *converted, *downloads_dir;
-
- xdg_download_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
- if (xdg_download_dir != NULL)
- return g_strdup (xdg_download_dir);
-
- /* The name of the default downloads folder */
- translated_folder = _("Downloads");
-
- converted = g_filename_from_utf8 (translated_folder, -1, NULL,
- NULL, NULL);
-
- desktop_dir = ephy_file_desktop_dir ();
- downloads_dir = g_build_filename (desktop_dir, converted, NULL);
-
- g_free (desktop_dir);
- g_free (converted);
-
- return downloads_dir;
-}
-
-/**
* ephy_file_get_downloads_dir:
*
* Gets the full path to the downloads dir. This uses ephy_file_downloads_dir()
@@ -152,44 +117,16 @@ ephy_file_downloads_dir (void)
char *
ephy_file_get_downloads_dir (void)
{
- char *download_dir, *expanded;
+ char *download_dir;
download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
EPHY_PREFS_STATE_DOWNLOAD_DIR);
- if (download_dir && strcmp (download_dir, _("Downloads")) == 0)
- {
- g_free (download_dir);
- download_dir = ephy_file_downloads_dir ();
- }
- else if (download_dir && strcmp (download_dir, _("Desktop")) == 0)
- {
- g_free (download_dir);
- download_dir = ephy_file_desktop_dir ();
- }
- else if (download_dir)
- {
- char *converted_dp;
-
- converted_dp = g_filename_from_utf8 (download_dir, -1, NULL, NULL, NULL);
- g_free (download_dir);
- download_dir = converted_dp;
- }
-
/* Emergency download destination */
- if (download_dir == NULL)
- {
- const char *home_dir;
- home_dir = g_get_home_dir ();
- download_dir = g_strdup (home_dir != NULL ? home_dir : "/");
- }
-
- g_return_val_if_fail (download_dir != NULL, NULL);
-
- expanded = ephy_string_expand_initial_tilde (download_dir);
- g_free (download_dir);
+ if (g_path_is_absolute (download_dir) != TRUE)
+ download_dir = ephy_file_desktop_dir ();
- return expanded;
+ return download_dir;
}
/**
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index f2c4a4acf..e290f38c3 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -52,7 +52,6 @@ gboolean ephy_file_helpers_init (const char *profile_dir,
const char * ephy_file (const char *filename);
const char * ephy_dot_dir (void);
void ephy_file_helpers_shutdown (void);
-char * ephy_file_downloads_dir (void);
char * ephy_file_get_downloads_dir (void);
char * ephy_file_desktop_dir (void);
const char * ephy_file_tmp_dir (void);
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 7392450db..191045548 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -834,42 +834,14 @@ create_language_section (EphyDialog *dialog)
static void
download_path_changed_cb (GtkFileChooser *button)
{
- char *dir, *downloads_dir, *desktop_dir;
+ char *dir;
- /* FIXME: use _uri variant when we support downloading
- * to gnome-vfs remote locations
- */
dir = gtk_file_chooser_get_filename (button);
if (dir == NULL) return;
- downloads_dir = ephy_file_downloads_dir ();
- desktop_dir = ephy_file_desktop_dir ();
- g_return_if_fail (downloads_dir != NULL && desktop_dir != NULL);
-
- /* Check if the dir matches the default downloads_dir or desktop_dir to
- * store the english name instead of the localized one reported by the
- * two ephy_file_ functions. */
- if (strcmp (dir, downloads_dir) == 0)
- {
- g_settings_set_string (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_DOWNLOAD_DIR,
- _("Downloads"));
- }
- else if (strcmp (dir, desktop_dir) == 0)
- {
- g_settings_set_string (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_DOWNLOAD_DIR,
- _("Desktop"));
- }
- else
- {
- g_settings_set_string (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_DOWNLOAD_DIR, dir);
- }
-
+ g_settings_set_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR, dir);
g_free (dir);
- g_free (downloads_dir);
- g_free (desktop_dir);
}
static void