diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-09-20 19:28:53 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-09-20 19:28:53 +0800 |
commit | 7b653b5dce039fe86e9646e0d85aa647f3cf1dc0 (patch) | |
tree | 4ebb0c5d4b733eb37a23764bd448596b7132e086 | |
parent | 299aea88b01667397396ad664fa6e9dfe2c4a4bb (diff) | |
download | gsoc2013-epiphany-7b653b5dce039fe86e9646e0d85aa647f3cf1dc0.tar gsoc2013-epiphany-7b653b5dce039fe86e9646e0d85aa647f3cf1dc0.tar.gz gsoc2013-epiphany-7b653b5dce039fe86e9646e0d85aa647f3cf1dc0.tar.bz2 gsoc2013-epiphany-7b653b5dce039fe86e9646e0d85aa647f3cf1dc0.tar.lz gsoc2013-epiphany-7b653b5dce039fe86e9646e0d85aa647f3cf1dc0.tar.xz gsoc2013-epiphany-7b653b5dce039fe86e9646e0d85aa647f3cf1dc0.tar.zst gsoc2013-epiphany-7b653b5dce039fe86e9646e0d85aa647f3cf1dc0.zip |
Fix directory selection persistence [bug #122780].
2003-09-20 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-utils.c: (ephy_embed_utils_save):
* embed/mozilla/mozilla-embed-single.cpp:
* src/window-commands.c: (window_cmd_file_open):
Fix directory selection persistence [bug #122780].
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | embed/ephy-embed-utils.c | 29 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 6 | ||||
-rw-r--r-- | src/window-commands.c | 43 |
4 files changed, 48 insertions, 38 deletions
@@ -1,3 +1,11 @@ +2003-09-20 Christian Persch <chpe@cvs.gnome.org> + + * embed/ephy-embed-utils.c: (ephy_embed_utils_save): + * embed/mozilla/mozilla-embed-single.cpp: + * src/window-commands.c: (window_cmd_file_open): + + Fix directory selection persistence [bug #122780]. + 2003-09-18 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-favicon-cache.c: (ephy_favicon_cache_load): diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c index bddab9191..21b51281f 100644 --- a/embed/ephy-embed-utils.c +++ b/embed/ephy-embed-utils.c @@ -59,7 +59,6 @@ ephy_embed_utils_save (GtkWidget *window, char *retPath = NULL; char *fileName = NULL; char *dirName = NULL; - char *retDir; char *target; const char *source; gresult ret; @@ -134,18 +133,28 @@ ephy_embed_utils_save (GtkWidget *window, if (ask_dest) { + char *ret_dir; + /* show the file picker */ ret = ephy_embed_single_show_file_picker (single, window, title, dirName, fileName, modeSave, &retPath, NULL, NULL); - } - - - uri = gnome_vfs_uri_new (retPath); - g_return_if_fail (uri != NULL); - retDir = gnome_vfs_uri_extract_dirname (uri); + if (g_file_test (retPath, G_FILE_TEST_IS_DIR)) + { + ret_dir = g_strdup (retPath); + } + else + { + ret_dir = g_path_get_dirname (retPath); + } + + /* set default save dir */ + eel_gconf_set_string (default_dir_pref, ret_dir); + g_free (ret_dir); + + } if (ret == G_OK) { @@ -171,12 +180,6 @@ ephy_embed_utils_save (GtkWidget *window, } - /* set default save dir */ - eel_gconf_set_string (default_dir_pref, - retDir); - - g_free (retDir); - gnome_vfs_uri_unref (uri); g_free (retPath); g_object_unref (G_OBJECT(persist)); diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 9830c236c..8df565f50 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -36,6 +36,7 @@ #include <time.h> #include <libgnome/gnome-i18n.h> +#include <libgnomevfs/gnome-vfs-utils.h> #include <string.h> #include <nsICacheService.h> #include <nsCOMPtr.h> @@ -1058,15 +1059,14 @@ impl_show_file_picker (EphyEmbedSingle *shell, GFilePicker *filePicker = new GFilePicker (file_formats); - /* FIXME sane path: expand tilde ... */ - expanded_directory = g_strdup (directory); + expanded_directory = gnome_vfs_expand_initial_tilde (directory); /* make sure the directory exists, and use the home directory * otherwise */ if (!expanded_directory || !g_file_test (expanded_directory, G_FILE_TEST_IS_DIR)) { - if (expanded_directory) g_free (expanded_directory); + g_free (expanded_directory); expanded_directory = g_strdup (g_get_home_dir()); } diff --git a/src/window-commands.c b/src/window-commands.c index 66145daf4..04c596b16 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -318,10 +318,7 @@ void window_cmd_file_open (EggAction *action, EphyWindow *window) { - gchar *dir, *retDir; - gchar *file; - GnomeVFSURI *uri; - GtkWidget *wmain; + char *dir, *ret_dir, *file; EphyEmbedShell *embed_shell; gresult result; EphyEmbedSingle *single; @@ -331,35 +328,37 @@ window_cmd_file_open (EggAction *action, embed_shell = EPHY_EMBED_SHELL (ephy_shell); - wmain = GTK_WIDGET (window); - g_return_if_fail (wmain != NULL); - dir = eel_gconf_get_string (CONF_STATE_OPEN_DIR); result = ephy_embed_single_show_file_picker - (single, wmain, + (single, GTK_WIDGET (window), _("Open"), dir, NULL, modeOpen, &file, NULL, NULL); - uri = gnome_vfs_uri_new (file); - if (uri) + /* persist directory choice */ + /* Fix for bug 122780: + * if the user selected a directory, or aborted with no filename typed, + * g_path_get_dirname and gnome_vfs_uri_extract_dirname strip the last + * path component, so test if the returned file is actually a directory. + */ + if (g_file_test (file, G_FILE_TEST_IS_DIR)) { - retDir = gnome_vfs_uri_extract_dirname (uri); - - /* set default open dir */ - eel_gconf_set_string (CONF_STATE_OPEN_DIR, - retDir); + ret_dir = g_strdup (file); + } + else + { + ret_dir = g_path_get_dirname (file); + } - g_free (retDir); - gnome_vfs_uri_unref (uri); + eel_gconf_set_string (CONF_STATE_OPEN_DIR, ret_dir); - if (result == G_OK) - { - ephy_window_load_url(window, file); - } - } + if (result == G_OK) + { + ephy_window_load_url(window, file); + } + g_free (ret_dir); g_free (file); g_free (dir); } |