static void rename_callback (NautilusFile *file, GFile *result_location, GError *error, gpointer callback_data) { NautilusRenameData *data; gboolean cancelled = FALSE; g_assert (NAUTILUS_IS_FILE (file)); g_assert (callback_data == NULL); data = g_object_get_data (G_OBJECT (file), NEW_NAME_TAG); g_assert (data != NULL); if (error) { if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)) { /* If rename failed, notify the user. */ nautilus_report_error_renaming_file (file, data->name, error, NULL); } else { cancelled = TRUE; } } finish_rename (file, !cancelled, error); }
static void cancel_rename_callback (gpointer callback_data) { GError *error; error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled"); finish_rename (CAJA_FILE (callback_data), FALSE, error); g_error_free (error); }
void fm_rename_file (CajaFile *file, const char *new_name, CajaFileOperationCallback callback, gpointer callback_data) { char *old_name, *wait_message; FMRenameData *data; char *uri; GError *error; g_return_if_fail (CAJA_IS_FILE (file)); g_return_if_fail (new_name != NULL); /* Stop any earlier rename that's already in progress. */ error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled"); finish_rename (file, TRUE, error); g_error_free (error); data = g_new0 (FMRenameData, 1); data->name = g_strdup (new_name); data->callback = callback; data->callback_data = callback_data; /* Attach the new name to the file. */ g_object_set_data_full (G_OBJECT (file), NEW_NAME_TAG, data, (GDestroyNotify)fm_rename_data_free); /* Start the timed wait to cancel the rename. */ old_name = caja_file_get_display_name (file); wait_message = g_strdup_printf (_("Renaming \"%s\" to \"%s\"."), old_name, new_name); g_free (old_name); eel_timed_wait_start (cancel_rename_callback, file, wait_message, NULL); /* FIXME bugzilla.gnome.org 42395: Parent this? */ g_free (wait_message); uri = caja_file_get_uri (file); caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER, "rename file old=\"%s\", new=\"%s\"", uri, new_name); g_free (uri); /* Start the rename. */ caja_file_rename (file, new_name, rename_callback, NULL); }
void nautilus_rename_file (NautilusFile *file, const char *new_name, NautilusFileOperationCallback callback, gpointer callback_data) { char *old_name, *wait_message; NautilusRenameData *data; char *uri; GError *error; g_return_if_fail (NAUTILUS_IS_FILE (file)); g_return_if_fail (new_name != NULL); /* Stop any earlier rename that's already in progress. */ error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled"); finish_rename (file, TRUE, error); g_error_free (error); data = g_new0 (NautilusRenameData, 1); data->name = g_strdup (new_name); data->callback = callback; data->callback_data = callback_data; /* Attach the new name to the file. */ g_object_set_data_full (G_OBJECT (file), NEW_NAME_TAG, data, (GDestroyNotify)nautilus_rename_data_free); /* Start the timed wait to cancel the rename. */ old_name = nautilus_file_get_display_name (file); wait_message = g_strdup_printf (_("Renaming “%s” to “%s”."), old_name, new_name); g_free (old_name); eel_timed_wait_start (cancel_rename_callback, file, wait_message, NULL); /* FIXME bugzilla.gnome.org 42395: Parent this? */ g_free (wait_message); uri = nautilus_file_get_uri (file); DEBUG ("Renaming file %s to %s", uri, new_name); g_free (uri); /* Start the rename. */ nautilus_file_rename (file, new_name, rename_callback, NULL); }
static void rename_callback (AthenaFile *file, GFile *result_location, GError *error, gpointer callback_data) { AthenaRenameData *data; g_assert (ATHENA_IS_FILE (file)); g_assert (callback_data == NULL); data = g_object_get_data (G_OBJECT (file), NEW_NAME_TAG); g_assert (data != NULL); if (error && !(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)) { /* If rename failed, notify the user. */ athena_report_error_renaming_file (file, data->name, error, NULL); } finish_rename (file, TRUE, error); }