From 7b653b5dce039fe86e9646e0d85aa647f3cf1dc0 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sat, 20 Sep 2003 11:28:53 +0000 Subject: Fix directory selection persistence [bug #122780]. 2003-09-20 Christian Persch * 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]. --- src/window-commands.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'src/window-commands.c') 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); } -- cgit v1.2.3