From fdafabde40eced013ffdcb49e4f080542fbbc402 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Mon, 1 Nov 2010 03:47:54 -0500 Subject: 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 --- lib/ephy-file-helpers.c | 71 +++---------------------------------------------- lib/ephy-file-helpers.h | 1 - 2 files changed, 4 insertions(+), 68 deletions(-) (limited to 'lib') 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 @@ -105,41 +105,6 @@ ephy_file_tmp_dir (void) return tmp_dir; } -/** - * 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: * @@ -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); -- cgit v1.2.3