aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-10-30 05:38:41 +0800
committerChristian Persch <chpe@src.gnome.org>2005-10-30 05:38:41 +0800
commitbc541864b12e85185251765c99a103718b92b994 (patch)
tree698d93b981692c29cfad5f113e0795ad6fca01b4 /lib
parentcd07b3ec041e14b8ed23d0457cc8741eaaa1a00d (diff)
downloadgsoc2013-epiphany-bc541864b12e85185251765c99a103718b92b994.tar
gsoc2013-epiphany-bc541864b12e85185251765c99a103718b92b994.tar.gz
gsoc2013-epiphany-bc541864b12e85185251765c99a103718b92b994.tar.bz2
gsoc2013-epiphany-bc541864b12e85185251765c99a103718b92b994.tar.lz
gsoc2013-epiphany-bc541864b12e85185251765c99a103718b92b994.tar.xz
gsoc2013-epiphany-bc541864b12e85185251765c99a103718b92b994.tar.zst
gsoc2013-epiphany-bc541864b12e85185251765c99a103718b92b994.zip
Add ephy_file_get_downloads_dir() to get the actual downloads directory,
2005-10-29 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/MozDownload.cpp: * lib/ephy-file-chooser.c: (ephy_file_chooser_constructor): * lib/ephy-file-helpers.c: (ephy_file_get_downloads_dir): * lib/ephy-file-helpers.h: * src/prefs-dialog.c: (download_path_changed_cb), (create_download_path_button): Add ephy_file_get_downloads_dir() to get the actual downloads directory, and use it in the prefs dialogue, the filechooser, and the backend.
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-file-chooser.c2
-rw-r--r--lib/ephy-file-helpers.c41
-rw-r--r--lib/ephy-file-helpers.h2
3 files changed, 44 insertions, 1 deletions
diff --git a/lib/ephy-file-chooser.c b/lib/ephy-file-chooser.c
index 4ce3b38d4..faf94ed9b 100644
--- a/lib/ephy-file-chooser.c
+++ b/lib/ephy-file-chooser.c
@@ -111,7 +111,7 @@ ephy_file_chooser_constructor (GType type,
object = parent_class->constructor (type, n_construct_properties,
construct_params);
- downloads_dir = ephy_file_downloads_dir ();
+ downloads_dir = ephy_file_get_downloads_dir ();
gtk_file_chooser_add_shortcut_folder
(GTK_FILE_CHOOSER (object), downloads_dir, NULL);
g_free (downloads_dir);
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 45278b31a..db8950f20 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -108,6 +108,47 @@ ephy_file_downloads_dir (void)
}
char *
+ephy_file_get_downloads_dir (void)
+{
+ char *path = NULL, *download_dir, *home_dir, *expanded;
+
+ download_dir = eel_gconf_get_string (CONF_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)
+ {
+ 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 = gnome_vfs_expand_initial_tilde (download_dir);
+ g_free (download_dir);
+
+ return expanded;
+}
+
+char *
ephy_file_desktop_dir (void)
{
char *downloads_dir;
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index 81fdd90f5..2e5b7f111 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -45,6 +45,8 @@ 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);