From b3804abc15d4cc0aa927a5295d6552d4eb5e0626 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Sun, 1 Apr 2012 20:48:52 -0500 Subject: 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 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib') 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; } -- cgit v1.2.3