Commit 556d51aa authored by William Jon McCann's avatar William Jon McCann

Don't allow moving files on top of themselves

Desensitize the select button when the cwd is the parent of the source files.
parent 5a3481b8
......@@ -5940,6 +5940,41 @@ copy_data_free (CopyCallbackData *data)
g_free (data);
}
static gboolean
uri_is_parent_of_selection (GList *selection,
const char *uri)
{
gboolean found;
GList *l;
GFile *file;
found = FALSE;
file = g_file_new_for_uri (uri);
for (l = selection; !found && l != NULL; l = l->next) {
GFile *parent;
parent = nautilus_file_get_parent_location (l->data);
found = g_file_equal (file, parent);
g_object_unref (parent);
}
g_object_unref (file);
return found;
}
static void
on_destination_dialog_folder_changed (GtkFileChooser *chooser,
gpointer user_data)
{
CopyCallbackData *copy_data = user_data;
char *uri;
gboolean found;
uri = gtk_file_chooser_get_current_folder_uri (chooser);
found = uri_is_parent_of_selection (copy_data->selection, uri);
gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser), GTK_RESPONSE_OK, !found);
g_free (uri);
}
static void
on_destination_dialog_response (GtkDialog *dialog,
gint response_id,
......@@ -6071,7 +6106,9 @@ copy_or_move_selection (NautilusView *view,
uri = nautilus_directory_get_uri (view->details->model);
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), uri);
g_free (uri);
g_signal_connect (dialog, "current-folder-changed",
G_CALLBACK (on_destination_dialog_folder_changed),
copy_data);
g_signal_connect (dialog, "response",
G_CALLBACK (on_destination_dialog_response),
copy_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment