[nautilus-actions] na_importer_import_from_list() renamed as na_importer_import_from_uris()



commit 8edeadcf13b421d206b73706aaba51ec2a95fbb6
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Jan 2 07:45:58 2012 +0100

    na_importer_import_from_list() renamed as na_importer_import_from_uris()
    
    + now returns the count of successfully imported items.

 ChangeLog                        |    9 +++++++++
 src/core/na-importer.c           |   22 +++++++++++++---------
 src/core/na-importer.h           |    6 +++---
 src/nact/nact-assistant-import.c |    2 +-
 src/nact/nact-tree-model-dnd.c   |    2 +-
 src/test/test-reader.c           |    4 ++--
 6 files changed, 29 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3280d45..921643a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2012-01-02 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-importer.c:
+	* src/core/na-importer.h (na_importer_import_from_list):
+	Renamed as na_importer_import_from_uris.
+	Now returns the count of succesffully imported items.
+
+	* src/nact/nact-assistant-import.c (assistant_apply):
+	* src/nact/nact-tree-model-dnd.c (drop_uri_list):
+	* src/test/test-reader.c (main): Updated accordingly.
+
 	* src/api/na-iimporter.h: Update documentation.
 
 	* m4/na-maintainer-mode.m4: Reverse the sens of deprecation test.
diff --git a/src/core/na-importer.c b/src/core/na-importer.c
index 1ac0ea8..dc4aea0 100644
--- a/src/core/na-importer.c
+++ b/src/core/na-importer.c
@@ -115,7 +115,7 @@ static NAIOption    *get_mode_from_struct( const NAImportModeStr *str );
 #define ERR_NOT_LOADABLE	_( "%s is not loadable (empty or too big or not a regular file)" )
 
 /*
- * na_importer_import_from_list:
+ * na_importer_import_from_uris:
  * @pivot: the #NAPivot pivot for this application.
  * @parms: a #NAImporterParms structure.
  *
@@ -141,22 +141,23 @@ static NAIOption    *get_mode_from_struct( const NAImportModeStr *str );
  * - keep my choice                   -> import-keep-choice
  * - last chosen import mode          -> import-ask-user-last-mode
  *
- * Returns: the last import operation code.
+ * Returns: the count of successfully imported items
+ * (was the last import operation code up to 3.2).
  *
  * Since: 2.30
  */
 guint
-na_importer_import_from_list( const NAPivot *pivot, NAImporterParms *parms )
+na_importer_import_from_uris( const NAPivot *pivot, NAImporterParms *parms )
 {
-	static const gchar *thisfn = "na_importer_import_from_list";
+	static const gchar *thisfn = "na_importer_import_from_uris";
 	GList *modules;
 	GSList *iuri;
 	NAImporterResult *result;
-	guint code;
+	guint count;
 
-	g_return_val_if_fail( NA_IS_PIVOT( pivot ), IMPORTER_CODE_PROGRAM_ERROR );
+	g_return_val_if_fail( NA_IS_PIVOT( pivot ), 0 );
 
-	code = IMPORTER_CODE_NOT_WILLING_TO;
+	count = 0;
 	parms->results = NULL;
 
 	if( iimporter_initialized && !iimporter_finalized ){
@@ -166,15 +167,18 @@ na_importer_import_from_list( const NAPivot *pivot, NAImporterParms *parms )
 		modules = na_pivot_get_providers( pivot, NA_IIMPORTER_TYPE );
 
 		for( iuri = parms->uris ; iuri ; iuri = iuri->next ){
-			code = import_from_uri( pivot, modules, parms, ( const gchar * ) iuri->data, &result );
+			import_from_uri( pivot, modules, parms, ( const gchar * ) iuri->data, &result );
 			parms->results = g_list_prepend( parms->results, result );
+			if( result->imported ){
+				count += 1;
+			}
 		}
 
 		na_pivot_free_providers( modules );
 		parms->results = g_list_reverse( parms->results );
 	}
 
-	return( code );
+	return( count );
 }
 
 /*
diff --git a/src/core/na-importer.h b/src/core/na-importer.h
index 3ab51b2..e37b883 100644
--- a/src/core/na-importer.h
+++ b/src/core/na-importer.h
@@ -53,7 +53,7 @@ G_BEGIN_DECLS
 typedef struct {
 	GtkWindow         *parent;			/* the parent window, if any */
 	GSList            *uris;			/* the list of uris of the files to be imported */
-	guint              mode;			/* asked import mode */
+	guint              mode;			/* asked (preferred) import mode */
 	NAIImporterCheckFn check_fn;		/* a function to check the existence of the imported id */
 	void              *check_fn_data;	/* data function */
 	GList             *results;			/* a #GList of newly allocated NAImporterResult structures,
@@ -64,14 +64,14 @@ typedef struct {
 
 typedef struct {
 	gchar             *uri;				/* the imported uri */
-	guint              mode;			/* the actual import mode in effect for this import */
+	guint              mode;			/* the actual mode in effect for this import */
 	gboolean           exist;			/* whether the imported Id already existed */
 	NAObjectItem      *imported;		/* eventually imported NAObjectItem-derived object, or %NULL */
 	GSList            *messages;		/* a #GSList list of localized strings */
 }
 	NAImporterResult;
 
-guint      na_importer_import_from_list( const NAPivot *pivot, NAImporterParms *parms );
+guint      na_importer_import_from_uris( const NAPivot *pivot, NAImporterParms *parms );
 
 void       na_importer_free_result     ( NAImporterResult *result );
 
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index b00da71..898dc95 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -677,7 +677,7 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
 	application = NACT_APPLICATION( base_window_get_application( main_window ));
 	updater = nact_application_get_updater( application );
 
-	na_importer_import_from_list( NA_PIVOT( updater ), &importer_parms );
+	na_importer_import_from_uris( NA_PIVOT( updater ), &importer_parms );
 
 	for( it = importer_parms.results ; it ; it = it->next ){
 		result = ( NAImporterResult * ) it->data;
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index be5431d..0e17a75 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -866,7 +866,7 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData  *selec
 	parms.check_fn_data = main_window;
 	parms.results = NULL;
 
-	na_importer_import_from_list( NA_PIVOT( updater ), &parms );
+	na_importer_import_from_uris( NA_PIVOT( updater ), &parms );
 
 	/* analysing output results, simultaneously building a concatenation
 	 * of all lines of messages, and the list of imported items
diff --git a/src/test/test-reader.c b/src/test/test-reader.c
index 9f61d81..9e7421e 100755
--- a/src/test/test-reader.c
+++ b/src/test/test-reader.c
@@ -82,9 +82,9 @@ main( int argc, char **argv )
 	parms.check_fn = NULL;
 	parms.check_fn_data = NULL;
 
-	guint code = na_importer_import_from_list( pivot, &parms );
+	guint count = na_importer_import_from_uris( pivot, &parms );
 
-	g_print( "%s: return code from import is %u.\n", g_get_prgname(), code );
+	g_print( "%s: na_importer_import_from_uris() returns count=%u.\n", g_get_prgname(), count );
 
 	result = parms.results->data;
 	if( result->imported ){



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]