summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file-changes-queue.c
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2001-03-24 00:36:45 +0000
committerDarin Adler <darin@src.gnome.org>2001-03-24 00:36:45 +0000
commit92312a5f28aab657b9c87e77aa290d5337b3245c (patch)
tree5678f98689c7060408a75e82be3f41d228e391c3 /libnautilus-private/nautilus-file-changes-queue.c
parenta62c1cdb14238a9071b8f2c4af3e4ea46b627af6 (diff)
downloadnautilus-92312a5f28aab657b9c87e77aa290d5337b3245c.tar.gz
reviewed by: Pavel Cisler <pavel@eazel.com>
More loose ends of the file copy and paste feature. * libnautilus-extensions/nautilus-directory-notify.h: Rename NautilusFileChangesQueuePositionSetting to NautilusFileChangesQueuePosition. Add a field so it can be used to set or remove a position. Rename nautilus_directory_schedule_position_setting to nautilus_directory_schedule_position_set. * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_schedule_position_set): Change name and also make it handle the case where we want to remove a position rather than setting it. * libnautilus-extensions/nautilus-file-changes-queue.h: * libnautilus-extensions/nautilus-file-changes-queue.c: (nautilus_file_changes_queue_schedule_position_set): Name change. (nautilus_file_changes_queue_schedule_position_remove): New function used to remove a position. (position_set_list_free): Name changes, added the new remove flavor where needed. (nautilus_file_changes_consume_changes): Updated SET case, added case for REMOVE. * libnautilus-extensions/nautilus-file-operations.c: (icon_position_iterator_get_next): New function, used to extract the next position out of the iterator. (apply_one_position): Simplified by using icon_position_iterator_get_next, and also changed so that the position is always either removed or set. * libnautilus-extensions/nautilus-file-operations.h: Fixed header. * libnautilus-extensions/nautilus-gtk-extensions.h: * libnautilus-extensions/nautilus-gtk-extensions.c: (event_get_time), (nautilus_get_current_event_time): Add new function to get the current event time. This is available in GTK 2.0, so we can remove it when we move up. * libnautilus-extensions/nautilus-link.c: (nautilus_link_local_create): Updated for change to notify API. * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_from_command): Added FIXME. * src/file-manager/fm-directory-view.c: (copy_or_cut_files): Use new nautilus_get_current_event_time function. Put up a status string about the cut or copy. Since there's no other feedback this is especially important. (paste_files_callback): Use new nautilus_get_current_event_time function. (real_selection_clear_event): Erase the status string. (real_selection_received): Put up a status string if the paste does nothing. Since we can't desensitize the Paste Files command, this is the next best thing.
Diffstat (limited to 'libnautilus-private/nautilus-file-changes-queue.c')
-rw-r--r--libnautilus-private/nautilus-file-changes-queue.c137
1 files changed, 82 insertions, 55 deletions
diff --git a/libnautilus-private/nautilus-file-changes-queue.c b/libnautilus-private/nautilus-file-changes-queue.c
index def67f421..d1a0c27fe 100644
--- a/libnautilus-private/nautilus-file-changes-queue.c
+++ b/libnautilus-private/nautilus-file-changes-queue.c
@@ -1,8 +1,6 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
- nautilus-directory.h: Nautilus directory model.
-
- Copyright (C) 1999, 2000 Eazel, Inc.
+ Copyright (C) 1999, 2000, 2001 Eazel, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -23,9 +21,9 @@
*/
#include <config.h>
+#include "nautilus-file-changes-queue.h"
#include "nautilus-directory-notify.h"
-#include "nautilus-file-changes-queue.h"
#include "nautilus-glib-extensions.h"
#ifdef G_THREADS_ENABLED
@@ -44,7 +42,8 @@ typedef enum {
CHANGE_METADATA_COPIED,
CHANGE_METADATA_MOVED,
CHANGE_METADATA_REMOVED,
- CHANGE_POSITION_SET
+ CHANGE_POSITION_SET,
+ CHANGE_POSITION_REMOVE
} NautilusFileChangeKind;
typedef struct {
@@ -227,8 +226,8 @@ nautilus_file_changes_queue_schedule_metadata_remove (const char *uri)
}
void
-nautilus_file_changes_queue_schedule_position_setting (const char *uri,
- GdkPoint point)
+nautilus_file_changes_queue_schedule_position_set (const char *uri,
+ GdkPoint point)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -242,6 +241,20 @@ nautilus_file_changes_queue_schedule_position_setting (const char *uri,
nautilus_file_changes_queue_add_common (queue, new_item);
}
+void
+nautilus_file_changes_queue_schedule_position_remove (const char *uri)
+{
+ NautilusFileChange *new_item;
+ NautilusFileChangesQueue *queue;
+
+ queue = nautilus_file_changes_queue_get ();
+
+ new_item = g_new (NautilusFileChange, 1);
+ new_item->kind = CHANGE_POSITION_REMOVE;
+ new_item->from_uri = g_strdup (uri);
+ nautilus_file_changes_queue_add_common (queue, new_item);
+}
+
static NautilusFileChange *
nautilus_file_changes_queue_get_change (NautilusFileChangesQueue *queue)
{
@@ -293,10 +306,10 @@ pairs_list_free (GList *pairs)
}
static void
-position_setting_list_free (GList *list)
+position_set_list_free (GList *list)
{
GList *p;
- NautilusFileChangesQueuePositionSetting *item;
+ NautilusFileChangesQueuePosition *item;
for (p = list; p != NULL; p = p->next) {
item = p->data;
@@ -315,9 +328,9 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
NautilusFileChange *change;
GList *additions, *deletions, *moves;
GList *metadata_copy_requests, *metadata_move_requests, *metadata_remove_requests;
- GList *position_setting_requests;
+ GList *position_set_requests;
URIPair *pair;
- NautilusFileChangesQueuePositionSetting *position_setting;
+ NautilusFileChangesQueuePosition *position_set;
guint chunk_count;
NautilusFileChangesQueue *queue;
gboolean flush_needed;
@@ -329,7 +342,7 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
metadata_copy_requests = NULL;
metadata_move_requests = NULL;
metadata_remove_requests = NULL;
- position_setting_requests = NULL;
+ position_set_requests = NULL;
queue = nautilus_file_changes_queue_get();
@@ -347,51 +360,56 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
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));
-
- flush_needed |= (moves != NULL
- && (change->kind != CHANGE_FILE_MOVED
- && change->kind != CHANGE_METADATA_MOVED
- && change->kind != CHANGE_POSITION_SET));
-
- 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));
-
- flush_needed |= (metadata_move_requests != NULL
- && (change->kind != CHANGE_FILE_MOVED
- && change->kind != CHANGE_METADATA_MOVED
- && change->kind != CHANGE_POSITION_SET));
+ 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 |= 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 |= metadata_remove_requests != NULL
+ && change->kind != CHANGE_FILE_REMOVED
+ && change->kind != CHANGE_METADATA_REMOVED;
- flush_needed |= (position_setting_requests != NULL
- && (change->kind != CHANGE_POSITION_SET
- && change->kind != CHANGE_FILE_ADDED
- && change->kind != CHANGE_FILE_MOVED
- && change->kind != CHANGE_METADATA_COPIED
- && change->kind != CHANGE_METADATA_MOVED));
+ 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) {
nautilus_directory_notify_files_removed (deletions);
nautilus_g_list_free_deep (deletions);
@@ -422,10 +440,10 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
nautilus_g_list_free_deep (metadata_remove_requests);
metadata_remove_requests = NULL;
}
- if (position_setting_requests != NULL) {
- nautilus_directory_schedule_position_setting (position_setting_requests);
- position_setting_list_free (position_setting_requests);
- position_setting_requests = NULL;
+ if (position_set_requests != NULL) {
+ nautilus_directory_schedule_position_set (position_set_requests);
+ position_set_list_free (position_set_requests);
+ position_set_requests = NULL;
}
}
@@ -471,11 +489,20 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
break;
case CHANGE_POSITION_SET:
- position_setting = g_new (NautilusFileChangesQueuePositionSetting, 1);
- position_setting->uri = change->from_uri;
- position_setting->point = change->point;
- position_setting_requests = g_list_append (position_setting_requests,
- position_setting);
+ position_set = g_new (NautilusFileChangesQueuePosition, 1);
+ position_set->uri = change->from_uri;
+ position_set->set = TRUE;
+ position_set->point = change->point;
+ position_set_requests = g_list_append (position_set_requests,
+ position_set);
+ break;
+
+ case CHANGE_POSITION_REMOVE:
+ position_set = g_new (NautilusFileChangesQueuePosition, 1);
+ position_set->uri = change->from_uri;
+ position_set->set = FALSE;
+ position_set_requests = g_list_append (position_set_requests,
+ position_set);
break;
default: