add a new struct field to clear the file entry after the current folder

2007-05-01  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
        (update_current_folder_get_info_cb): add a new struct field to clear
        the file entry after the current folder has been updated.

        (gtk_file_chooser_default_update_current_folder),
        (change_folder_and_display_error): Add a new function parameter to
        trigger file entry clearing.

        (edited_idle_create_folder_cb),
        (file_list_drag_data_received_get_info_cb),
        (gtk_file_chooser_default_map),
        (gtk_file_chooser_default_set_current_folder),
        (switch_to_selected_folder), (save_entry_get_info_cb),
        (shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
        (shortcuts_activate_get_info_cb), (list_row_activated),
        (path_bar_clicked): use new function parameter appropriately.

        (gtk_file_chooser_default_should_respond): trigger file entry clearing
        after the directory is updated instead of clearing it before, this way
        we avoid reloading the completion model with the soon to be old folder,
        causing a warning and a glitch in the folder where completion happens.
        (#379414, Carlos Garnacho)


svn path=/trunk/; revision=17754
This commit is contained in:
Matthias Clasen 2007-05-01 20:35:33 +00:00 committed by Matthias Clasen
parent 2a80113304
commit a9423f4964
2 changed files with 52 additions and 18 deletions

View File

@ -1,6 +1,31 @@
2007-05-01 Matthias Clasen <mclasen@redhat.com> 2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconcachvalidator.[hc]: Add an icon cache validator. * gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconcachevalidator.[hc]: Add an icon cache validator.
* gtk/updateiconcache.c: Validate the generated cache before * gtk/updateiconcache.c: Validate the generated cache before
moving it in place. Also add a --validate option to validate moving it in place. Also add a --validate option to validate

View File

@ -278,6 +278,7 @@ static gboolean gtk_file_chooser_default_set_current_folder (GtkFileCh
static gboolean gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser, static gboolean gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser,
const GtkFilePath *path, const GtkFilePath *path,
gboolean keep_trail, gboolean keep_trail,
gboolean clear_entry,
GError **error); GError **error);
static GtkFilePath * gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser); static GtkFilePath * gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser);
static void gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser, static void gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
@ -1007,7 +1008,8 @@ error_changing_folder_dialog (GtkFileChooserDefault *impl,
/* Changes folders, displaying an error dialog if this fails */ /* Changes folders, displaying an error dialog if this fails */
static gboolean static gboolean
change_folder_and_display_error (GtkFileChooserDefault *impl, change_folder_and_display_error (GtkFileChooserDefault *impl,
const GtkFilePath *path) const GtkFilePath *path,
gboolean clear_entry)
{ {
GError *error; GError *error;
gboolean result; gboolean result;
@ -1029,7 +1031,7 @@ change_folder_and_display_error (GtkFileChooserDefault *impl,
path_copy = gtk_file_path_copy (path); path_copy = gtk_file_path_copy (path);
error = NULL; error = NULL;
result = gtk_file_chooser_default_update_current_folder (GTK_FILE_CHOOSER (impl), path_copy, TRUE, &error); result = gtk_file_chooser_default_update_current_folder (GTK_FILE_CHOOSER (impl), path_copy, TRUE, clear_entry, &error);
if (!result) if (!result)
error_changing_folder_dialog (impl, path_copy, error); error_changing_folder_dialog (impl, path_copy, error);
@ -2144,7 +2146,7 @@ edited_idle_create_folder_cb (GtkFileSystemHandle *handle,
goto out; goto out;
if (!error) if (!error)
change_folder_and_display_error (impl, path); change_folder_and_display_error (impl, path, FALSE);
else else
error_creating_folder_dialog (impl, path, g_error_copy (error)); error_creating_folder_dialog (impl, path, g_error_copy (error));
@ -3788,7 +3790,7 @@ file_list_drag_data_received_get_info_cb (GtkFileSystemHandle *handle,
data->impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) && data->impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) &&
data->uris[1] == 0 && !error && data->uris[1] == 0 && !error &&
gtk_file_info_get_is_folder (info)) gtk_file_info_get_is_folder (info))
change_folder_and_display_error (data->impl, data->path); change_folder_and_display_error (data->impl, data->path, FALSE);
else else
{ {
GError *error = NULL; GError *error = NULL;
@ -5528,7 +5530,7 @@ gtk_file_chooser_default_map (GtkWidget *widget)
if (impl->current_folder) if (impl->current_folder)
{ {
pending_select_paths_store_selection (impl); pending_select_paths_store_selection (impl);
change_folder_and_display_error (impl, impl->current_folder); change_folder_and_display_error (impl, impl->current_folder, FALSE);
} }
break; break;
@ -6253,7 +6255,7 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
const GtkFilePath *path, const GtkFilePath *path,
GError **error) GError **error)
{ {
return gtk_file_chooser_default_update_current_folder (chooser, path, FALSE, error); return gtk_file_chooser_default_update_current_folder (chooser, path, FALSE, FALSE, error);
} }
@ -6262,6 +6264,7 @@ struct UpdateCurrentFolderData
GtkFileChooserDefault *impl; GtkFileChooserDefault *impl;
GtkFilePath *path; GtkFilePath *path;
gboolean keep_trail; gboolean keep_trail;
gboolean clear_entry;
GtkFilePath *original_path; GtkFilePath *original_path;
GError *original_error; GError *original_error;
}; };
@ -6367,8 +6370,13 @@ update_current_folder_get_info_cb (GtkFileSystemHandle *handle,
/* Set the folder on the save entry */ /* Set the folder on the save entry */
if (impl->location_entry) if (impl->location_entry)
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), {
impl->current_folder); _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->location_entry),
impl->current_folder);
if (data->clear_entry)
_gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), "");
}
/* Create a new list model. This is slightly evil; we store the result value /* Create a new list model. This is slightly evil; we store the result value
* but perform more actions rather than returning immediately even if it * but perform more actions rather than returning immediately even if it
@ -6398,6 +6406,7 @@ static gboolean
gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser, gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser,
const GtkFilePath *path, const GtkFilePath *path,
gboolean keep_trail, gboolean keep_trail,
gboolean clear_entry,
GError **error) GError **error)
{ {
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser); GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
@ -6427,6 +6436,7 @@ gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser,
data->impl = impl; data->impl = impl;
data->path = gtk_file_path_copy (path); data->path = gtk_file_path_copy (path);
data->keep_trail = keep_trail; data->keep_trail = keep_trail;
data->clear_entry = clear_entry;
impl->reload_state = RELOAD_HAS_FOLDER; impl->reload_state = RELOAD_HAS_FOLDER;
@ -7291,7 +7301,7 @@ switch_to_selected_folder (GtkFileChooserDefault *impl)
g_assert (closure.path && closure.num_selected == 1); g_assert (closure.path && closure.num_selected == 1);
change_folder_and_display_error (impl, closure.path); change_folder_and_display_error (impl, closure.path, FALSE);
} }
/* Gets the GtkFileInfo for the selected row in the file list; assumes single /* Gets the GtkFileInfo for the selected row in the file list; assumes single
@ -7586,7 +7596,7 @@ save_entry_get_info_cb (GtkFileSystemHandle *handle,
else else
{ {
/* This will display an error, which is what we want */ /* This will display an error, which is what we want */
change_folder_and_display_error (data->impl, data->parent_path); change_folder_and_display_error (data->impl, data->parent_path, FALSE);
} }
out: out:
@ -7831,8 +7841,7 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
|| impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) || impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
{ {
_gtk_file_chooser_entry_set_file_part (entry, ""); change_folder_and_display_error (impl, path, TRUE);
change_folder_and_display_error (impl, path);
retval = FALSE; retval = FALSE;
} }
else if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER else if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
@ -8089,7 +8098,7 @@ shortcuts_activate_volume_mount_cb (GtkFileSystemHandle *handle,
path = gtk_file_system_volume_get_base_path (impl->file_system, volume); path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
if (path != NULL) if (path != NULL)
{ {
change_folder_and_display_error (impl, path); change_folder_and_display_error (impl, path, FALSE);
gtk_file_path_free (path); gtk_file_path_free (path);
} }
@ -8127,7 +8136,7 @@ shortcuts_activate_volume (GtkFileChooserDefault *impl,
path = gtk_file_system_volume_get_base_path (impl->file_system, volume); path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
if (path != NULL) if (path != NULL)
{ {
change_folder_and_display_error (impl, path); change_folder_and_display_error (impl, path, FALSE);
gtk_file_path_free (path); gtk_file_path_free (path);
} }
} }
@ -8160,7 +8169,7 @@ shortcuts_activate_get_info_cb (GtkFileSystemHandle *handle,
goto out; goto out;
if (!error && gtk_file_info_get_is_folder (info)) if (!error && gtk_file_info_get_is_folder (info))
change_folder_and_display_error (data->impl, data->path); change_folder_and_display_error (data->impl, data->path, FALSE);
else else
gtk_file_chooser_default_select_path (GTK_FILE_CHOOSER (data->impl), data->path, NULL); gtk_file_chooser_default_select_path (GTK_FILE_CHOOSER (data->impl), data->path, NULL);
@ -8360,7 +8369,7 @@ list_row_activated (GtkTreeView *tree_view,
const GtkFilePath *file_path; const GtkFilePath *file_path;
file_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter); file_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
change_folder_and_display_error (impl, file_path); change_folder_and_display_error (impl, file_path, FALSE);
return; return;
} }
@ -8380,7 +8389,7 @@ path_bar_clicked (GtkPathBar *path_bar,
if (child_path) if (child_path)
pending_select_paths_add (impl, child_path); pending_select_paths_add (impl, child_path);
if (!change_folder_and_display_error (impl, file_path)) if (!change_folder_and_display_error (impl, file_path, FALSE))
return; return;
/* Say we have "/foo/bar/[.baz]" and the user clicks on "bar". We should then /* Say we have "/foo/bar/[.baz]" and the user clicks on "bar". We should then