void nautilus_directory_notify_files_moved_by_uri (GList *uri_pairs) { GList *file_pairs; file_pairs = uri_pairs_to_file_pairs (uri_pairs); nautilus_directory_notify_files_moved (file_pairs); g_list_foreach (file_pairs, (GFunc)g_file_pair_free, NULL); g_list_free (file_pairs); }
/* go through changes in the change queue, send ones with the same kind * in a list to the different nautilus_directory_notify calls */ void nautilus_file_changes_consume_changes (gboolean consume_all) { NautilusFileChange *change; GList *additions, *changes, *deletions, *moves; GList *metadata_copy_requests, *metadata_move_requests, *metadata_remove_requests; GList *position_set_requests; GFilePair *pair; NautilusFileChangesQueuePosition *position_set; guint chunk_count; NautilusFileChangesQueue *queue; gboolean flush_needed; additions = NULL; changes = NULL; deletions = NULL; moves = NULL; metadata_copy_requests = NULL; metadata_move_requests = NULL; metadata_remove_requests = NULL; position_set_requests = NULL; queue = nautilus_file_changes_queue_get(); /* Consume changes from the queue, stuffing them into one of three lists, * keep doing it while the changes are of the same kind, then send them off. * This is to ensure that the changes get sent off in the same order that they * arrived. */ for (chunk_count = 0; ; chunk_count++) { change = nautilus_file_changes_queue_get_change (queue); /* figure out if we need to flush the pending changes that we collected sofar */ if (change == NULL) { flush_needed = TRUE; /* no changes left, flush everything */ } else { flush_needed = additions != NULL && change->kind != CHANGE_FILE_ADDED && change->kind != CHANGE_METADATA_COPIED && change->kind != CHANGE_POSITION_SET && change->kind != CHANGE_POSITION_REMOVE; flush_needed |= changes != NULL && change->kind != CHANGE_FILE_CHANGED; flush_needed |= moves != NULL && change->kind != CHANGE_FILE_MOVED && change->kind != CHANGE_METADATA_MOVED && change->kind != CHANGE_POSITION_SET && change->kind != CHANGE_POSITION_REMOVE; flush_needed |= deletions != NULL && change->kind != CHANGE_FILE_REMOVED && change->kind != CHANGE_METADATA_REMOVED; flush_needed |= metadata_copy_requests != NULL && change->kind != CHANGE_FILE_ADDED && change->kind != CHANGE_METADATA_COPIED && change->kind != CHANGE_POSITION_SET && change->kind != CHANGE_POSITION_REMOVE; flush_needed |= metadata_move_requests != NULL && change->kind != CHANGE_FILE_MOVED && change->kind != CHANGE_METADATA_MOVED && change->kind != CHANGE_POSITION_SET && change->kind != CHANGE_POSITION_REMOVE; flush_needed |= metadata_remove_requests != NULL && change->kind != CHANGE_FILE_REMOVED && change->kind != CHANGE_METADATA_REMOVED; flush_needed |= position_set_requests != NULL && change->kind != CHANGE_POSITION_SET && change->kind != CHANGE_POSITION_REMOVE && change->kind != CHANGE_FILE_ADDED && change->kind != CHANGE_FILE_MOVED && change->kind != CHANGE_METADATA_COPIED && change->kind != CHANGE_METADATA_MOVED; flush_needed |= !consume_all && chunk_count >= CONSUME_CHANGES_MAX_CHUNK; /* we have reached the chunk maximum */ } if (flush_needed) { /* Send changes we collected off. * At one time we may only have one of the lists * contain changes. */ if (deletions != NULL) { deletions = g_list_reverse (deletions); nautilus_directory_notify_files_removed (deletions); eel_g_object_list_free (deletions); deletions = NULL; } if (moves != NULL) { moves = g_list_reverse (moves); nautilus_directory_notify_files_moved (moves); pairs_list_free (moves); moves = NULL; } if (additions != NULL) { additions = g_list_reverse (additions); nautilus_directory_notify_files_added (additions); eel_g_object_list_free (additions); additions = NULL; } if (changes != NULL) { changes = g_list_reverse (changes); nautilus_directory_notify_files_changed (changes); eel_g_object_list_free (changes); changes = NULL; } if (metadata_copy_requests != NULL) { metadata_copy_requests = g_list_reverse (metadata_copy_requests); nautilus_directory_schedule_metadata_copy (metadata_copy_requests); pairs_list_free (metadata_copy_requests); metadata_copy_requests = NULL; } if (metadata_move_requests != NULL) { metadata_move_requests = g_list_reverse (metadata_move_requests); nautilus_directory_schedule_metadata_move (metadata_move_requests); pairs_list_free (metadata_move_requests); metadata_move_requests = NULL; } if (metadata_remove_requests != NULL) { metadata_remove_requests = g_list_reverse (metadata_remove_requests); nautilus_directory_schedule_metadata_remove (metadata_remove_requests); eel_g_object_list_free (metadata_remove_requests); metadata_remove_requests = NULL; } if (position_set_requests != NULL) { position_set_requests = g_list_reverse (position_set_requests); nautilus_directory_schedule_position_set (position_set_requests); position_set_list_free (position_set_requests); position_set_requests = NULL; } } if (change == NULL) { /* we are done */ return; } /* add the new change to the list */ switch (change->kind) { case CHANGE_FILE_ADDED: additions = g_list_prepend (additions, change->from); break; case CHANGE_FILE_CHANGED: changes = g_list_prepend (changes, change->from); break; case CHANGE_FILE_REMOVED: deletions = g_list_prepend (deletions, change->from); break; case CHANGE_FILE_MOVED: pair = g_new (GFilePair, 1); pair->from = change->from; pair->to = change->to; moves = g_list_prepend (moves, pair); break; case CHANGE_METADATA_COPIED: pair = g_new (GFilePair, 1); pair->from = change->from; pair->to = change->to; metadata_copy_requests = g_list_prepend (metadata_copy_requests, pair); break; case CHANGE_METADATA_MOVED: pair = g_new (GFilePair, 1); pair->from = change->from; pair->to = change->to; metadata_move_requests = g_list_prepend (metadata_move_requests, pair); break; case CHANGE_METADATA_REMOVED: metadata_remove_requests = g_list_prepend (metadata_remove_requests, change->from); break; case CHANGE_POSITION_SET: position_set = g_new (NautilusFileChangesQueuePosition, 1); position_set->location = change->from; position_set->set = TRUE; position_set->point = change->point; position_set->screen = change->screen; position_set_requests = g_list_prepend (position_set_requests, position_set); break; case CHANGE_POSITION_REMOVE: position_set = g_new (NautilusFileChangesQueuePosition, 1); position_set->location = change->from; position_set->set = FALSE; position_set_requests = g_list_prepend (position_set_requests, position_set); break; default: g_assert_not_reached (); break; } g_free (change); } }