[nautilus-actions] Do not deal with null values when parsing parameters



commit 0465f90747f71eea2e1a320c0083808f008d72b9
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Apr 14 22:11:23 2010 +0200

    Do not deal with null values when parsing parameters

 ChangeLog                    |   11 +++++++
 po/es.po                     |   20 -------------
 src/core/na-icontext.c       |    4 +-
 src/core/na-object-profile.c |   62 ++++++++++++++++++++++++++++-------------
 src/core/na-selected-info.c  |   14 +++++-----
 src/core/na-selected-info.h  |    2 +-
 6 files changed, 63 insertions(+), 50 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 13abc0f..a22e3ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2009-04-14 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-selected-info.h:
+	* src/core/na-selected-info.c (na_selected_info_get_name):
+	Renamed as na_selected_info_get_path.
+
+	* src/core/na-icontext.c
+	(is_current_folder_inside, is_target_selection_candidate):
+	Updated accordingly.
+
+	* src/core/na-object-profile.c (na_object_profile_parse_parameters):
+	Do not try to deal with null values.
+
 	* src/plugin-menu/nautilus-actions.c (create_item_from_profile):
 	Duplicate the candidate profile, set the parent to null.
 
diff --git a/po/es.po b/po/es.po
index c29ed32..40f2b44 100644
--- a/po/es.po
+++ b/po/es.po
@@ -557,13 +557,9 @@ msgstr ""
 "Un patrón para coincidir con los archivos seleccionados. Puede incluir "
 "comodines (? o *) (debe establecer una opción por cada patrón que necesite)"
 
-<<<<<<< HEAD
-#: ../src/core/na-icontextual-factory.c:125
-=======
 #: ../src/core/na-icontext-factory.c:125
 #, fuzzy
 #| msgid "Whether the labels are the sames"
->>>>>>> Refactor NAIContextual as NAIContext
 msgid "Whether the profile applies to files"
 msgstr "Indica si el perfil se aplica a archivos"
 
@@ -599,13 +595,9 @@ msgstr ""
 "isfile=FALSE e isdir=FALSE: combinación inválida (su configuración nunca "
 "aparecerá)"
 
-<<<<<<< HEAD
-#: ../src/core/na-icontextual-factory.c:153
-=======
 #: ../src/core/na-icontext-factory.c:153
 #, fuzzy
 #| msgid "Whether the labels are the sames"
->>>>>>> Refactor NAIContextual as NAIContext
 msgid "Whether the profile applies to folders"
 msgstr "Indica si el perfil se aplica a carpetas"
 
@@ -641,13 +633,9 @@ msgstr ""
 "isfile=FALSE e isdir=FALSE: combinación inválida (su configuración nunca "
 "aparecerá)"
 
-<<<<<<< HEAD
-#: ../src/core/na-icontextual-factory.c:181
-=======
 #: ../src/core/na-icontext-factory.c:181
 #, fuzzy
 #| msgid "Whether the action is enabled"
->>>>>>> Refactor NAIContextual as NAIContext
 msgid "Whether the selection may be multiple"
 msgstr "Indica si la selección puede ser múltiple"
 
@@ -665,13 +653,9 @@ msgstr ""
 "Si necesita que se selecciones uno o más archivos o carpetas, ponga a «true» "
 "esta clave. Si tan sólo quiere un archivo o carpeta, póngala a «false»"
 
-<<<<<<< HEAD
-#: ../src/core/na-icontextual-factory.c:204
-=======
 #: ../src/core/na-icontext-factory.c:204
 #, fuzzy
 #| msgid "The list of pattern to match the selected file(s)/folder(s)"
->>>>>>> Refactor NAIContextual as NAIContext
 msgid ""
 "List of schemes to be matched against those of selected file(s)/folder(s)"
 msgstr ""
@@ -736,15 +720,11 @@ msgstr ""
 "\n"
 "Se pueden usar todos los esquemas GnomeVFS que use Nautilus aquí."
 
-<<<<<<< HEAD
-#: ../src/core/na-icontextual-factory.c:233
-=======
 #: ../src/core/na-icontext-factory.c:233
 #, fuzzy
 #| msgid ""
 #| "A valid GIO scheme where the selected files should be located. You must "
 #| "set one option for each scheme you need"
->>>>>>> Refactor NAIContextual as NAIContext
 msgid ""
 "A valid GIO scheme where the selected file(s)/folder(s) should be located. "
 "You must set one option for each scheme you need"
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index 1511036..174bfab 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -313,7 +313,7 @@ is_current_folder_inside( const NAIContext *object, NASelectedInfo *current_fold
 	gchar *current_folder_path;
 
 	is_inside = FALSE;
-	current_folder_path = na_selected_info_get_name( current_folder );
+	current_folder_path = na_selected_info_get_path( current_folder );
 	folders = na_object_get_folders( object );
 
 	for( ifold = folders ; ifold && !is_inside ; ifold = ifold->next ){
@@ -407,7 +407,7 @@ is_target_selection_candidate( const NAIContext *object, GList *files )
 
 	for( iter1 = files ; iter1 ; iter1 = iter1->next ){
 
-		tmp_filename = na_selected_info_get_name( NA_SELECTED_INFO( iter1->data ));
+		tmp_filename = na_selected_info_get_path( NA_SELECTED_INFO( iter1->data ));
 		g_debug( "na_icontext_is_target_selection_candidate: tmp_filename=%s", tmp_filename );
 
 		if( tmp_filename ){
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index a5037bf..77e64c6 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -520,7 +520,7 @@ na_object_profile_parse_parameters( const NAObjectProfile *profile, gint target,
 			na_gnome_vfs_uri_parse( vfs, iuri );
 
 			uri = g_strdup( iuri );
-			dirname = g_path_get_dirname( ipath );
+			dirname = ipath ? g_path_get_dirname( ipath ) : NULL;
 			scheme = g_strdup( vfs->scheme );
 			filename = g_strdup( ibname );
 			hostname = g_strdup( vfs->host_name );
@@ -531,13 +531,17 @@ na_object_profile_parse_parameters( const NAObjectProfile *profile, gint target,
 			na_gnome_vfs_uri_free( vfs );
 		}
 
-		tmp = g_shell_quote( ibname );
-		g_string_append_printf( basename_list, " %s", tmp );
-		g_free( tmp );
+		if( ibname ){
+			tmp = g_shell_quote( ibname );
+			g_string_append_printf( basename_list, " %s", tmp );
+			g_free( tmp );
+		}
 
-		tmp = g_shell_quote( ipath );
-		g_string_append_printf( pathname_list, " %s", tmp );
-		g_free( tmp );
+		if( ipath ){
+			tmp = g_shell_quote( ipath );
+			g_string_append_printf( pathname_list, " %s", tmp );
+			g_free( tmp );
+		}
 
 		tmp = g_shell_quote( iuri );
 		g_string_append_printf( uris_list, " %s", tmp );
@@ -560,35 +564,45 @@ na_object_profile_parse_parameters( const NAObjectProfile *profile, gint target,
 			/* base dir of the (first) selected item
 			 */
 			case 'd':
-				tmp = g_shell_quote( dirname );
-				string = g_string_append( string, tmp );
-				g_free( tmp );
+				if( dirname ){
+					tmp = g_shell_quote( dirname );
+					string = g_string_append( string, tmp );
+					g_free( tmp );
+				}
 				break;
 
 			/* basename of the (first) selected item
 			 */
 			case 'f':
-				tmp = g_shell_quote( filename );
-				string = g_string_append( string, tmp );
-				g_free( tmp );
+				if( filename ){
+					tmp = g_shell_quote( filename );
+					string = g_string_append( string, tmp );
+					g_free( tmp );
+				}
 				break;
 
 			/* hostname of the (first) URI
 			 */
 			case 'h':
-				string = g_string_append( string, hostname );
+				if( hostname ){
+					string = g_string_append( string, hostname );
+				}
 				break;
 
 			/* space-separated list of the basenames
 			 */
 			case 'm':
-				string = g_string_append( string, basename_list->str );
+				if( basename_list->str ){
+					string = g_string_append( string, basename_list->str );
+				}
 				break;
 
 			/* space-separated list of full pathnames
 			 */
 			case 'M':
-				string = g_string_append( string, pathname_list->str );
+				if( pathname_list->str ){
+					string = g_string_append( string, pathname_list->str );
+				}
 				break;
 
 			/* port number of the (first) URI
@@ -602,25 +616,33 @@ na_object_profile_parse_parameters( const NAObjectProfile *profile, gint target,
 			/* list of URIs
 			 */
 			case 'R':
-				string = g_string_append( string, uris_list->str );
+				if( uris_list->str ){
+					string = g_string_append( string, uris_list->str );
+				}
 				break;
 
 			/* scheme of the (first) URI
 			 */
 			case 's':
-				string = g_string_append( string, scheme );
+				if( scheme ){
+					string = g_string_append( string, scheme );
+				}
 				break;
 
 			/* URI of the first item
 			 */
 			case 'u':
-				string = g_string_append( string, uri );
+				if( uri ){
+					string = g_string_append( string, uri );
+				}
 				break;
 
 			/* username of the (first) URI
 			 */
 			case 'U':
-				string = g_string_append( string, username );
+				if( username ){
+					string = g_string_append( string, username );
+				}
 				break;
 
 			/* a percent sign
diff --git a/src/core/na-selected-info.c b/src/core/na-selected-info.c
index 9c6b3d2..be0f446 100644
--- a/src/core/na-selected-info.c
+++ b/src/core/na-selected-info.c
@@ -46,7 +46,7 @@ struct NASelectedInfoClassPrivate {
 struct NASelectedInfoPrivate {
 	gboolean       dispose_has_run;
 	gchar         *uri;
-	NAGnomeVFSURI *vfs;;
+	NAGnomeVFSURI *vfs;
 	GFile         *location;
 	gchar         *mimetype;
 	GFileType      file_type;
@@ -307,26 +307,26 @@ na_selected_info_get_mime_type( const NASelectedInfo *nsi )
 }
 
 /**
- * na_selected_info_get_name:
+ * na_selected_info_get_path:
  * @nsi: this #NASelectedInfo object.
  *
  * Returns: the filename of the item.
  */
 gchar *
-na_selected_info_get_name( const NASelectedInfo *nsi )
+na_selected_info_get_path( const NASelectedInfo *nsi )
 {
-	gchar *name;
+	gchar *path;
 
 	g_return_val_if_fail( NA_IS_SELECTED_INFO( nsi ), NULL );
 
-	name = NULL;
+	path = NULL;
 
 	if( !nsi->private->dispose_has_run ){
 
-		name = g_strdup( nsi->private->vfs->path );
+		path = g_strdup( nsi->private->vfs->path );
 	}
 
-	return( name );
+	return( path );
 }
 
 /**
diff --git a/src/core/na-selected-info.h b/src/core/na-selected-info.h
index e4c9796..cd647d3 100644
--- a/src/core/na-selected-info.h
+++ b/src/core/na-selected-info.h
@@ -81,7 +81,7 @@ void            na_selected_info_free_list         ( GList *list );
 
 GFile          *na_selected_info_get_location  ( const NASelectedInfo *nsi );
 gchar          *na_selected_info_get_mime_type ( const NASelectedInfo *nsi );
-gchar          *na_selected_info_get_name      ( const NASelectedInfo *nsi );
+gchar          *na_selected_info_get_path      ( const NASelectedInfo *nsi );
 gchar          *na_selected_info_get_uri       ( const NASelectedInfo *nsi );
 gchar          *na_selected_info_get_uri_scheme( const NASelectedInfo *nsi );
 gboolean        na_selected_info_is_directory  ( const NASelectedInfo *nsi );



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