diff options
author | Xan Lopez <xlopez@igalia.com> | 2011-03-31 06:07:17 +0800 |
---|---|---|
committer | Xan Lopez <xlopez@igalia.com> | 2011-03-31 13:42:42 +0800 |
commit | 100b402f07967fd23c1ff7129543b841205f4692 (patch) | |
tree | f6d0f6a433ac9c5580241850147004fe98701e34 /lib | |
parent | e7ce7a3783fb3a7ba04915b8c82cce6422f967ec (diff) | |
download | gsoc2013-epiphany-100b402f07967fd23c1ff7129543b841205f4692.tar gsoc2013-epiphany-100b402f07967fd23c1ff7129543b841205f4692.tar.gz gsoc2013-epiphany-100b402f07967fd23c1ff7129543b841205f4692.tar.bz2 gsoc2013-epiphany-100b402f07967fd23c1ff7129543b841205f4692.tar.lz gsoc2013-epiphany-100b402f07967fd23c1ff7129543b841205f4692.tar.xz gsoc2013-epiphany-100b402f07967fd23c1ff7129543b841205f4692.tar.zst gsoc2013-epiphany-100b402f07967fd23c1ff7129543b841205f4692.zip |
ephy-file-helpers: respect our documented special keys for download dir
'Desktop' should be the desktop dir, 'Downloads' the downloads dir. If
the key is an actual path we'll use it, if all else fails default to
Desktop directory.
Bug #644641
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-file-helpers.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index 11c390689..efd35cba4 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -105,6 +105,19 @@ ephy_file_tmp_dir (void) return tmp_dir; } +static char * +ephy_file_download_dir (void) +{ + const char *xdg_download_dir; + + xdg_download_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD); + if (xdg_download_dir != NULL) + return g_strdup (xdg_download_dir); + + /* If we don't have XDG user dirs info, return an educated guess. */ + return g_build_filename (g_get_home_dir (), _("Downloads"), NULL); +} + /** * ephy_file_get_downloads_dir: * @@ -123,7 +136,9 @@ ephy_file_get_downloads_dir (void) EPHY_PREFS_STATE_DOWNLOAD_DIR); /* Emergency download destination */ - if (g_path_is_absolute (download_dir) != TRUE) + 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) download_dir = ephy_file_desktop_dir (); return download_dir; |