[nautilus-actions] Define new duplicate_data NAIIProvider interface
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define new duplicate_data NAIIProvider interface
- Date: Fri, 18 Jun 2010 08:59:44 +0000 (UTC)
commit 9fe6ec507ca753ae43f71cf5e7f9acb6cd3aaad8
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jun 18 10:57:48 2010 +0200
Define new duplicate_data NAIIProvider interface
ChangeLog | 8 ++++++++
src/api/na-iio-provider.h | 15 +++++++++++++++
src/core/na-iio-provider.c | 1 +
src/core/na-io-provider.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/core/na-io-provider.h | 5 +++--
src/io-desktop/nadp-writer.c | 1 +
6 files changed, 70 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0c3b99b..dcc48bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-18 Pierre Wieser <pwieser trychlos org>
+
+ * src/api/na-iio-provider.h:
+ * src/core/na-iio-provider.c (duplicate_data):
+ * src/core/na-io-provider.c:
+ * src/core/na-io-provider.h (na_io_provider_duplicate_data):
+ Define new NAIIOProvider interface.
+
2010-06-17 Pierre Wieser <pwieser trychlos org>
* src/api/na-iio-provider.h:
diff --git a/src/api/na-iio-provider.h b/src/api/na-iio-provider.h
index e3107ad..52d0be6 100644
--- a/src/api/na-iio-provider.h
+++ b/src/api/na-iio-provider.h
@@ -193,6 +193,21 @@ typedef struct {
* successfull, or another code depending of the detected error.
*/
guint ( *delete_item ) ( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages );
+
+ /**
+ * duplicate_data:
+ * @instance: the #NAIIOProvider provider.
+ * @dest: a #NAObjectItem-derived item, menu or action.
+ * @source: a #NAObjectItem-derived item, menu or action.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
+ *
+ * Duplicates provider data (if any) from @source to @dest.
+ *
+ * Returns: %NA_IIO_PROVIDER_CODE_OK if the duplicate operation was
+ * successfull, or another code depending of the detected error.
+ */
+ guint ( *duplicate_data ) ( const NAIIOProvider *instance, NAObjectItem *dest, const NAObjectItem *source, GSList **messages );
}
NAIIOProviderInterface;
diff --git a/src/core/na-iio-provider.c b/src/core/na-iio-provider.c
index 3567f09..8d6be7f 100644
--- a/src/core/na-iio-provider.c
+++ b/src/core/na-iio-provider.c
@@ -125,6 +125,7 @@ interface_base_init( NAIIOProviderInterface *klass )
klass->is_able_to_write = do_is_able_to_write;
klass->write_item = NULL;
klass->delete_item = NULL;
+ klass->duplicate_data = NULL;
/* register the signal (without any default handler)
* this signal should be sent by the #NAIIOProvider instance when
diff --git a/src/core/na-io-provider.c b/src/core/na-io-provider.c
index d7e68da..5702c96 100644
--- a/src/core/na-io-provider.c
+++ b/src/core/na-io-provider.c
@@ -1235,6 +1235,48 @@ na_io_provider_delete_item( const NAIOProvider *provider, const NAObjectItem *it
}
/**
+ * na_io_provider_duplicate_data:
+ * @provider: this #NAIOProvider object.
+ * @dest: the target #NAObjectItem item.
+ * @source: the source #NAObjectItem item.
+ * @messages: error messages.
+ *
+ * Duplicates provider data (if any) from @source to @dest.
+ *
+ * Returns: the NAIIOProvider return code.
+ */
+guint
+na_io_provider_duplicate_data( const NAIOProvider *provider, NAObjectItem *dest, const NAObjectItem *source, GSList **messages )
+{
+ static const gchar *thisfn = "na_io_provider_duplicate_data";
+ guint ret;
+ void *provider_data;
+
+ g_debug( "%s: provider=%p (%s), dest=%p (%s), source=%p (%s), messages=%p", thisfn,
+ ( void * ) provider, G_OBJECT_TYPE_NAME( provider ),
+ ( void * ) dest, G_OBJECT_TYPE_NAME( dest ),
+ ( void * ) source, G_OBJECT_TYPE_NAME( source ),
+ ( void * ) messages );
+
+ ret = NA_IIO_PROVIDER_CODE_PROGRAM_ERROR;
+
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), ret );
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( dest ), ret );
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( source ), ret );
+ g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider->private->provider ), ret );
+
+ na_object_set_provider_data( dest, NULL );
+ provider_data = na_object_get_provider_data( source );
+
+ if( provider_data &&
+ NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->duplicate_data ){
+ ret = NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->duplicate_data( provider->private->provider, dest, source, messages );
+ }
+
+ return( ret );
+}
+
+/**
* na_io_provider_get_readonly_tooltip:
* @reason: the reason for why an item is not writable.
*
diff --git a/src/core/na-io-provider.h b/src/core/na-io-provider.h
index 8f3f50c..2f8fb39 100644
--- a/src/core/na-io-provider.h
+++ b/src/core/na-io-provider.h
@@ -98,8 +98,9 @@ gboolean na_io_provider_is_willing_to_write ( const NAIOProvider *p
gboolean na_io_provider_is_able_to_write ( const NAIOProvider *provider );
gboolean na_io_provider_has_write_api ( const NAIOProvider *provider );
-guint na_io_provider_write_item ( const NAIOProvider *provider, const NAObjectItem *item, GSList **messages );
-guint na_io_provider_delete_item( const NAIOProvider *provider, const NAObjectItem *item, GSList **messages );
+guint na_io_provider_write_item ( const NAIOProvider *provider, const NAObjectItem *item, GSList **messages );
+guint na_io_provider_delete_item ( const NAIOProvider *provider, const NAObjectItem *item, GSList **messages );
+guint na_io_provider_duplicate_data( const NAIOProvider *provider, NAObjectItem *dest, const NAObjectItem *source, GSList **messages );
gchar *na_io_provider_get_readonly_tooltip( guint reason );
gchar *na_io_provider_get_return_code_label( guint code );
diff --git a/src/io-desktop/nadp-writer.c b/src/io-desktop/nadp-writer.c
index a33d46f..4b1b03e 100644
--- a/src/io-desktop/nadp-writer.c
+++ b/src/io-desktop/nadp-writer.c
@@ -133,6 +133,7 @@ nadp_iio_provider_write_item( const NAIIOProvider *provider, const NAObjectItem
subdirs = na_core_utils_slist_from_split( NADP_DESKTOP_PROVIDER_SUBDIRS, G_SEARCHPATH_SEPARATOR_S );
fulldir = g_build_filename( userdir, ( gchar * ) subdirs->data, NULL );
dir_ok = TRUE;
+
if( !g_file_test( fulldir, G_FILE_TEST_IS_DIR )){
if( g_mkdir_with_parents( fulldir, 0700 )){
g_warning( "%s: %s: %s", thisfn, userdir, g_strerror( errno ));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]