From f270f2250fac7cd1ee3d3ef655c2cfe80cd1225f Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Mon, 4 Sep 2006 20:09:08 +0000 Subject: [PATCH] if setting the given folder failed, try setting the parent folder until we 2006-09-04 Kristian Rietveld * gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb): if setting the given folder failed, try setting the parent folder until we succeed; display an error box at the end. --- ChangeLog | 6 +++++ gtk/gtkfilechooserdefault.c | 49 +++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2ba206e0d..f89ebee714 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-04 Kristian Rietveld + + * gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb): + if setting the given folder failed, try setting the parent folder + until we succeed; display an error box at the end. + 2006-09-04 Kristian Rietveld * gtk/gtkpathbar.c (gtk_path_bar_dispose): don't cancel the diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 6c50ef3c05..74d2dc5439 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -6138,6 +6138,8 @@ struct UpdateCurrentFolderData GtkFileChooserDefault *impl; GtkFilePath *path; gboolean keep_trail; + GtkFilePath *original_path; + GError *original_error; }; static void @@ -6163,8 +6165,51 @@ update_current_folder_get_info_cb (GtkFileSystemHandle *handle, if (error) { - error_changing_folder_dialog (impl, data->path, g_error_copy (error)); - goto out; + GtkFilePath *parent_path; + + if (!data->original_path) + { + data->original_path = gtk_file_path_copy (data->path); + data->original_error = g_error_copy (error); + } + + /* get parent path and try to change the folder to that */ + if (gtk_file_system_get_parent (impl->file_system, data->path, &parent_path, NULL)) + { + gtk_file_path_free (data->path); + data->path = parent_path; + + g_object_unref (handle); + + /* restart the update current folder operation */ + impl->reload_state = RELOAD_HAS_FOLDER; + + impl->update_current_folder_handle = + gtk_file_system_get_info (impl->file_system, data->path, + GTK_FILE_INFO_IS_FOLDER, + update_current_folder_get_info_cb, + data); + + set_busy_cursor (impl, TRUE); + + return; + } + else + { + /* error and bail out */ + error_changing_folder_dialog (impl, data->original_path, data->original_error); + + gtk_file_path_free (data->original_path); + + goto out; + } + } + + if (data->original_path) + { + error_changing_folder_dialog (impl, data->original_path, data->original_error); + + gtk_file_path_free (data->original_path); } if (!gtk_file_info_get_is_folder (info))