diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-10-30 05:38:41 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-10-30 05:38:41 +0800 |
commit | bc541864b12e85185251765c99a103718b92b994 (patch) | |
tree | 698d93b981692c29cfad5f113e0795ad6fca01b4 | |
parent | cd07b3ec041e14b8ed23d0457cc8741eaaa1a00d (diff) | |
download | gsoc2013-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.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | doc/reference/tmpl/ephy-embed.sgml | 2 | ||||
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 45 | ||||
-rw-r--r-- | lib/ephy-file-chooser.c | 2 | ||||
-rw-r--r-- | lib/ephy-file-helpers.c | 41 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 2 | ||||
-rw-r--r-- | src/prefs-dialog.c | 25 |
7 files changed, 88 insertions, 42 deletions
@@ -1,3 +1,16 @@ +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. + 2005-10-29 Jean-François Rameau <jframeau@cvs.gnome.org> * src/ephy-window.c: (ephy_window_key_press_event): diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml index 063548e5b..868790a54 100644 --- a/doc/reference/tmpl/ephy-embed.sgml +++ b/doc/reference/tmpl/ephy-embed.sgml @@ -292,6 +292,8 @@ be done by casting). @: @: @: +@: +@: @: <!-- ##### SIGNAL EphyEmbed::ge-search-key-press ##### --> diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp index 3219dc9c5..cf8a4e3e6 100644 --- a/embed/mozilla/MozDownload.cpp +++ b/embed/mozilla/MozDownload.cpp @@ -53,7 +53,6 @@ #include "MozDownload.h" #include "EphyUtils.h" -#include <libgnomevfs/gnome-vfs-utils.h> #include <glib/gi18n.h> #include <nsIIOService.h> @@ -773,50 +772,22 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI static char* GetFilePath (const char *filename) { - char *path = NULL, *download_dir, *expanded; + const char *home_dir; + char *download_dir, *path; - download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR); + download_dir = ephy_file_get_downloads_dir (); - if (download_dir && strcmp (download_dir, "Downloads") == 0) + if (ephy_ensure_dir_exists (download_dir)) { - g_free (download_dir); - download_dir = ephy_file_downloads_dir (); + path = g_build_filename (download_dir, filename, NULL); } - 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; - } - - if (download_dir == NULL) - { - /* Emergency download destination */ - download_dir = g_strdup (g_get_home_dir ()); - } - - g_return_val_if_fail (download_dir != NULL, FALSE); - - expanded = gnome_vfs_expand_initial_tilde (download_dir); - if (ephy_ensure_dir_exists (expanded)) + else { - path = g_build_filename (expanded, filename, NULL); + home_dir = g_get_home_dir (); + path = g_build_filename (home_dir ? home_dir : "/", filename, NULL); } - g_free (expanded); g_free (download_dir); - if (path == NULL) - { - path = g_build_filename (g_get_home_dir (), filename, NULL); - } - return path; } 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); diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index 2b8d00bd1..60f965d78 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -1117,17 +1117,34 @@ create_language_section (EphyDialog *dialog) static void download_path_changed_cb (GtkFileChooser *button) { - char *dir; + char *dir, *downloads_dir, *desktop_dir; /* FIXME: use _uri variant when we support downloading * to gnome-vfs remote locations */ dir = gtk_file_chooser_get_filename (button); - if (dir != NULL) + if (dir == NULL) return; + + downloads_dir = ephy_file_downloads_dir (); + desktop_dir = ephy_file_desktop_dir (); + g_return_if_fail (downloads_dir != NULL && desktop_dir != NULL); + + if (strcmp (dir, downloads_dir) == 0) + { + eel_gconf_set_string (CONF_STATE_DOWNLOAD_DIR, "Downloads"); + } + else if (strcmp (dir, desktop_dir) == 0) + { + eel_gconf_set_string (CONF_STATE_DOWNLOAD_DIR, "Desktop"); + } + else { eel_gconf_set_path (CONF_STATE_DOWNLOAD_DIR, dir); - g_free (dir); } + + g_free (dir); + g_free (downloads_dir); + g_free (desktop_dir); } static void @@ -1137,7 +1154,7 @@ create_download_path_button (EphyDialog *dialog) EphyFileChooser *fc; char *dir; - dir = ephy_file_downloads_dir (); + dir = ephy_file_get_downloads_dir (); ephy_dialog_get_controls (dialog, properties[DOWNLOAD_PATH_HBOX_PROP].id, &hbox, |