[epiphany] e-file-helpers: simplify ephy_file_get_downloads_dir



commit b3804abc15d4cc0aa927a5295d6552d4eb5e0626
Author: Diego Escalante Urrelo <diegoe igalia com>
Date:   Sun Apr 1 20:48:52 2012 -0500

    e-file-helpers: simplify ephy_file_get_downloads_dir
    
    Better explain the logic of the function and reorder the conditions.
    This makes ~/Downloads the fallback instead of ~/Desktop.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673337

 lib/ephy-file-helpers.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 414dd9e..13ae06d 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -119,9 +119,16 @@ ephy_file_download_dir (void)
 /**
  * ephy_file_get_downloads_dir:
  *
- * Gets the full path to the downloads dir. This uses ephy_file_downloads_dir()
- * internally and hence is locale dependant. Note that this can return %NULL if
- * not even the user homedir path can be found.
+ * Returns a proper downloads destination by checking the
+ * EPHY_PREFS_STATE_DOWNLOAD_DIR GSettings key and following this logic:
+ *
+ *  - An absolute path: considered user-set, use this value directly.
+ *
+ *  - "Desktop" keyword in GSettings: the directory returned by
+ *    ephy_file_desktop_dir().
+ *
+ *  - "Downloads" keyword in GSettings, or any other value: the XDG
+ *  downloads directory, or ~/Downloads.
  *
  * Returns: a newly-allocated string containing the path to the downloads dir.
  **/
@@ -133,11 +140,11 @@ ephy_file_get_downloads_dir (void)
 	download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
 					      EPHY_PREFS_STATE_DOWNLOAD_DIR);
 
-	/* Emergency download destination */
-	if (g_str_equal (download_dir, "Downloads"))
-		download_dir = ephy_file_download_dir ();
-	else if (g_str_equal (download_dir, "Desktop") || g_path_is_absolute (download_dir) != TRUE)
+	if (g_str_equal (download_dir, "Desktop"))
 		download_dir = ephy_file_desktop_dir ();
+	if (g_str_equal (download_dir, "Downloads") ||
+	    g_path_is_absolute (download_dir) != TRUE)
+		download_dir = ephy_file_download_dir ();
 
 	return download_dir;
 }



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