Commit d30f3f82 authored by Pierre Wieser's avatar Pierre Wieser

Implement NAXMLReader

parent 01a1d03c
2009-02-20 Pierre Wieser <pwieser@trychlos.org>
* po/POTFILES.in:
* src/api/na-idata-factory-str.h:
* src/api/na-idata-factory.h:
* src/api/na-iimporter.h:
* src/api/na-iio-factory.h:
* src/api/na-object-api.h:
* src/core/Makefile.am:
* src/core/na-data-factory.c:
* src/core/na-data-factory.h:
* src/core/na-idata-factory.c:
* src/core/na-iio-factory.c:
* src/core/na-importer.c:
* src/core/na-importer.h:
* src/core/na-io-factory.c:
* src/core/na-io-factory.h:
* src/core/na-iprefs.h:
* src/core/na-module.c:
* src/core/na-object-action-enum.c:
* src/core/na-object-action.c:
* src/core/na-object-id-enum.c:
* src/core/na-object-item-enum.c:
* src/core/na-object-item.c:
* src/core/na-object-menu-enum.c:
* src/core/na-object-menu.c:
* src/core/na-object-profile-enum.c:
* src/core/na-object-profile.c:
* src/core/na-pivot.c:
* src/io-desktop/Makefile.am:
* src/io-gconf/Makefile.am:
* src/io-xml/Makefile.am:
* src/io-xml/naxml-keys.c:
* src/io-xml/naxml-keys.h:
* src/io-xml/naxml-provider.c:
* src/io-xml/naxml-provider.h:
* src/io-xml/naxml-reader.c:
* src/io-xml/naxml-reader.h:
* src/nact/Makefile.am:
* src/nact/nact-assistant-import.c:
* src/nact/nact-import-ask.c:
* src/nact/nact-iprefs.c:
* src/nact/nact-preferences-editor.c:
* src/nact/nact-tree-model-dnd.c:
* src/plugin-menu/Makefile.am:
* src/plugin-tracker/Makefile.am:
* src/test/.gitignore:
* src/test/Makefile.am:
* src/utils/Makefile.am: Implement NAXMLReader.
2009-02-18 Pierre Wieser <pwieser@trychlos.org>
* src/api/na-core-utils.h:
......
......@@ -7,8 +7,8 @@ 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/nact-xml-reader.c
src/io-xml/na-xml-names.h
src/io-xml/naxml-keys.h
src/io-xml/naxml-reader.c
src/io-xml/naxml-provider.c
src/nact/base-application.c
src/nact/base-assistant.c
......
......@@ -71,43 +71,56 @@ enum {
NADF_TYPE_UINT, /* an unsigned integer */
};
/* attach here a xml document root with the corresponding node for the data
*/
typedef struct {
gchar *doc_id;
gchar *key;
}
NadfDocKey;
/**
* The structure which fully describe an elementary data
* Each #NAIDataFactory item definition may include several groups of
* this structure
*/
typedef struct {
guint id; /* the id of the object data item
guint id; /* the id of the object data item
* must only be unique inside of the given group */
gchar *name; /* canonical name, used when getting/setting properties */
gchar *name; /* canonical name, used when getting/setting properties */
gboolean serializable; /* whether the data is serializable
gboolean serializable; /* whether the data is serializable
* if FALSE, then no attempt will be made to read/write it
* and the data will must be set dynamically */
gchar *short_label; /* short descriptive name, used in GParamSpec */
gchar *short_label; /* short descriptive name, used in GParamSpec */
gchar *long_label; /* long, if not complete, description, used in GParamSpec */
gchar *long_label; /* long, if not complete, description, used in GParamSpec */
guint type; /* the elementary NADF_TYPE_xxx data type */
guint type; /* the elementary NADF_TYPE_xxx data type */
gchar *default_value; /* the default to assign when creating a new object
gchar *default_value; /* the default to assign when creating a new object
* this default is also displayed in command-line help
* of nautilus-actions-new utility */
gboolean copyable; /* whether this data should be automatically copied when
gboolean copyable; /* whether this data should be automatically copied when
* we are duplicating an object to another
* in all cases, the implementation is always triggered
* by the copy() interface method */
gboolean comparable; /* whether this data should be compared when we
gboolean comparable; /* whether this data should be compared when we
* are testing two objects for equality */
gboolean mandatory; /* whether this data must be not null and not empty
gboolean mandatory; /* whether this data must be not null and not empty
* when we are testing for validity of an object */
void ( *free )( void * ); /* a pointer to a function to free the element data
gboolean localizable; /* whether this is a localizable data
* when serializing or exporting */
gchar *gconf_entry; /* same entry is also used for GConf-based XML docs */
void ( *free )( void * ); /* a pointer to a function to free the element data
* a default function is provided for main elementary
* data types:
* - STRING and LOCALE_STRING: g_free
......
......@@ -175,11 +175,12 @@ typedef struct {
}
NAIDataFactoryInterface;
GType na_idata_factory_get_type( void );
GType na_idata_factory_get_type( void );
void *na_idata_factory_get( const NAIDataFactory *object, guint data_id );
void *na_idata_factory_get( const NAIDataFactory *object, guint data_id );
void na_idata_factory_set( NAIDataFactory *object, guint data_id, const void *data );
void na_idata_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *data );
void na_idata_factory_set_from_void ( NAIDataFactory *object, guint data_id, const void *data );
G_END_DECLS
......
......@@ -54,6 +54,8 @@ typedef struct NAIImporter NAIImporter;
typedef struct NAIImporterInterfacePrivate NAIImporterInterfacePrivate;
typedef gboolean ( *ImporterCheckFn )( const gchar *, void *fn_data );
typedef struct {
GTypeInterface parent;
NAIImporterInterfacePrivate *private;
......@@ -67,9 +69,36 @@ typedef struct {
* Defaults to 1.
*/
guint ( *get_version )( const NAIImporter *instance );
/**
* import_uri:
* @instance: the #NAIImporter provider.
* @uri: the URI of the file to be imported.
* @mode: import mode.
* @fn: a pointer to the function to be used to check for existancy of
* imported id.
* @fn_data: data to be passed to @fn.
* @messages: a pointer to a #GSList list of strings; the provider
* may append messages to this list, but shouldn't reinitialize it.
*
* Imports an item.
*
* Returns: a #NAObjectItem-derived object, or %NULL if an error has
* been detected.
*/
NAObjectItem * ( *import_uri ) ( const NAIImporter *instance, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages );
}
NAIImporterInterface;
/* import mode
*/
enum {
IMPORTER_MODE_NO_IMPORT = 1, /* this is a "do not import anything" mode */
IMPORTER_MODE_RENUMBER,
IMPORTER_MODE_OVERRIDE,
IMPORTER_MODE_ASK
};
GType na_iimporter_get_type( void );
G_END_DECLS
......
......@@ -162,6 +162,8 @@ GType na_iio_factory_get_type( void );
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 );
NadfIdType *na_iio_factory_get_idtype_from_gconf_key( const gchar *xml_entry );
G_END_DECLS
#endif /* __NAUTILUS_ACTIONS_API_NA_IIO_FACTORY_H__ */
......@@ -81,9 +81,9 @@ G_BEGIN_DECLS
#define na_object_get_label( obj ) (( gchar * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_LABEL ))
#define na_object_get_parent( obj ) (( NAObjectItem * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_PARENT ))
#define na_object_set_id( obj, id ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ID, ( const void * )( id ))
#define na_object_set_label( obj, label ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_LABEL, ( const void * )( label ))
#define na_object_set_parent( obj, parent ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PARENT, ( const void * )( parent ))
#define na_object_set_id( obj, id ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ID, ( const void * )( id ))
#define na_object_set_label( obj, label ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_LABEL, ( const void * )( label ))
#define na_object_set_parent( obj, parent ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PARENT, ( const void * )( parent ))
#define na_object_sort_alpha_asc( a, b ) na_object_id_sort_alpha_asc( NA_OBJECT_ID( a ), NA_OBJECT_ID( b ))
#define na_object_sort_alpha_desc( a, b ) na_object_id_sort_alpha_desc( NA_OBJECT_ID( a ), NA_OBJECT_ID( b ))
......@@ -104,14 +104,14 @@ G_BEGIN_DECLS
#define na_object_get_provider( obj ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER )
#define na_object_get_provider_data( obj ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER_DATA )
#define na_object_set_tooltip( obj, tooltip ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLTIP, ( const void * )( tooltip ))
#define na_object_set_icon( obj, icon ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ICON, ( const void * )( icon ))
#define na_object_set_items( obj, list ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS, ( const void * )( list ))
#define na_object_set_items_slist( obj, slist ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS_SLIST, ( const void * )( slist ))
#define na_object_set_enabled( obj, enabled ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ENABLED, ( const void * ) GUINT_TO_POINTER( enabled ))
#define na_object_set_readonly( obj, readonly ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_READONLY, ( const void * ) GUINT_TO_POINTER( readonly ))
#define na_object_set_provider( obj, provider ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER, ( const void * )( provider ))
#define na_object_set_provider_data( obj, data ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER_DATA, ( const void * )( data ))
#define na_object_set_tooltip( obj, tooltip ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLTIP, ( const void * )( tooltip ))
#define na_object_set_icon( obj, icon ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ICON, ( const void * )( icon ))
#define na_object_set_items( obj, list ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS, ( const void * )( list ))
#define na_object_set_items_slist( obj, slist ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_SUBITEMS_SLIST, ( const void * )( slist ))
#define na_object_set_enabled( obj, enabled ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ENABLED, ( const void * ) GUINT_TO_POINTER( enabled ))
#define na_object_set_readonly( obj, readonly ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_READONLY, ( const void * ) GUINT_TO_POINTER( readonly ))
#define na_object_set_provider( obj, provider ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER, ( const void * )( provider ))
#define na_object_set_provider_data( obj, data ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PROVIDER_DATA, ( const void * )( data ))
#define na_object_get_item( obj, id ) na_object_item_get_item( NA_OBJECT_ITEM( obj ),( const gchar * )( id ))
#define na_object_get_position( obj, child ) na_object_item_get_position( NA_OBJECT_ITEM( obj ), NA_OBJECT_ID( child ))
......@@ -135,15 +135,15 @@ G_BEGIN_DECLS
#define na_object_is_toolbar_same_label( obj ) (( gboolean ) GPOINTER_TO_UINT( na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_SAME_LABEL )))
#define na_object_get_last_allocated( obj ) (( guint ) GPOINTER_TO_UINT( na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED )))
#define na_object_set_version( obj, version ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_VERSION, ( const void * )( version ))
#define na_object_set_target_selection( obj, target ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_SELECTION, ( const void * ) GUINT_TO_POINTER( target ))
#define na_object_set_target_background( obj, target ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_BACKGROUND, ( const void * ) GUINT_TO_POINTER( target ))
#define na_object_set_target_toolbar( obj, target ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_TOOLBAR, ( const void * ) GUINT_TO_POINTER( target ))
#define na_object_set_toolbar_label( obj, label ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_LABEL, ( const void * )( label ))
#define na_object_set_toolbar_same_label( obj, same ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_SAME_LABEL, ( const void * ) GUINT_TO_POINTER( same ))
#define na_object_set_last_allocated( obj, last ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( last ))
#define na_object_set_version( obj, version ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_VERSION, ( const void * )( version ))
#define na_object_set_target_selection( obj, target ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_SELECTION, ( const void * ) GUINT_TO_POINTER( target ))
#define na_object_set_target_background( obj, target ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_BACKGROUND, ( const void * ) GUINT_TO_POINTER( target ))
#define na_object_set_target_toolbar( obj, target ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TARGET_TOOLBAR, ( const void * ) GUINT_TO_POINTER( target ))
#define na_object_set_toolbar_label( obj, label ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_LABEL, ( const void * )( label ))
#define na_object_set_toolbar_same_label( obj, same ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_TOOLBAR_SAME_LABEL, ( const void * ) GUINT_TO_POINTER( same ))
#define na_object_set_last_allocated( obj, last ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( last ))
#define na_object_reset_last_allocated( obj ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( 0 ))
#define na_object_reset_last_allocated( obj ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_LAST_ALLOCATED, ( const void * ) GUINT_TO_POINTER( 0 ))
#define na_object_attach_profile( obj, profile ) na_object_action_attach_profile( NA_OBJECT_ACTION( obj ), NA_OBJECT_PROFILE( profile ))
/* NAObjectProfile
......@@ -159,16 +159,16 @@ G_BEGIN_DECLS
#define na_object_get_schemes( obj ) (( GSList * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_SCHEMES ))
#define na_object_get_folders( obj ) (( GSList * ) na_idata_factory_get( NA_IDATA_FACTORY( obj ), NADF_DATA_FOLDERS ))
#define na_object_set_path( obj, path ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PATH, ( const void * )( path ))
#define na_object_set_parameters( obj, parms ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_PARAMETERS, ( const void * )( parms ))
#define na_object_set_basenames( obj, bnames ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_BASENAMES, ( const void * )( bnames ))
#define na_object_set_matchcase( obj, match ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_MATCHCASE, ( const void * ) GUINT_TO_POINTER( match ))
#define na_object_set_mimetypes( obj, types ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_MIMETYPES, ( const void * )( types ))
#define na_object_set_isfile( obj, isfile ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ISFILE, ( const void * ) GUINT_TO_POINTER( isfile ))
#define na_object_set_isdir( obj, isdir ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_ISDIR, ( const void * ) GUINT_TO_POINTER( isdir ))
#define na_object_set_multiple( obj, multiple ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_MULTIPLE, ( const void * ) GUINT_TO_POINTER( multiple ))
#define na_object_set_schemes( obj, schemes ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_SCHEMES, ( const void * )( schemes ))
#define na_object_set_folders( obj, folders ) na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_FOLDERS, ( const void * )( folders ))
#define na_object_set_path( obj, path ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PATH, ( const void * )( path ))
#define na_object_set_parameters( obj, parms ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_PARAMETERS, ( const void * )( parms ))
#define na_object_set_basenames( obj, bnames ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_BASENAMES, ( const void * )( bnames ))
#define na_object_set_matchcase( obj, match ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_MATCHCASE, ( const void * ) GUINT_TO_POINTER( match ))
#define na_object_set_mimetypes( obj, types ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_MIMETYPES, ( const void * )( types ))
#define na_object_set_isfile( obj, isfile ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ISFILE, ( const void * ) GUINT_TO_POINTER( isfile ))
#define na_object_set_isdir( obj, isdir ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_ISDIR, ( const void * ) GUINT_TO_POINTER( isdir ))
#define na_object_set_multiple( obj, multiple ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_MULTIPLE, ( const void * ) GUINT_TO_POINTER( multiple ))
#define na_object_set_schemes( obj, schemes ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_SCHEMES, ( const void * )( schemes ))
#define na_object_set_folders( obj, folders ) na_idata_factory_set_from_void( NA_IDATA_FACTORY( obj ), NADF_DATA_FOLDERS, ( const void * )( folders ))
#define na_object_set_scheme( obj, scheme, add ) na_object_profile_set_scheme( NA_OBJECT_PROFILE( obj ), ( const gchar * )( scheme ), ( add ))
#define na_object_replace_folder( obj, old, new ) na_object_profile_replace_folder( NA_OBJECT_PROFILE( obj ), ( const gchar * )( old ), ( const gchar * )( new ))
......
......@@ -30,6 +30,7 @@ pkglib_LTLIBRARIES = libna-core.la
AM_CPPFLAGS += \
-I $(top_srcdir) \
-I $(top_srcdir)/src \
-DPKGLIBDIR=\""$(pkglibdir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_CORE}\" \
......@@ -58,6 +59,7 @@ libna_core_la_SOURCES = \
na-iexporter.c \
na-iimporter.c \
na-iio-factory.c \
na-iio-factory-priv.h \
na-iio-provider.c \
na-io-factory.c \
na-io-factory.h \
......
......@@ -659,27 +659,24 @@ v_write_done( NAIDataFactory *serializable, const NAIIOFactory *writer, void *wr
}
/**
* na_data_factory_set:
* na_data_factory_set_from_string:
* @object: this #NAIDataFactory instance.
* @data_id: the elementary data whose value is to be set.
* @data: the value to set.
* @property_id: the elementary data id.
* @string: the string to be set in the element.
*
* Set the elementary data with the given value.
* Set the @object with the @string.
*/
void
na_data_factory_set( NAIDataFactory *object, guint data_id, const void *data )
na_data_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *string )
{
static const gchar *thisfn = "na_data_factory_set";
static const gchar *thisfn = "na_data_factory_set_from_string";
NADataElement *element;
/*g_debug( "%s: object=%p (%s), data_id=%d, data=%p",
thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ), data_id, ( void * ) data );*/
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
element = data_element_from_id( object, data_id );
if( element ){
na_data_element_set_from_void( element, data );
na_data_element_set_from_string( element, string );
} else {
g_warning( "%s: unknown property id %d", thisfn, data_id );
......@@ -687,11 +684,10 @@ na_data_factory_set( NAIDataFactory *object, guint data_id, const void *data )
}
/**
* na_data_factory_get_value:
* na_data_factory_set_from_value:
* @object: this #NAIDataFactory instance.
* @property_id: the elementary data id.
* @value: the #GValue whose content is to be got.
* @spec: the #GParamSpec which describes this data.
*
* Get from the @value the content to be set in the #NADataElement
* attached to @property_id.
......@@ -699,19 +695,47 @@ na_data_factory_set( NAIDataFactory *object, guint data_id, const void *data )
* This is to be readen as "set data element from value".
*/
void
na_data_factory_get_value( NAIDataFactory *object, guint property_id, const GValue *value, GParamSpec *spec )
na_data_factory_set_from_value( NAIDataFactory *object, guint data_id, const GValue *value )
{
static const gchar *thisfn = "na_data_factory_get_value";
static const gchar *thisfn = "na_data_factory_set_from_value";
NADataElement *element;
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
element = data_element_from_id( object, property_id );
element = data_element_from_id( object, data_id );
if( element ){
na_data_element_set_from_value( element, value );
} else {
g_warning( "%s: unknown property id %d", thisfn, property_id );
g_warning( "%s: unknown property id %d", thisfn, data_id );
}
}
/**
* na_data_factory_set_from_void:
* @object: this #NAIDataFactory instance.
* @data_id: the elementary data whose value is to be set.
* @data: the value to set.
*
* Set the elementary data with the given value.
*/
void
na_data_factory_set_from_void( NAIDataFactory *object, guint data_id, const void *data )
{
static const gchar *thisfn = "na_data_factory_set_from_void";
NADataElement *element;
/*g_debug( "%s: object=%p (%s), data_id=%d, data=%p",
thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ), data_id, ( void * ) data );*/
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
element = data_element_from_id( object, data_id );
if( element ){
na_data_element_set_from_void( element, data );
} else {
g_warning( "%s: unknown property id %d", thisfn, data_id );
}
}
......
......@@ -54,8 +54,10 @@ void na_data_factory_finalize ( NAIDataFactory *object );
void na_data_factory_read ( NAIDataFactory *object, const NAIIOFactory *reader, void *reader_data, GSList **messages );
void na_data_factory_write ( NAIDataFactory *object, const NAIIOFactory *writer, void *writer_data, GSList **messages );
void na_data_factory_set ( NAIDataFactory *object, guint data_id, const void *data );
void na_data_factory_get_value ( NAIDataFactory *object, guint property_id, const GValue *value, GParamSpec *spec );
void na_data_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *data );
void na_data_factory_set_from_value ( NAIDataFactory *object, guint data_id, const GValue *value );
void na_data_factory_set_from_void ( NAIDataFactory *object, guint data_id, const void *data );
void *na_data_factory_get ( const NAIDataFactory *object, guint data_id );
void na_data_factory_set_value ( const NAIDataFactory *object, guint property_id, GValue *value, GParamSpec *spec );
......
......@@ -160,7 +160,7 @@ na_idata_factory_get( const NAIDataFactory *object, guint data_id )
}
/**
* na_idata_factory_set:
* na_idata_factory_set_from_string:
* @object: this #NAIDataFactory instance.
* @data_id: the elementary data whose value is to be set.
* @data: the value to set.
......@@ -168,9 +168,25 @@ na_idata_factory_get( const NAIDataFactory *object, guint data_id )
* Set the elementary data with the given value.
*/
void
na_idata_factory_set( NAIDataFactory *object, guint data_id, const void *data )
na_idata_factory_set_from_string( NAIDataFactory *object, guint data_id, const gchar *data )
{
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
na_data_factory_set( object, data_id, data );
na_data_factory_set_from_string( object, data_id, data );
}
/**
* na_idata_factory_set_from_void:
* @object: this #NAIDataFactory instance.
* @data_id: the elementary data whose value is to be set.
* @data: the value to set.
*
* Set the elementary data with the given value.
*/
void
na_idata_factory_set_from_void( NAIDataFactory *object, guint data_id, const void *data )
{
g_return_if_fail( NA_IS_IDATA_FACTORY( object ));
na_data_factory_set_from_void( object, data_id, data );
}
......@@ -210,6 +210,19 @@ na_iio_factory_write_item( const NAIIOFactory *writer, void *writer_data, NAIDat
}
}
/**
* na_iio_factory_get_idtype_from_gconf_key:
* @entry: the name of the node we are searching for.
*
* Returns: the definition of the data which is exported as @entry in GConf,
* or %NULL if not found.
*/
NadfIdType *
na_iio_factory_get_idtype_from_gconf_key( const gchar *entry )
{
return( na_io_factory_get_idtype_from_gconf_key( entry ));
}
static void
v_io_factory_read_start( const NAIIOFactory *reader, void *reader_data, NAIDataFactory *serializable, GSList **messages )
{
......
......@@ -39,27 +39,39 @@ extern gboolean iimporter_finalized; /* defined in na-iimporter.c */
/**
* na_importer_import:
* @items: a #GList of already loaded items.
* @pivot: the #NAPivot pivot for this application.
* @uri: the source filename URI.
* @mode: the import mode.
* @fn: a function to check the existance of the imported item.
* @fn_data: function data
* @messages: a pointer to a #GSList list of strings; the provider
* may append messages to this list, but shouldn't reinitialize it.
*
* Exports the specified @item to the target @uri in the required
* @format.
*
* Returns: a newly allocated #NAObjectItem-derived object, or %NULL
* if an error has been detected.
*/
NAObjectItem *
na_importer_import( GList *items, const gchar *uri, guint mode, GSList **messages )
na_importer_import( const NAPivot *pivot, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages )
{
static const gchar *thisfn = "na_importer_import";
NAObjectItem *item;
GList *modules;
g_debug( "%s: pivot=%p, uri=%s, mode=%d, fn=%p, fn_data=%p, messages=%p",
thisfn, ( void * ) pivot, uri, mode, ( void * ) fn, ( void * ) fn_data, ( void * ) messages );
item = NULL;
if( iimporter_initialized && !iimporter_finalized ){
modules = na_pivot_get_providers( pivot, NA_IIMPORTER_TYPE );
g_debug( "na_importer_import: modules_count=%d", g_list_length( modules ));
if( g_list_length( modules )){
if( NA_IIMPORTER_GET_INTERFACE( NA_IIMPORTER( modules->data ))->import_uri ){
item = NA_IIMPORTER_GET_INTERFACE( NA_IIMPORTER( modules->data ))->import_uri( NA_IIMPORTER( modules->data ), uri, mode, fn, fn_data, messages );
}
}
na_pivot_free_providers( modules );
}
return( item );
......
......@@ -38,10 +38,13 @@
*/
#include <api/na-object-item.h>
#include <api/na-iimporter.h>
#include <core/na-pivot.h>
G_BEGIN_DECLS
NAObjectItem *na_importer_import( GList *items, const gchar *uri, guint mode, GSList **messages );
NAObjectItem *na_importer_import( const NAPivot *pivot, const gchar *uri, guint mode, ImporterCheckFn fn, void *fn_data, GSList **messages );
G_END_DECLS
......
......@@ -32,6 +32,8 @@
#include <config.h>
#endif
#include <string.h>
#include "na-iio-factory-priv.h"
#include "na-io-factory.h"
......@@ -57,7 +59,8 @@ na_io_factory_register( GType type, const NadfIdGroup *groups )
if( iio_factory_initialized && !iio_factory_finalized ){
g_debug( "%s: type=%lu, groups=%p", thisfn, ( unsigned long ) type, ( void * ) groups );
g_debug( "%s: type=%lu, groups=%p",
thisfn, ( unsigned long ) type, ( void * ) groups );
g_return_if_fail( groups != NULL );
......@@ -101,6 +104,62 @@ na_io_factory_get_groups( GType type )
return( NULL );
}
/**
* na_io_factory_get_idtype_from_gconf_key:
* @entry: the name of the GConf entry we are searching for.
*
* Returns: the definition of the data which is exported as @entry in GConf,
* or %NULL if not found.
*/
NadfIdType *
na_io_factory_get_idtype_from_gconf_key( const gchar *entry )
{
static const gboolean debug = FALSE;
GList *imp;
if( iio_factory_initialized && !iio_factory_finalized ){
if( debug ){
g_debug( "na_io_factory_get_idtype_from_gconf_key: entry=%s", entry );
}
for( imp = iio_factory_klass->private->registered ; imp ; imp = imp->next ){
NadfImplement *implement = ( NadfImplement * ) imp->data;
if( debug ){
g_debug( "implement=%p, type=%lu, groups=%p",
( void * ) implement, ( gulong ) implement->type, ( void * ) implement->groups );
}
NadfIdGroup *group = implement->groups;
while( group->idgroup ){
if( debug ){
g_debug( "group=%p, idgroup=%d, iddefs=%p", ( void * ) group, group->idgroup, ( void * ) group->iddef );
}
NadfIdType *iddef = group->iddef;
if( iddef ){
while( iddef->id ){
if( debug ){
g_debug( "iddef=%p, id=%d, gconf_entry=%s", ( void * ) iddef, iddef->id, iddef->gconf_entry );
}
if( iddef->gconf_entry && !strcmp( iddef->gconf_entry, entry )){
return( iddef );
}
iddef++;
}
}
group++;
}
}
}
return( NULL );
}
/**
* na_io_factory_read_value:
* @reader: the instance which implements this #NAIIOFactory interface.
......
......@@ -43,6 +43,7 @@ G_BEGIN_DECLS
void na_io_factory_register ( GType type, const NadfIdGroup *groups );
NadfIdGroup *na_io_factory_get_groups( GType type );
NadfIdType *na_io_factory_get_idtype_from_gconf_key( const gchar *entry );
GValue *na_io_factory_read_value( const NAIIOFactory *reader, void *reader_data, const NadfIdType *iddef, GSList **messages );
......
......@@ -110,15 +110,6 @@ enum {
IPREFS_ORDER_MANUAL
};
/* import mode
*/
enum {
IPREFS_IMPORT_NO_IMPORT = 1,
IPREFS_IMPORT_RENUMBER,
IPREFS_IMPORT_OVERRIDE,
IPREFS_IMPORT_ASK
};
GType na_iprefs_get_type( void );
gint na_iprefs_get_order_mode( NAIPrefs *instance );
......
......@@ -463,9 +463,7 @@ na_module_get_extensions_for_type( GList *modules, GType type )
}
}
willing_to = g_list_reverse( willing_to );
return( willing_to );
return( g_list_reverse( willing_to ));
}
/**
......
......@@ -50,6 +50,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
FALSE,
"version",
NULL },
{ NADF_DATA_TARGET_SELECTION,
......@@ -62,6 +64,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
FALSE,
"target-selection",
NULL },
{ NADF_DATA_TARGET_BACKGROUND,
......@@ -74,6 +78,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
FALSE,
"target-background",
NULL },
{ NADF_DATA_TARGET_TOOLBAR,
......@@ -88,6 +94,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
FALSE,
"target-toolbar",
NULL },
{ NADF_DATA_TOOLBAR_LABEL,
......@@ -101,6 +109,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
TRUE,
"toolbar-label",
NULL },
{ NADF_DATA_TOOLBAR_SAME_LABEL,
......@@ -113,6 +123,8 @@ static NadfIdType action_iddef [] = {
TRUE,
TRUE,
FALSE,
FALSE,
"toolbar-same-label",
NULL },
{ NADF_DATA_LAST_ALLOCATED,
......@@ -126,9 +138,11 @@ static NadfIdType action_iddef [] = {
TRUE,
FALSE,
FALSE,
FALSE,
NULL,
NULL },
{ 0, NULL, FALSE, NULL, NULL, 0, NULL, FALSE, FALSE, FALSE, NULL },
{ 0 },
};
NadfIdGroup action_id_groups [] = {
......@@ -136,5 +150,5 @@ NadfIdGroup action_id_groups [] = {
{ NA_DATA_FACTORY_ITEM_GROUP, item_iddef },
{ NA_DATA_FACTORY_ACTION_GROUP, action_iddef },