diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-09-26 02:06:29 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-09-26 02:06:29 +0800 |
commit | 6a5efeb0f98a88afbbe18af740df7a209bb1c71b (patch) | |
tree | 0b7cc11115a6fa4ff45f634545fad0c842c1e7d0 /shell/e-storage-set.c | |
parent | 541c29f0d9914395cf5a2b840edc5e88c5f809bd (diff) | |
download | gsoc2013-evolution-6a5efeb0f98a88afbbe18af740df7a209bb1c71b.tar.gz gsoc2013-evolution-6a5efeb0f98a88afbbe18af740df7a209bb1c71b.tar.zst gsoc2013-evolution-6a5efeb0f98a88afbbe18af740df7a209bb1c71b.zip |
[Finish fixing #11645.]
* e-shell-folder-commands.c (xfer_result_callback): Don't update
the shortcuts here anymore since now the shell takes care of it.
* e-shell.c (storage_set_moved_folder_callback): New callback for
EStorageSetView::folder_moved; update the shortcuts.
(e_shell_construct): Connect.
* e-storage-set.c: Renamed StorageConverterCallbackData to
StorageCallbackData. New members destination_folder,
source_folder, operation in it.
(class_init): Install "moved_folder" signal.
(storage_callback_data_new): Renamed from
storage_converter_callback_data_new.
(storage_callback_data_free): New.
(storage_callback): Renamed from storage_callback_converter. Use
storage_callback_data_free().
(e_storage_set_async_create_folder): Updated to use the
storage_callback and storage_callback_data_new().
(e_storage_set_async_remove_folder): Likewise.
(e_storage_set_async_xfer_folder): Likewise.
* e-storage-set.h: New signal "moved_folder".
svn path=/trunk/; revision=18216
Diffstat (limited to 'shell/e-storage-set.c')
-rw-r--r-- | shell/e-storage-set.c | 105 |
1 files changed, 78 insertions, 27 deletions
diff --git a/shell/e-storage-set.c b/shell/e-storage-set.c index 17c66ce672..6303ef9320 100644 --- a/shell/e-storage-set.c +++ b/shell/e-storage-set.c @@ -63,6 +63,7 @@ enum { NEW_FOLDER, UPDATED_FOLDER, REMOVED_FOLDER, + MOVED_FOLDER, CLOSE_FOLDER, LAST_SIGNAL }; @@ -106,42 +107,74 @@ name_to_named_storage_foreach_destroy (void *key, /* "Callback converter", from `EStorageResultCallback' to `EStorageSetResultCallback'. */ -struct _StorageCallbackConverterData { +enum _StorageOperation { + OPERATION_COPY, + OPERATION_MOVE, + OPERATION_REMOVE, + OPERATION_CREATE +}; +typedef enum _StorageOperation StorageOperation; + +struct _StorageCallbackData { EStorageSet *storage_set; EStorageSetResultCallback storage_set_result_callback; + char *source_path; + char *destination_path; + StorageOperation operation; void *data; }; -typedef struct _StorageCallbackConverterData StorageCallbackConverterData; - -static StorageCallbackConverterData * -storage_callback_converter_data_new (EStorageSet *storage_set, - EStorageSetResultCallback callback, - void *data) +typedef struct _StorageCallbackData StorageCallbackData; + +static StorageCallbackData * +storage_callback_data_new (EStorageSet *storage_set, + EStorageSetResultCallback callback, + const char *source_path, + const char *destination_path, + StorageOperation operation, + void *data) { - StorageCallbackConverterData *new; + StorageCallbackData *new; - new = g_new (StorageCallbackConverterData, 1); + new = g_new (StorageCallbackData, 1); new->storage_set = storage_set; new->storage_set_result_callback = callback; + new->source_path = g_strdup (source_path); + new->destination_path = g_strdup (destination_path); + new->operation = operation; new->data = data; return new; } static void -storage_callback_converter (EStorage *storage, - EStorageResult result, - void *data) +storage_callback_data_free (StorageCallbackData *data) { - StorageCallbackConverterData *converter_data; + g_free (data->source_path); + g_free (data->destination_path); - converter_data = (StorageCallbackConverterData *) data; + g_free (data); +} - (* converter_data->storage_set_result_callback) (converter_data->storage_set, - result, - converter_data->data); +static void +storage_callback (EStorage *storage, + EStorageResult result, + void *data) +{ + StorageCallbackData *storage_callback_data; - g_free (converter_data); + storage_callback_data = (StorageCallbackData *) data; + + (* storage_callback_data->storage_set_result_callback) (storage_callback_data->storage_set, + result, + storage_callback_data->data); + + if (storage_callback_data->operation == OPERATION_MOVE) + gtk_signal_emit (GTK_OBJECT (storage_callback_data->storage_set), + signals[MOVED_FOLDER], + storage_callback_data->source_path, + storage_callback_data->destination_path); + + storage_callback_data_free (storage_callback_data); } @@ -376,6 +409,15 @@ class_init (EStorageSetClass *klass) gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + signals[MOVED_FOLDER] = + gtk_signal_new ("moved_folder", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EStorageSetClass, moved_folder), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, + GTK_TYPE_STRING, + GTK_TYPE_STRING); signals[CLOSE_FOLDER] = gtk_signal_new ("close_folder", GTK_RUN_FIRST, @@ -642,7 +684,7 @@ e_storage_set_async_create_folder (EStorageSet *storage_set, { EStorage *storage; const char *subpath; - StorageCallbackConverterData *converter_data; + StorageCallbackData *storage_callback_data; g_return_if_fail (storage_set != NULL); g_return_if_fail (E_IS_STORAGE_SET (storage_set)); @@ -654,10 +696,12 @@ e_storage_set_async_create_folder (EStorageSet *storage_set, storage = get_storage_for_path (storage_set, path, &subpath); - converter_data = storage_callback_converter_data_new (storage_set, callback, data); + storage_callback_data = storage_callback_data_new (storage_set, callback, + path, NULL, OPERATION_CREATE, + data); e_storage_async_create_folder (storage, subpath, type, description, - storage_callback_converter, converter_data); + storage_callback, storage_callback_data); } void @@ -668,7 +712,7 @@ e_storage_set_async_remove_folder (EStorageSet *storage_set, { EStorage *storage; const char *subpath; - StorageCallbackConverterData *converter_data; + StorageCallbackData *storage_callback_data; g_return_if_fail (storage_set != NULL); g_return_if_fail (E_IS_STORAGE_SET (storage_set)); @@ -678,10 +722,12 @@ e_storage_set_async_remove_folder (EStorageSet *storage_set, storage = get_storage_for_path (storage_set, path, &subpath); - converter_data = storage_callback_converter_data_new (storage_set, callback, data); + storage_callback_data = storage_callback_data_new (storage_set, callback, + path, NULL, OPERATION_REMOVE, + data); e_storage_async_remove_folder (storage, subpath, - storage_callback_converter, converter_data); + storage_callback, storage_callback_data); } void @@ -696,7 +742,7 @@ e_storage_set_async_xfer_folder (EStorageSet *storage_set, EStorage *destination_storage; const char *source_subpath; const char *destination_subpath; - StorageCallbackConverterData *converter_data; + StorageCallbackData *storage_callback_data; g_return_if_fail (storage_set != NULL); g_return_if_fail (E_IS_STORAGE_SET (storage_set)); @@ -716,11 +762,16 @@ e_storage_set_async_xfer_folder (EStorageSet *storage_set, return; } - converter_data = storage_callback_converter_data_new (storage_set, callback, data); + storage_callback_data = storage_callback_data_new (storage_set, + callback, + source_path, + destination_path, + remove_source ? OPERATION_MOVE : OPERATION_COPY, + data); e_storage_async_xfer_folder (source_storage, source_subpath, destination_subpath, remove_source, - storage_callback_converter, converter_data); + storage_callback, storage_callback_data); } |