[nautilus-actions] Update NAIExporter interface
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Update NAIExporter interface
- Date: Fri, 19 Feb 2010 02:27:36 +0000 (UTC)
commit 641b4a27b2df25a1bf9de48ca5a16da47b936720
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Feb 17 10:32:11 2010 +0100
Update NAIExporter interface
ChangeLog | 5 ++
src/api/na-iexporter.h | 53 +++++++++++++------
src/core/na-iexporter.c | 27 +++++-----
src/io-xml/naxml-module.c | 1 -
src/io-xml/naxml-provider.c | 116 ++++++++++++++++++++++--------------------
5 files changed, 116 insertions(+), 86 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1cf15c8..2f8b0ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-02-17 Pierre Wieser <pwieser trychlos org>
+ * src/api/na-iexporter.h:
+ * src/core/na-iexporter.c:
+ * src/io-xml/naxml-module.c:
+ * src/io-xml/naxml-provider.c: Update NAIExporter interface.
+
Define NAExportFormat new class.
* src/core/na-export-format.c:
diff --git a/src/api/na-iexporter.h b/src/api/na-iexporter.h
index 470c894..39a4f07 100644
--- a/src/api/na-iexporter.h
+++ b/src/api/na-iexporter.h
@@ -54,6 +54,17 @@ typedef struct NAIExporter NAIExporter;
typedef struct NAIExporterInterfacePrivate NAIExporterInterfacePrivate;
+/* When listing available export formats, the instance returns a GList
+ * of these structures
+ */
+typedef struct {
+ gchar *format; /* format identifier (ascii) */
+ gchar *dlg_label; /* label to be displayed in the NactExportAsk dialog (UTF-8 locale) */
+ gchar *wnd_label; /* short label to be displayed in the UI (UTF-8 locale) */
+ gchar *description; /* full description of the format (UTF-8 locale) */
+}
+ NAExporterStr;
+
typedef struct {
GTypeInterface parent;
NAIExporterInterfacePrivate *private;
@@ -66,7 +77,7 @@ typedef struct {
*
* Defaults to 1.
*/
- guint ( *get_version )( const NAIExporter *instance );
+ guint ( *get_version )( const NAIExporter *instance );
/**
* get_formats:
@@ -77,14 +88,18 @@ typedef struct {
*
* Defaults to %NULL (no format at all).
*
- * #NAExporterStr structures addressed in the returned list are
- * owned by the @instance. They must not be released by the caller.
- * Only the list itself should be g_list_free().
+ * The returned list is owned by the @instance. It must not be
+ * released by the caller.
+ *
+ * To avoid any collision, the format id is allocated by the
+ * Nautilus-Actions maintainer team. If you wish develop a new
+ * export format, and so need a new format id, please contact the
+ * maintainers (see #nautilus-actions.doap).
*/
- GList * ( *get_formats )( const NAIExporter *instance );
+ const NAExporterStr * ( *get_formats )( const NAIExporter *instance );
/**
- * export:
+ * to_file:
* @instance: this #NAIExporter instance.
* @item: a #NAObjectItem-derived object.
* @uri: the target directory URI.
@@ -97,22 +112,26 @@ typedef struct {
*
* Returns: the status of the operation.
*/
- guint ( *export ) ( const NAIExporter *instance, const NAObjectItem *item, const gchar *uri, const gchar *format, gchar **fname );
+ guint ( *to_file ) ( const NAIExporter *instance, const NAObjectItem *item, const gchar *uri, const gchar *format, gchar **fname );
+
+ /**
+ * to_buffer:
+ * @instance: this #NAIExporter instance.
+ * @item: a #NAObjectItem-derived object.
+ * @format: the target format.
+ * @buffer: the place where allocate a new buffer to store the output.
+ *
+ * Exports the specified @item to the target @buffer in the required
+ * @format.
+ *
+ * Returns: the status of the operation.
+ */
+ guint ( *to_buffer ) ( const NAIExporter *instance, const NAObjectItem *item, const gchar *format, gchar **buffer );
}
NAIExporterInterface;
GType na_iexporter_get_type( void );
-/* When listing available export formats, the instance returns a GList
- * of these structures
- */
-typedef struct {
- gchar *format; /* format identifier (ascii) */
- gchar *ui_label; /* short label to be displayed in the UI (UTF-8 locale) */
- gchar *ui_description; /* full description of the format (UTF-8 locale) */
-}
- NAExporterStr;
-
/* The reasons for which an item may not have been exported
*/
enum {
diff --git a/src/core/na-iexporter.c b/src/core/na-iexporter.c
index 090a738..36e9f76 100644
--- a/src/core/na-iexporter.c
+++ b/src/core/na-iexporter.c
@@ -40,15 +40,15 @@ struct NAIExporterInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
-static gboolean st_initialized = FALSE;
-static gboolean st_finalized = FALSE;
+gboolean iexporter_initialized = FALSE;
+gboolean iexporter_finalized = FALSE;
-static GType register_type( void );
-static void interface_base_init( NAIExporterInterface *klass );
-static void interface_base_finalize( NAIExporterInterface *klass );
+static GType register_type( void );
+static void interface_base_init( NAIExporterInterface *klass );
+static void interface_base_finalize( NAIExporterInterface *klass );
-static guint iexporter_get_version( const NAIExporter *instance );
-static GList *iexporter_get_formats( const NAIExporter *instance );
+static guint iexporter_get_version( const NAIExporter *instance );
+static const NAExporterStr *iexporter_get_formats( const NAIExporter *instance );
/**
* na_iexporter_get_type:
@@ -104,7 +104,7 @@ interface_base_init( NAIExporterInterface *klass )
{
static const gchar *thisfn = "na_iexporter_interface_base_init";
- if( !st_initialized ){
+ if( !iexporter_initialized ){
g_debug( "%s: klass%p (%s)", thisfn, ( void * ) klass, G_OBJECT_CLASS_NAME( klass ));
@@ -112,9 +112,10 @@ interface_base_init( NAIExporterInterface *klass )
klass->get_version = iexporter_get_version;
klass->get_formats = iexporter_get_formats;
- klass->export = NULL;
+ klass->to_file = NULL;
+ klass->to_buffer = NULL;
- st_initialized = TRUE;
+ iexporter_initialized = TRUE;
}
}
@@ -123,11 +124,11 @@ interface_base_finalize( NAIExporterInterface *klass )
{
static const gchar *thisfn = "na_iexporter_interface_base_finalize";
- if( st_initialized && !st_finalized ){
+ if( iexporter_initialized && !iexporter_finalized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
- st_finalized = TRUE;
+ iexporter_finalized = TRUE;
g_free( klass->private );
}
@@ -139,7 +140,7 @@ iexporter_get_version( const NAIExporter *instance )
return( 1 );
}
-static GList *
+static const NAExporterStr *
iexporter_get_formats( const NAIExporter *instance )
{
return( NULL );
diff --git a/src/io-xml/naxml-module.c b/src/io-xml/naxml-module.c
index 4e4159b..50bbff9 100644
--- a/src/io-xml/naxml-module.c
+++ b/src/io-xml/naxml-module.c
@@ -48,7 +48,6 @@
*
* mandatory starting with API v. 1.
*/
-/* TODO: remove this when we will be ready to release the desktop provider */
gboolean
na_extension_startup( GTypeModule *module )
{
diff --git a/src/io-xml/naxml-provider.c b/src/io-xml/naxml-provider.c
index fbcebf6..8af7c35 100644
--- a/src/io-xml/naxml-provider.c
+++ b/src/io-xml/naxml-provider.c
@@ -35,7 +35,7 @@
#include <glib/gi18n.h>
#include <api/na-iio-factory.h>
-#include <api/na-iio-provider.h>
+#include <api/na-iexporter.h>
#include "naxml-provider.h"
@@ -51,24 +51,58 @@ struct NaxmlProviderPrivate {
gboolean dispose_has_run;
};
+static NAExporterStr st_formats[] = {
+
+ /* GCONF_SCHEMA_V1: a schema with owner, short and long descriptions;
+ * each action has its own schema addressed by the id
+ * (historical format up to v1.10.x serie)
+ */
+ { "GConfSchemaV1",
+ N_( "Export as a full GConf schema (v_1) file" ),
+ N_( "Export as a GConf schema file with full key descriptions" ),
+ N_( "This used to be the historical export format. " \
+ "The exported file may later be imported via :\n" \
+ "- Import assistant of the Nautilus Actions Configuration Tool,\n" \
+ "- or via the gconftool-2 --import-schema-file command-line tool." ) },
+
+ /* GCONF_SCHEMA_V2: the lightest schema still compatible with gconftool-2 --install-schema-file
+ * (no owner, no short nor long descriptions) - introduced in v 1.11
+ */
+ { "GConfSchemaV2",
+ N_( "Export as a light GConf _schema (v2) file" ),
+ N_( "Export as a light GConf schema file" ),
+ N_( "The exported file may later be imported via :\n" \
+ "- Import assistant of the Nautilus Actions Configuration Tool,\n" \
+ "- or via the gconftool-2 --import-schema-file command-line tool." ) },
+
+ /* GCONF_ENTRY: not a schema, but a dump of the GConf entry
+ * introduced in v 1.11
+ */
+ { "GConfEntry",
+ N_( "Export as a GConf _entry file" ),
+ N_( "Export as a GConf entry file" ),
+ N_( "This should be the preferred format for newly exported actions.\n" \
+ "The exported file may later be imported via :\n" \
+ "- Import assistant of the Nautilus Actions Configuration Tool,\n" \
+ "- or via the gconftool-2 --load command-line tool." ) },
+
+ { NULL, NULL, NULL }
+};
+
static GType st_module_type = 0;
static GObjectClass *st_parent_class = NULL;
-static void class_init( NaxmlProviderClass *klass );
-static void instance_init( GTypeInstance *instance, gpointer klass );
-static void instance_dispose( GObject *object );
-static void instance_finalize( GObject *object );
+static void class_init( NaxmlProviderClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_dispose( GObject *object );
+static void instance_finalize( GObject *object );
-static void iio_provider_iface_init( NAIIOProviderInterface *iface );
-static gchar *iio_provider_get_id( const NAIIOProvider *provider );
-static gchar *iio_provider_get_name( const NAIIOProvider *provider );
-static guint iio_provider_get_version( const NAIIOProvider *provider );
-static gboolean iio_provider_is_willing_to_write( const NAIIOProvider *instance );
-static gboolean iio_provider_is_able_to_write( const NAIIOProvider *instance );
-static guint iio_provider_write_item( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages );
+static void iexporter_iface_init( NAIExporterInterface *iface );
+static guint iexporter_get_version( const NAIExporter *provider );
+static const NAExporterStr *iexporter_get_formats( const NAIExporter *instance );
-static void iio_factory_iface_init( NAIIOFactoryInterface *iface );
-static guint iio_factory_get_version( const NAIIOFactory *provider );
+static void iio_factory_iface_init( NAIIOFactoryInterface *iface );
+static guint iio_factory_get_version( const NAIIOFactory *provider );
GType
naxml_provider_get_type( void )
@@ -93,8 +127,8 @@ naxml_provider_register_type( GTypeModule *module )
( GInstanceInitFunc ) instance_init
};
- static const GInterfaceInfo iio_provider_iface_info = {
- ( GInterfaceInitFunc ) iio_provider_iface_init,
+ static const GInterfaceInfo iexporter_iface_info = {
+ ( GInterfaceInitFunc ) iexporter_iface_init,
NULL,
NULL
};
@@ -109,7 +143,7 @@ naxml_provider_register_type( GTypeModule *module )
st_module_type = g_type_module_register_type( module, G_TYPE_OBJECT, "NaxmlProvider", &info, 0 );
- g_type_module_add_interface( module, st_module_type, NA_IIO_PROVIDER_TYPE, &iio_provider_iface_info );
+ g_type_module_add_interface( module, st_module_type, NA_IEXPORTER_TYPE, &iexporter_iface_info );
g_type_module_add_interface( module, st_module_type, NA_IIO_FACTORY_TYPE, &iio_factory_iface_info );
}
@@ -185,56 +219,28 @@ instance_finalize( GObject *object )
}
static void
-iio_provider_iface_init( NAIIOProviderInterface *iface )
+iexporter_iface_init( NAIExporterInterface *iface )
{
- static const gchar *thisfn = "naxml_provider_iio_provider_iface_init";
+ static const gchar *thisfn = "naxml_provider_iexporter_iface_init";
g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
- iface->get_id = iio_provider_get_id;
- iface->get_name = iio_provider_get_name;
- iface->get_version = iio_provider_get_version;
- iface->read_items = NULL;
- iface->is_willing_to_write = iio_provider_is_willing_to_write;
- iface->is_able_to_write = iio_provider_is_able_to_write;
- iface->write_item = iio_provider_write_item;
- iface->delete_item = NULL;
-}
-
-static gchar *
-iio_provider_get_id( const NAIIOProvider *provider )
-{
- return( g_strdup( "na-xml" ));
-}
-
-static gchar *
-iio_provider_get_name( const NAIIOProvider *provider )
-{
- return( g_strdup( _( "Nautilus-Actions XML I/O Provider" )));
+ iface->get_version = iexporter_get_version;
+ iface->get_formats = iexporter_get_formats;
+ iface->to_file = NULL;
+ iface->to_buffer = NULL;
}
static guint
-iio_provider_get_version( const NAIIOProvider *provider )
+iexporter_get_version( const NAIExporter *provider )
{
return( 1 );
}
-static gboolean
-iio_provider_is_willing_to_write( const NAIIOProvider *instance )
-{
- return( TRUE );
-}
-
-static gboolean
-iio_provider_is_able_to_write( const NAIIOProvider *instance )
-{
- return( TRUE );
-}
-
-static guint
-iio_provider_write_item( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages )
+static const NAExporterStr *
+iexporter_get_formats( const NAIExporter *instance )
{
- return( NA_IIO_PROVIDER_CODE_OK );
+ return( st_formats );
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]