Changed the EStorageSet API to have a single `xfer()' method instead
of separate copy/move (as in the IDL). Actually implement the `xfer()' operation for the case when source and destination are in the same storage. Fix the `EStorageSet' API by having a special `EStorageSetResultCallback' callback type for it (instead of using `EStorageResultCallback', which would never work). Also, removed some unused variables in `e-storage-set-view.c'. svn path=/trunk/; revision=8895
This commit is contained in:
@ -1,3 +1,32 @@
|
||||
2001-03-22 Ettore Perazzoli <ettore@ximian.com>
|
||||
|
||||
* e-storage-set-view.c: Removed some unused static variables.
|
||||
(set_evolution_path_selection): Removed unused variable
|
||||
`evolution_path'.
|
||||
|
||||
* e-storage-set.c (e_storage_set_async_xfer_folder): Get an
|
||||
`EStorageSetResultCallback', instead of an
|
||||
`EStorageResultCallback'.
|
||||
(e_storage_set_async_remove_folder): Likewise.
|
||||
(e_storage_set_async_create_folder): Likewise.
|
||||
(storage_callback_converter): New callback to convert from the
|
||||
EStorageResultCallback to the EStorageSetResultCallback.
|
||||
|
||||
* e-storage-set.h: New typedef `EStorageSetResultCallback'.
|
||||
|
||||
* Evolution-ShellComponent.idl: Renamed `copyFolderAsync' into
|
||||
`xferFolderAsync' for consistency.
|
||||
|
||||
* e-storage-set-view.c (tree_drag_data_received): Updated to use
|
||||
`e_storage_set_async_xfer_folder()' instead of
|
||||
`e_storage_set_async_move_folder()' or
|
||||
`e_storage_set_async_copy_folder()'.
|
||||
(folder_xfer_callback): New, callback for the xfer function.
|
||||
|
||||
* e-storage-set.c (e_storage_set_async_move_folder): Removed.
|
||||
(e_storage_set_async_copy_folder): Removed.
|
||||
(e_storage_set_async_xfer_folder): New.
|
||||
|
||||
2001-03-22 Ettore Perazzoli <ettore@ximian.com>
|
||||
|
||||
* e-storage.c (e_storage_async_xfer_folder): New.
|
||||
|
||||
@ -60,7 +60,7 @@ module Evolution {
|
||||
in string physical_uri)
|
||||
raises (Busy);
|
||||
|
||||
void copyFolderAsync (in ShellComponentListener listener,
|
||||
void xferFolderAsync (in ShellComponentListener listener,
|
||||
in string source_physical_uri,
|
||||
in string destination_physical_uri,
|
||||
in boolean remove_source)
|
||||
|
||||
@ -130,20 +130,6 @@ typedef enum _DndTargetType DndTargetType;
|
||||
#define URI_LIST_TYPE "text/uri-list"
|
||||
#define E_SHORTCUT_TYPE "E-SHORTCUT"
|
||||
|
||||
static GtkTargetEntry source_drag_types [] = {
|
||||
{ URI_LIST_TYPE, 0, DND_TARGET_TYPE_URI_LIST },
|
||||
{ E_SHORTCUT_TYPE, 0, DND_TARGET_TYPE_E_SHORTCUT }
|
||||
};
|
||||
static const int num_source_drag_types = sizeof (source_drag_types) / sizeof (source_drag_types[0]);
|
||||
|
||||
static GtkTargetEntry destination_drag_types [] = {
|
||||
{ URI_LIST_TYPE, 0, DND_TARGET_TYPE_URI_LIST },
|
||||
{ E_SHORTCUT_TYPE, 0, DND_TARGET_TYPE_E_SHORTCUT }
|
||||
};
|
||||
static const int num_destination_drag_types = sizeof (destination_drag_types) / sizeof (destination_drag_types[0]);
|
||||
|
||||
static GtkTargetList *target_list;
|
||||
|
||||
|
||||
/* Sorting callbacks. */
|
||||
|
||||
@ -613,7 +599,6 @@ set_evolution_path_selection (EStorageSetView *storage_set_view,
|
||||
GtkSelectionData *selection_data)
|
||||
{
|
||||
EStorageSetViewPrivate *priv;
|
||||
const char *evolution_path;
|
||||
|
||||
g_assert (storage_set_view != NULL);
|
||||
g_assert (selection_data != NULL);
|
||||
@ -624,6 +609,17 @@ set_evolution_path_selection (EStorageSetView *storage_set_view,
|
||||
8, (guchar *) priv->selected_row_path, strlen (priv->selected_row_path) + 1);
|
||||
}
|
||||
|
||||
|
||||
/* Callbacks for folder operations. */
|
||||
|
||||
static void
|
||||
folder_xfer_callback (EStorageSet *storage_set,
|
||||
EStorageResult result,
|
||||
void *data)
|
||||
{
|
||||
g_print ("Folder Xfer result -- %s\n", e_storage_result_to_string (result));
|
||||
}
|
||||
|
||||
|
||||
/* Folder context menu. */
|
||||
/* FIXME: This should be moved somewhere else, so that also the shortcut code
|
||||
@ -1188,11 +1184,13 @@ tree_drag_data_received (ETree *etree,
|
||||
switch (context->action) {
|
||||
case GDK_ACTION_MOVE:
|
||||
g_print ("EStorageSetView: Moving from `%s' to `%s'\n", source_path, destination_path);
|
||||
e_storage_set_async_move_folder (priv->storage_set, source_path, destination_path, NULL, NULL);
|
||||
e_storage_set_async_xfer_folder (priv->storage_set, source_path, destination_path, TRUE,
|
||||
folder_xfer_callback, NULL);
|
||||
break;
|
||||
case GDK_ACTION_COPY:
|
||||
g_print ("EStorageSetView: Copying from `%s' to `%s'\n", source_path, destination_path);
|
||||
e_storage_set_async_copy_folder (priv->storage_set, source_path, destination_path, NULL, NULL);
|
||||
e_storage_set_async_xfer_folder (priv->storage_set, source_path, destination_path, FALSE,
|
||||
folder_xfer_callback, NULL);
|
||||
break;
|
||||
default:
|
||||
g_warning ("EStorageSetView: Don't know action %d\n", context->action);
|
||||
|
||||
@ -99,6 +99,48 @@ name_to_named_storage_foreach_destroy (void *key,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* "Callback converter", from `EStorageResultCallback' to
|
||||
`EStorageSetResultCallback'. */
|
||||
|
||||
struct _StorageCallbackConverterData {
|
||||
EStorageSet *storage_set;
|
||||
EStorageSetResultCallback storage_set_result_callback;
|
||||
void *data;
|
||||
};
|
||||
typedef struct _StorageCallbackConverterData StorageCallbackConverterData;
|
||||
|
||||
static StorageCallbackConverterData *
|
||||
storage_callback_converter_data_new (EStorageSet *storage_set,
|
||||
EStorageSetResultCallback callback,
|
||||
void *data)
|
||||
{
|
||||
StorageCallbackConverterData *new;
|
||||
|
||||
new = g_new (StorageCallbackConverterData, 1);
|
||||
new->storage_set = storage_set;
|
||||
new->storage_set_result_callback = callback;
|
||||
new->data = data;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
static void
|
||||
storage_callback_converter (EStorage *storage,
|
||||
EStorageResult result,
|
||||
void *data)
|
||||
{
|
||||
StorageCallbackConverterData *converter_data;
|
||||
|
||||
converter_data = (StorageCallbackConverterData *) data;
|
||||
|
||||
(* converter_data->storage_set_result_callback) (converter_data->storage_set,
|
||||
result,
|
||||
converter_data->data);
|
||||
|
||||
g_free (converter_data);
|
||||
}
|
||||
|
||||
|
||||
/* Handling for signals coming from the EStorages. */
|
||||
|
||||
@ -500,15 +542,16 @@ e_storage_set_new_view (EStorageSet *storage_set)
|
||||
|
||||
|
||||
void
|
||||
e_storage_set_async_create_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
const char *type,
|
||||
const char *description,
|
||||
EStorageResultCallback callback,
|
||||
void *data)
|
||||
e_storage_set_async_create_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
const char *type,
|
||||
const char *description,
|
||||
EStorageSetResultCallback callback,
|
||||
void *data)
|
||||
{
|
||||
EStorage *storage;
|
||||
const char *subpath;
|
||||
StorageCallbackConverterData *converter_data;
|
||||
|
||||
g_return_if_fail (storage_set != NULL);
|
||||
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
|
||||
@ -520,17 +563,21 @@ e_storage_set_async_create_folder (EStorageSet *storage_set,
|
||||
|
||||
storage = get_storage_for_path (storage_set, path, &subpath);
|
||||
|
||||
e_storage_async_create_folder (storage, subpath, type, description, callback, data);
|
||||
converter_data = storage_callback_converter_data_new (storage_set, callback, data);
|
||||
|
||||
e_storage_async_create_folder (storage, subpath, type, description,
|
||||
storage_callback_converter, converter_data);
|
||||
}
|
||||
|
||||
void
|
||||
e_storage_set_async_remove_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
EStorageResultCallback callback,
|
||||
void *data)
|
||||
e_storage_set_async_remove_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
EStorageSetResultCallback callback,
|
||||
void *data)
|
||||
{
|
||||
EStorage *storage;
|
||||
const char *subpath;
|
||||
StorageCallbackConverterData *converter_data;
|
||||
|
||||
g_return_if_fail (storage_set != NULL);
|
||||
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
|
||||
@ -540,7 +587,49 @@ e_storage_set_async_remove_folder (EStorageSet *storage_set,
|
||||
|
||||
storage = get_storage_for_path (storage_set, path, &subpath);
|
||||
|
||||
e_storage_async_remove_folder (storage, path, callback, data);
|
||||
converter_data = storage_callback_converter_data_new (storage_set, callback, data);
|
||||
|
||||
e_storage_async_remove_folder (storage, path,
|
||||
storage_callback_converter, converter_data);
|
||||
}
|
||||
|
||||
void
|
||||
e_storage_set_async_xfer_folder (EStorageSet *storage_set,
|
||||
const char *source_path,
|
||||
const char *destination_path,
|
||||
gboolean remove_source,
|
||||
EStorageSetResultCallback callback,
|
||||
void *data)
|
||||
{
|
||||
EStorage *source_storage;
|
||||
EStorage *destination_storage;
|
||||
const char *source_subpath;
|
||||
const char *destination_subpath;
|
||||
StorageCallbackConverterData *converter_data;
|
||||
|
||||
g_return_if_fail (storage_set != NULL);
|
||||
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
|
||||
g_return_if_fail (source_path != NULL);
|
||||
g_return_if_fail (g_path_is_absolute (source_path));
|
||||
g_return_if_fail (destination_path != NULL);
|
||||
g_return_if_fail (g_path_is_absolute (destination_path));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
source_storage = get_storage_for_path (storage_set, source_path, &source_subpath);
|
||||
destination_storage = get_storage_for_path (storage_set, destination_path, &destination_subpath);
|
||||
|
||||
if (source_storage != destination_storage) {
|
||||
g_warning ("e_storage_set_async_xfer_folder(): "
|
||||
"Attempt to xfer folders between different storages -- not supported yet.");
|
||||
(* callback) (storage_set, E_STORAGE_UNSUPPORTEDOPERATION, data);
|
||||
return;
|
||||
}
|
||||
|
||||
converter_data = storage_callback_converter_data_new (storage_set, callback, data);
|
||||
|
||||
e_storage_async_xfer_folder (source_storage,
|
||||
source_subpath, destination_subpath, remove_source,
|
||||
storage_callback_converter, converter_data);
|
||||
}
|
||||
|
||||
|
||||
@ -601,52 +690,5 @@ e_storage_set_get_path_for_physical_uri (EStorageSet *storage_set,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* e_storage_set_async_copy_folder:
|
||||
* @storage_set:
|
||||
* @source_path:
|
||||
* @destination_path:
|
||||
* @callback:
|
||||
* @data:
|
||||
*
|
||||
* Copy a folder from @source_path to @destination_path.
|
||||
**/
|
||||
void
|
||||
e_storage_set_async_copy_folder (EStorageSet *storage_set,
|
||||
const char *source_path,
|
||||
const char *destination_path,
|
||||
EStorageResultCallback callback,
|
||||
void *data)
|
||||
{
|
||||
g_return_if_fail (storage_set != NULL);
|
||||
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
|
||||
g_return_if_fail (source_path != NULL);
|
||||
g_return_if_fail (destination_path != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* e_storage_set_async_move_folder:
|
||||
* @storage_set:
|
||||
* @source_path:
|
||||
* @destination_path:
|
||||
* @callback:
|
||||
* @data:
|
||||
*
|
||||
* Move a folder from @source_path to @destination_path.
|
||||
**/
|
||||
void
|
||||
e_storage_set_async_move_folder (EStorageSet *storage_set,
|
||||
const char *source_path,
|
||||
const char *destination_path,
|
||||
EStorageResultCallback callback,
|
||||
void *data)
|
||||
{
|
||||
g_return_if_fail (storage_set != NULL);
|
||||
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
|
||||
g_return_if_fail (source_path != NULL);
|
||||
g_return_if_fail (destination_path != NULL);
|
||||
}
|
||||
|
||||
|
||||
E_MAKE_TYPE (e_storage_set, "EStorageSet", EStorageSet, class_init, init, PARENT_TYPE)
|
||||
|
||||
@ -45,6 +45,8 @@ typedef struct _EStorageSet EStorageSet;
|
||||
typedef struct _EStorageSetPrivate EStorageSetPrivate;
|
||||
typedef struct _EStorageSetClass EStorageSetClass;
|
||||
|
||||
typedef void (* EStorageSetResultCallback) (EStorageSet *storage_set, EStorageResult result, void *data);
|
||||
|
||||
struct _EStorageSet {
|
||||
GtkObject parent;
|
||||
|
||||
@ -81,27 +83,22 @@ EFolder *e_storage_set_get_folder (EStorageSet *storage
|
||||
const char *path);
|
||||
GtkWidget *e_storage_set_new_view (EStorageSet *storage_set);
|
||||
|
||||
void e_storage_set_async_create_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
const char *type,
|
||||
const char *description,
|
||||
EStorageResultCallback callback,
|
||||
void *data);
|
||||
void e_storage_set_async_remove_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
EStorageResultCallback callback,
|
||||
void *data);
|
||||
|
||||
void e_storage_set_async_copy_folder (EStorageSet *storage_set,
|
||||
const char *source_path,
|
||||
const char *destination_path,
|
||||
EStorageResultCallback callback,
|
||||
void *data);
|
||||
void e_storage_set_async_move_folder (EStorageSet *storage_set,
|
||||
const char *source_path,
|
||||
const char *destination_path,
|
||||
EStorageResultCallback callback,
|
||||
void *data);
|
||||
void e_storage_set_async_create_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
const char *type,
|
||||
const char *description,
|
||||
EStorageSetResultCallback callback,
|
||||
void *data);
|
||||
void e_storage_set_async_remove_folder (EStorageSet *storage_set,
|
||||
const char *path,
|
||||
EStorageSetResultCallback callback,
|
||||
void *data);
|
||||
void e_storage_set_async_xfer_folder (EStorageSet *storage_set,
|
||||
const char *source_path,
|
||||
const char *destination_path,
|
||||
gboolean remove_source,
|
||||
EStorageSetResultCallback callback,
|
||||
void *data);
|
||||
|
||||
EFolderTypeRegistry *e_storage_set_get_folder_type_registry (EStorageSet *storage_set);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user