[nautilus-actions] Add read_start() and write_start() to NAIIOFactory and NAIDataFactory interfaces
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Add read_start() and write_start() to NAIIOFactory and NAIDataFactory interfaces
- Date: Fri, 19 Feb 2010 02:30:03 +0000 (UTC)
commit c1c5f7ef0c12250753d56a19714cf6ac53f43906
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Feb 17 22:58:03 2010 +0100
Add read_start() and write_start() to NAIIOFactory and NAIDataFactory interfaces
ChangeLog | 13 +++++++++++++
src/api/na-idata-factory.h | 24 ++++++++++++++++++++++++
src/api/na-iio-factory.h | 27 +++++++++++++++++++++++++--
src/core/na-data-factory.c | 20 ++++++++++++++++++++
src/core/na-iio-factory.c | 20 ++++++++++++++++++++
src/core/na-object-action.c | 2 ++
src/core/na-object-menu.c | 2 ++
src/core/na-object-profile.c | 2 ++
src/io-desktop/nadp-desktop-provider.c | 32 ++++++++++++++++++++++++++++++--
src/io-gconf/nagp-gconf-provider.c | 6 ++++++
src/io-xml/naxml-provider.c | 6 ++++++
11 files changed, 150 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5d4c7f5..087fd9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2009-02-17 Pierre Wieser <pwieser trychlos org>
+ * src/api/na-idata-factory.h:
+ * src/api/na-iio-factory.h:
+ * src/core/na-data-factory.c:
+ * src/core/na-iio-factory.c:
+ * src/core/na-object-action.c:
+ * src/core/na-object-menu.c:
+ * src/core/na-object-profile.c:
+ * src/io-desktop/nadp-desktop-provider.c:
+ * src/io-gconf/nagp-gconf-provider.c:
+ * src/io-xml/naxml-provider.c:
+ Add read_start() and write_start() to NAIIOFactory and
+ NAIDataFactory interfaces.
+
* po/POTFILES.in: Update list of translatable files.
* src/utils/console-utils.c:
diff --git a/src/api/na-idata-factory.h b/src/api/na-idata-factory.h
index 85340e6..57fb72a 100644
--- a/src/api/na-idata-factory.h
+++ b/src/api/na-idata-factory.h
@@ -115,6 +115,18 @@ typedef struct {
gboolean ( *are_equal ) ( const NAIDataFactory *a, const NAIDataFactory *b );
/**
+ * read_start:
+ * @instance: this #NAIDataFactory instance.
+ * @reader: the instance which has provided read services.
+ * @reader_data: the data associated to @reader.
+ * @messages: a pointer to a #GSList list of strings; the instance
+ * may append messages to this list, but shouldn't reinitialize it.
+ *
+ * Called just before the object is unserialized.
+ */
+ void ( *read_start ) ( NAIDataFactory *instance, const NAIIOFactory *reader, void *reader_data, GSList **messages );
+
+ /**
* read_done:
* @instance: this #NAIDataFactory instance.
* @reader: the instance which has provided read services.
@@ -127,6 +139,18 @@ typedef struct {
void ( *read_done ) ( NAIDataFactory *instance, const NAIIOFactory *reader, void *reader_data, GSList **messages );
/**
+ * write_start:
+ * @instance: this #NAIDataFactory instance.
+ * @writer: the instance which has provided writing services.
+ * @writer_data: the data associated to @writer.
+ * @messages: a pointer to a #GSList list of strings; the instance
+ * may append messages to this list, but shouldn't reinitialize it.
+ *
+ * Called just before the object is serialized.
+ */
+ void ( *write_start )( NAIDataFactory *instance, const NAIIOFactory *writer, void *writer_data, GSList **messages );
+
+ /**
* write_done:
* @instance: this #NAIDataFactory instance.
* @writer: the instance which has provided writing services.
diff --git a/src/api/na-iio-factory.h b/src/api/na-iio-factory.h
index 2dfbaf7..861c504 100644
--- a/src/api/na-iio-factory.h
+++ b/src/api/na-iio-factory.h
@@ -71,6 +71,18 @@ typedef struct {
guint ( *get_version )( const NAIIOFactory *instance );
/**
+ * read_start:
+ * @reader: this #NAIIOFactory instance.
+ * @reader_data: the data associated to this instance.
+ * @object: the #NAIDataFactory object which comes to be readen.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
+ *
+ * API called by #NAIDataFactory just before starting with reading data.
+ */
+ void ( *read_start ) ( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *object, GSList **messages );
+
+ /**
* read_value:
* @reader: this #NAIIOFactory instance.
* @reader_data: the data associated to this instance.
@@ -104,6 +116,18 @@ typedef struct {
void ( *read_done ) ( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *object, GSList **messages );
/**
+ * write_start:
+ * @writer: this #NAIIOFactory instance.
+ * @writer_data: the data associated to this instance.
+ * @object: the #NAIDataFactory object which comes to be written.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
+ *
+ * API called by #NAIDataFactory just before starting with writing data.
+ */
+ void ( *write_start )( const NAIIOFactory *writer, void *writer_data, NAIDataFactory *object, GSList **messages );
+
+ /**
* write_value:
* @writer: this #NAIIOFactory instance.
* @writer_data: the data associated to this instance.
@@ -135,8 +159,7 @@ typedef struct {
GType na_iio_factory_get_type( void );
-NAIDataFactory *na_iio_factory_read_item ( const NAIIOFactory *reader, void *reader_data, GType type, GSList **messages );
-
+NAIDataFactory *na_iio_factory_read_item ( const NAIIOFactory *reader, void *reader_data, GType type, GSList **messages );
void na_iio_factory_write_item( const NAIIOFactory *writer, void *writer_data, NAIDataFactory *serializable, GSList **messages );
G_END_DECLS
diff --git a/src/core/na-data-factory.c b/src/core/na-data-factory.c
index b9375b2..c72d553 100644
--- a/src/core/na-data-factory.c
+++ b/src/core/na-data-factory.c
@@ -82,9 +82,11 @@ static void v_copy( NAIDataFactory *target, const NAIDataFactory *sour
static gboolean v_are_equal( const NAIDataFactory *a, const NAIDataFactory *b );
static void data_factory_read_data( NAIDataFactory *serializable, const NAIIOFactory *reader, void *reader_data, NadfIdGroup *groups, GSList **messages );
static gboolean data_factory_read_data_iter( NadfIdType *iddef, NadfRWIter *iter );
+static void v_read_start( NAIDataFactory *serializable, const NAIIOFactory *reader, void *reader_data, GSList **messages );
static void v_read_done( NAIDataFactory *serializable, const NAIIOFactory *reader, void *reader_data, GSList **messages );
static void data_factory_write_data( NAIDataFactory *serializable, const NAIIOFactory *writer, void *writer_data, NadfIdGroup *groups, GSList **messages );
static gboolean data_factory_write_data_iter( NadfIdType *iddef, NadfRWIter *iter );
+static void v_write_start( NAIDataFactory *serializable, const NAIIOFactory *reader, void *reader_data, GSList **messages );
static void v_write_done( NAIDataFactory *serializable, const NAIIOFactory *reader, void *reader_data, GSList **messages );
static NADataElement *data_element_from_id( const NAIDataFactory *object, guint data_id );
static void iter_on_id_groups( const NadfIdGroup *idgroups, gboolean serializable_only, IdGroupIterFunc pfn, void *user_data );
@@ -428,6 +430,7 @@ na_data_factory_read( NAIDataFactory *serializable, const NAIIOFactory *reader,
groups = na_io_factory_get_groups( G_OBJECT_TYPE( serializable ));
if( groups ){
+ v_read_start( serializable, reader, reader_data, messages );
data_factory_read_data( serializable, reader, reader_data, groups, messages );
v_read_done( serializable, reader, reader_data, messages );
@@ -492,6 +495,14 @@ data_factory_read_data_iter( NadfIdType *iddef, NadfRWIter *iter )
}
static void
+v_read_start( NAIDataFactory *serializable, const NAIIOFactory *reader, void *reader_data, GSList **messages )
+{
+ if( NA_IDATA_FACTORY_GET_INTERFACE( serializable )->read_start ){
+ NA_IDATA_FACTORY_GET_INTERFACE( serializable )->read_start( serializable, reader, reader_data, messages );
+ }
+}
+
+static void
v_read_done( NAIDataFactory *serializable, const NAIIOFactory *reader, void *reader_data, GSList **messages )
{
if( NA_IDATA_FACTORY_GET_INTERFACE( serializable )->read_done ){
@@ -522,6 +533,7 @@ na_data_factory_write( NAIDataFactory *serializable, const NAIIOFactory *writer,
groups = na_io_factory_get_groups( G_OBJECT_TYPE( serializable ));
if( groups ){
+ v_write_start( serializable, writer, writer_data, messages );
data_factory_write_data( serializable, writer, writer_data, groups, messages );
v_write_done( serializable, writer, writer_data, messages );
@@ -573,6 +585,14 @@ data_factory_write_data_iter( NadfIdType *iddef, NadfRWIter *iter )
}
static void
+v_write_start( NAIDataFactory *serializable, const NAIIOFactory *writer, void *writer_data, GSList **messages )
+{
+ if( NA_IDATA_FACTORY_GET_INTERFACE( serializable )->write_start ){
+ NA_IDATA_FACTORY_GET_INTERFACE( serializable )->write_start( serializable, writer, writer_data, messages );
+ }
+}
+
+static void
v_write_done( NAIDataFactory *serializable, const NAIIOFactory *writer, void *writer_data, GSList **messages )
{
if( NA_IDATA_FACTORY_GET_INTERFACE( serializable )->write_done ){
diff --git a/src/core/na-iio-factory.c b/src/core/na-iio-factory.c
index aa9cc0b..8589b51 100644
--- a/src/core/na-iio-factory.c
+++ b/src/core/na-iio-factory.c
@@ -48,7 +48,9 @@ static void interface_base_finalize( NAIIOFactoryInterface *klass );
static guint iio_factory_get_version( const NAIIOFactory *instance );
+static void v_io_factory_read_start( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages );
static void v_io_factory_read_done( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages );
+static void v_io_factory_write_start( const NAIIOFactory *writer, void *writer_data, NAIDataFactory *serializable, GSList **messages );
static void v_io_factory_write_done( const NAIIOFactory *writer, void *writer_data, NAIDataFactory *serializable, GSList **messages );
/**
@@ -170,6 +172,7 @@ na_iio_factory_read_item( const NAIIOFactory *reader, void *reader_data, GType t
serializable = na_data_factory_new( type );
if( serializable ){
+ v_io_factory_read_start( reader, reader_data, serializable, messages );
na_data_factory_read( serializable, reader, reader_data, messages );
v_io_factory_read_done( reader, reader_data, serializable, messages );
@@ -201,12 +204,21 @@ na_iio_factory_write_item( const NAIIOFactory *writer, void *writer_data, NAIDat
if( iio_factory_initialized && !iio_factory_finalized ){
+ v_io_factory_write_start( writer, writer_data, serializable, messages );
na_data_factory_write( serializable, writer, writer_data, messages );
v_io_factory_write_done( writer, writer_data, serializable, messages );
}
}
static void
+v_io_factory_read_start( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages )
+{
+ if( NA_IIO_FACTORY_GET_INTERFACE( reader )->read_start ){
+ NA_IIO_FACTORY_GET_INTERFACE( reader )->read_start( reader, reader_data, serializable, messages );
+ }
+}
+
+static void
v_io_factory_read_done( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages )
{
if( NA_IIO_FACTORY_GET_INTERFACE( reader )->read_done ){
@@ -215,6 +227,14 @@ v_io_factory_read_done( const NAIIOFactory *reader, void *reader_data, NAIDataFa
}
static void
+v_io_factory_write_start( const NAIIOFactory *writer, void *writer_data, NAIDataFactory *serializable, GSList **messages )
+{
+ if( NA_IIO_FACTORY_GET_INTERFACE( writer )->write_start ){
+ NA_IIO_FACTORY_GET_INTERFACE( writer )->write_start( writer, writer_data, serializable, messages );
+ }
+}
+
+static void
v_io_factory_write_done( const NAIIOFactory *writer, void *writer_data, NAIDataFactory *serializable, GSList **messages )
{
if( NA_IIO_FACTORY_GET_INTERFACE( writer )->write_done ){
diff --git a/src/core/na-object-action.c b/src/core/na-object-action.c
index 96c1ba8..5a90438 100644
--- a/src/core/na-object-action.c
+++ b/src/core/na-object-action.c
@@ -248,7 +248,9 @@ idata_factory_iface_init( NAIDataFactoryInterface *iface )
iface->get_default = idata_factory_get_default;
iface->copy = idata_factory_copy;
iface->are_equal = idata_factory_are_equal;
+ iface->read_start = NULL;
iface->read_done = idata_factory_read_done;
+ iface->write_start = NULL;
iface->write_done = idata_factory_write_done;
}
diff --git a/src/core/na-object-menu.c b/src/core/na-object-menu.c
index 3ea4845..5306795 100644
--- a/src/core/na-object-menu.c
+++ b/src/core/na-object-menu.c
@@ -249,7 +249,9 @@ idata_factory_iface_init( NAIDataFactoryInterface *iface )
iface->get_default = idata_factory_get_default;
iface->copy = idata_factory_copy;
iface->are_equal = idata_factory_are_equal;
+ iface->read_start = NULL;
iface->read_done = idata_factory_read_done;
+ iface->write_start = NULL;
iface->write_done = idata_factory_write_done;
}
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index 6c1a8d4..75ddcd9 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -277,7 +277,9 @@ idata_factory_iface_init( NAIDataFactoryInterface *iface )
iface->get_default = idata_factory_get_default;
iface->copy = NULL;
iface->are_equal = NULL;
+ iface->read_start = NULL;
iface->read_done = idata_factory_read_done;
+ iface->write_start = NULL;
iface->write_done = idata_factory_write_done;
}
diff --git a/src/io-desktop/nadp-desktop-provider.c b/src/io-desktop/nadp-desktop-provider.c
index 47c3809..9f3a173 100644
--- a/src/io-desktop/nadp-desktop-provider.c
+++ b/src/io-desktop/nadp-desktop-provider.c
@@ -65,6 +65,7 @@ static guint iio_provider_get_version( const NAIIOProvider *provider );
static void iio_factory_iface_init( NAIIOFactoryInterface *iface );
static guint iio_factory_get_version( const NAIIOFactory *reader );
+static void iio_factory_read_start( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages );
static GValue *iio_factory_read_value( const NAIIOFactory *reader, void *reader_data, const NadfIdType *iddef, GSList **messages );
static void iio_factory_read_done( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages );
@@ -225,10 +226,12 @@ iio_factory_iface_init( NAIIOFactoryInterface *iface )
g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
iface->get_version = iio_factory_get_version;
+ iface->read_start = iio_factory_read_start;
iface->read_value = iio_factory_read_value;
iface->read_done = iio_factory_read_done;
- /*iface->write_value = iio_factory_write_value;
- iface->write_done = iio_factory_write_done;*/
+ iface->write_start = NULL;
+ iface->write_value = NULL;
+ iface->write_done = NULL;
}
static guint
@@ -238,6 +241,31 @@ iio_factory_get_version( const NAIIOFactory *reader )
}
/*
+ * called before starting with reading an object
+ */
+static void
+iio_factory_read_start( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages )
+{
+ static const gchar *thisfn = "nadp_desktop_provider_iio_factory_read_start";
+ /*NAObjectProfile *profile;*/
+
+ g_debug( "%s: reader=%p (%s), reader_data=%p, serializable=%p (%s), messages=%p",
+ thisfn,
+ ( void * ) reader, G_OBJECT_TYPE_NAME( reader ),
+ ( void * ) reader_data,
+ ( void * ) serializable, G_OBJECT_TYPE_NAME( serializable ),
+ ( void * ) messages );
+
+ g_return_if_fail( NA_IS_IIO_FACTORY( reader ));
+ g_return_if_fail( NADP_IS_DESKTOP_PROVIDER( reader ));
+ g_return_if_fail( NA_IS_IDATA_FACTORY( serializable ));
+
+ if( !NADP_DESKTOP_PROVIDER( reader )->private->dispose_has_run ){
+
+ }
+}
+
+/*
* reading any data from a desktop file requires:
* - a NadpDesktopFile object which has been initialized with the .desktop file
* -> has been attached to the NAObjectItem in get_item() above
diff --git a/src/io-gconf/nagp-gconf-provider.c b/src/io-gconf/nagp-gconf-provider.c
index 6ab1d5e..5a0d35e 100644
--- a/src/io-gconf/nagp-gconf-provider.c
+++ b/src/io-gconf/nagp-gconf-provider.c
@@ -241,6 +241,12 @@ iio_factory_iface_init( NAIIOFactoryInterface *iface )
g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
iface->get_version = iio_factory_get_version;
+ iface->read_start = NULL;
+ iface->read_value = NULL;
+ iface->read_done = NULL;
+ iface->write_start = NULL;
+ iface->write_value = NULL;
+ iface->write_done = NULL;
}
static guint
diff --git a/src/io-xml/naxml-provider.c b/src/io-xml/naxml-provider.c
index 8af7c35..0c2eb54 100644
--- a/src/io-xml/naxml-provider.c
+++ b/src/io-xml/naxml-provider.c
@@ -251,6 +251,12 @@ iio_factory_iface_init( NAIIOFactoryInterface *iface )
g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
iface->get_version = iio_factory_get_version;
+ iface->read_start = NULL;
+ iface->read_value = NULL;
+ iface->read_done = NULL;
+ iface->write_start = NULL;
+ iface->write_value = NULL;
+ iface->write_done = NULL;
}
static guint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]