[epiphany/downloads: 5/12] ephy-file-helpers: only one downloads_dir function



commit c2a039a7cfb0e35be90ce1fb8c9d3e6eac77923a
Author: Diego Escalante Urrelo <descalante igalia com>
Date:   Mon Nov 1 03:47:54 2010 -0500

    ephy-file-helpers: only one downloads_dir function
    
    Remove all the ambiguity, we always throw downloads to the same place or the
    Desktop.

 lib/ephy-file-helpers.c |   71 ++--------------------------------------------
 lib/ephy-file-helpers.h |    1 -
 src/prefs-dialog.c      |   34 ++--------------------
 3 files changed, 7 insertions(+), 99 deletions(-)
---
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 78a0739..268ef36 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 f2c4a4a..e290f38 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 74637a3..6dc66e4 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]