[nautilus-actions] Do not emit a warning if Type is not found in the .desktop file



commit 23bd28d8b81739a4dd74bf229d8bad1029db50fd
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Apr 1 20:31:29 2010 +0200

    Do not emit a warning if Type is not found in the .desktop file

 ChangeLog                          |    4 ++++
 src/io-desktop/nadp-desktop-file.c |   21 +++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7cf2adf..26ea7fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,10 @@
 	* src/core/na-object-id.c (na_object_id_prepare_for_paste):
 	Parent is not always an action, may be a menu.
 
+	* src/io-desktop/nadp-desktop-file.c
+	(nadp_desktop_file_get_file_type):
+	Do not emit a warning if Type is not found in the .desktop file.
+
 2009-03-28 Pierre Wieser <pwieser trychlos org>
 
 	* src/api/na-data-boxed.h:
diff --git a/src/io-desktop/nadp-desktop-file.c b/src/io-desktop/nadp-desktop-file.c
index 98fd492..4823b3f 100644
--- a/src/io-desktop/nadp-desktop-file.c
+++ b/src/io-desktop/nadp-desktop-file.c
@@ -340,23 +340,32 @@ check_key_file( NadpDesktopFile *ndf )
 gchar *
 nadp_desktop_file_get_file_type( const NadpDesktopFile *ndf )
 {
-	static const gchar *thisfn = "nadp_desktop_file_get_type";
+	static const gchar *thisfn = "nadp_desktop_file_get_file_type";
 	gchar *type;
+	gboolean has_key;
 	GError *error;
 
-	type = NULL;
-	error = NULL;
 	g_return_val_if_fail( NADP_IS_DESKTOP_FILE( ndf ), NULL );
 
+	type = NULL;
+
 	if( !ndf->private->dispose_has_run ){
 
-		type = g_key_file_get_string( ndf->private->key_file, NADP_GROUP_DESKTOP, NADP_KEY_TYPE, &error );
+		error = NULL;
 
+		has_key = g_key_file_has_key( ndf->private->key_file, NADP_GROUP_DESKTOP, NADP_KEY_TYPE, &error );
 		if( error ){
 			g_warning( "%s: %s", thisfn, error->message );
 			g_error_free( error );
-			g_free( type );
-			type = NULL;
+
+		} else if( has_key ){
+			type = g_key_file_get_string( ndf->private->key_file, NADP_GROUP_DESKTOP, NADP_KEY_TYPE, &error );
+			if( error ){
+				g_warning( "%s: %s", thisfn, error->message );
+				g_error_free( error );
+				g_free( type );
+				type = NULL;
+			}
 		}
 	}
 



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