aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@igalia.com>2012-04-02 09:48:52 +0800
committerDiego Escalante Urrelo <diegoe@igalia.com>2012-05-24 11:21:10 +0800
commitb3804abc15d4cc0aa927a5295d6552d4eb5e0626 (patch)
treef7c582e68d133f956c4f0884fb459236b7a73a76
parent02e9b253ea8d127c766172f029379073cddb8f91 (diff)
downloadgsoc2013-epiphany-b3804abc15d4cc0aa927a5295d6552d4eb5e0626.tar.gz
gsoc2013-epiphany-b3804abc15d4cc0aa927a5295d6552d4eb5e0626.tar.zst
gsoc2013-epiphany-b3804abc15d4cc0aa927a5295d6552d4eb5e0626.zip
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
-rw-r--r--lib/ephy-file-helpers.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 414dd9e60..13ae06de2 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;
}