[nautilus-actions] Review NAIImporter interface
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Review NAIImporter interface
- Date: Tue, 3 Jan 2012 22:35:15 +0000 (UTC)
commit 28dbee61b990c94d86a252abff8646ed5469ad70
Author: Pierre Wieser <pwieser trychlos org>
Date: Tue Jan 3 23:16:36 2012 +0100
Review NAIImporter interface
ChangeLog | 3 ++
src/core/na-iimporter.c | 42 ++++++++++++++++--------------------
src/core/na-importer.c | 54 ++++++++++++++++++++--------------------------
3 files changed, 46 insertions(+), 53 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b185402..eabb155 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2012-01-03 Pierre Wieser <pwieser trychlos org>
+ * src/core/na-iimporter.c:
+ * src/core/na-importer.c: Review NAIImporterInterface.
+
* src/core/na-factory-provider.c:
* src/core/na-ifactory-provider.c: Review NAIFactoryProvider interface.
diff --git a/src/core/na-iimporter.c b/src/core/na-iimporter.c
index d1e30e3..4528cbb 100644
--- a/src/core/na-iimporter.c
+++ b/src/core/na-iimporter.c
@@ -44,12 +44,11 @@ struct _NAIImporterInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
-gboolean iimporter_initialized = FALSE;
-gboolean iimporter_finalized = FALSE;
+static guint st_initializations = 0; /* interface initialization count */
static GType register_type( void );
-static void interface_base_init( NAIImporterInterface *klass );
-static void interface_base_finalize( NAIImporterInterface *klass );
+static void interface_init( NAIImporterInterface *klass );
+static void interface_finalize( NAIImporterInterface *klass );
static guint iimporter_get_version( const NAIImporter *instance );
#ifdef NA_ENABLE_DEPRECATED
@@ -86,8 +85,8 @@ register_type( void )
static const GTypeInfo info = {
sizeof( NAIImporterInterface ),
- ( GBaseInitFunc ) interface_base_init,
- ( GBaseFinalizeFunc ) interface_base_finalize,
+ ( GBaseInitFunc ) interface_init,
+ ( GBaseFinalizeFunc ) interface_finalize,
NULL,
NULL,
NULL,
@@ -106,11 +105,11 @@ register_type( void )
}
static void
-interface_base_init( NAIImporterInterface *klass )
+interface_init( NAIImporterInterface *klass )
{
- static const gchar *thisfn = "na_iimporter_interface_base_init";
+ static const gchar *thisfn = "na_iimporter_interface_init";
- if( !iimporter_initialized ){
+ if( !st_initializations ){
g_debug( "%s: klass%p (%s)", thisfn, ( void * ) klass, G_OBJECT_CLASS_NAME( klass ));
@@ -118,21 +117,21 @@ interface_base_init( NAIImporterInterface *klass )
klass->get_version = iimporter_get_version;
klass->import_from_uri = NULL;
-
- iimporter_initialized = TRUE;
}
+
+ st_initializations += 1;
}
static void
-interface_base_finalize( NAIImporterInterface *klass )
+interface_finalize( NAIImporterInterface *klass )
{
- static const gchar *thisfn = "na_iimporter_interface_base_finalize";
+ static const gchar *thisfn = "na_iimporter_interface_finalize";
- if( iimporter_initialized && !iimporter_finalized ){
+ st_initializations -= 1;
- g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+ if( !st_initializations ){
- iimporter_finalized = TRUE;
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
g_free( klass->private );
}
@@ -167,14 +166,11 @@ na_iimporter_import_from_uri( const NAIImporter *importer, NAIImporterImportFrom
code = IMPORTER_CODE_NOT_WILLING_TO;
- if( iimporter_initialized && !iimporter_finalized ){
-
- g_debug( "%s: importer=%p (%s), parms=%p", thisfn,
- ( void * ) importer, G_OBJECT_TYPE_NAME( importer), ( void * ) parms );
+ g_debug( "%s: importer=%p (%s), parms=%p", thisfn,
+ ( void * ) importer, G_OBJECT_TYPE_NAME( importer), ( void * ) parms );
- if( NA_IIMPORTER_GET_INTERFACE( importer )->import_from_uri ){
- code = NA_IIMPORTER_GET_INTERFACE( importer )->import_from_uri( importer, parms );
- }
+ if( NA_IIMPORTER_GET_INTERFACE( importer )->import_from_uri ){
+ code = NA_IIMPORTER_GET_INTERFACE( importer )->import_from_uri( importer, parms );
}
return( code );
diff --git a/src/core/na-importer.c b/src/core/na-importer.c
index 2a3ea72..5595ca4 100644
--- a/src/core/na-importer.c
+++ b/src/core/na-importer.c
@@ -96,9 +96,6 @@ static NAImportModeStr st_import_ask_mode = {
"import-mode-ask.png"
};
-extern gboolean iimporter_initialized; /* defined in na-iimporter.c */
-extern gboolean iimporter_finalized; /* defined in na-iimporter.c */
-
static NAImporterResult *import_from_uri( const NAPivot *pivot, GList *modules, const gchar *uri );
static void manage_import_mode( NAImporterParms *parms, GList *results, NAImporterAskUserParms *ask_parms, NAImporterResult *result );
static NAObjectItem *is_importing_already_exists( NAImporterParms *parms, GList *results, NAImporterResult *result );
@@ -149,41 +146,38 @@ na_importer_import_from_uris( const NAPivot *pivot, NAImporterParms *parms )
results = NULL;
- if( iimporter_initialized && !iimporter_finalized ){
-
- g_debug( "%s: pivot=%p, parms=%p", thisfn, ( void * ) pivot, ( void * ) parms );
+ g_debug( "%s: pivot=%p, parms=%p", thisfn, ( void * ) pivot, ( void * ) parms );
- /* first phase: just try to import the uris into memory
- */
- modules = na_pivot_get_providers( pivot, NA_IIMPORTER_TYPE );
+ /* first phase: just try to import the uris into memory
+ */
+ modules = na_pivot_get_providers( pivot, NA_IIMPORTER_TYPE );
- for( uri = parms->uris ; uri ; uri = uri->next ){
- import_result = import_from_uri( pivot, modules, ( const gchar * ) uri->data );
- results = g_list_prepend( results, import_result );
- }
+ for( uri = parms->uris ; uri ; uri = uri->next ){
+ import_result = import_from_uri( pivot, modules, ( const gchar * ) uri->data );
+ results = g_list_prepend( results, import_result );
+ }
- na_pivot_free_providers( modules );
+ na_pivot_free_providers( modules );
- results = g_list_reverse( results );
+ results = g_list_reverse( results );
- memset( &ask_parms, '\0', sizeof( NAImporterAskUserParms ));
- ask_parms.parent = parms->parent_toplevel;
- ask_parms.count = 0;
- ask_parms.keep_choice = FALSE;
- ask_parms.pivot = pivot;
+ memset( &ask_parms, '\0', sizeof( NAImporterAskUserParms ));
+ ask_parms.parent = parms->parent_toplevel;
+ ask_parms.count = 0;
+ ask_parms.keep_choice = FALSE;
+ ask_parms.pivot = pivot;
- /* second phase: check for their pre-existence
- */
- for( ires = results ; ires ; ires = ires->next ){
- import_result = ( NAImporterResult * ) ires->data;
+ /* second phase: check for their pre-existence
+ */
+ for( ires = results ; ires ; ires = ires->next ){
+ import_result = ( NAImporterResult * ) ires->data;
- if( import_result->imported ){
- g_return_val_if_fail( NA_IS_OBJECT_ITEM( import_result->imported ), NULL );
- g_return_val_if_fail( NA_IS_IIMPORTER( import_result->importer ), NULL );
+ if( import_result->imported ){
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( import_result->imported ), NULL );
+ g_return_val_if_fail( NA_IS_IIMPORTER( import_result->importer ), NULL );
- ask_parms.uri = import_result->uri;
- manage_import_mode( parms, results, &ask_parms, import_result );
- }
+ ask_parms.uri = import_result->uri;
+ manage_import_mode( parms, results, &ask_parms, import_result );
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]