[nautilus-actions] NAIContext: first check for desktop from user preferences



commit 2ea0b12e6ffd3e5326367dc153aa4b86d1ffde18
Author: Pierre Wieser <pwieser trychlos org>
Date:   Fri Feb 25 13:26:11 2011 +0100

    NAIContext: first check for desktop from user preferences

 ChangeLog              |    3 +++
 src/core/na-icontext.c |   12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0fb1563..18ddd9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-02-25 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-icontext.c (is_candidate_for_show_in):
+	First try desktop from user preferences.
+
 	NASettings is now a private singleton which allocates itself when needed.
 	Preference are so available anywhere without requiring an object.
 
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index cbaa0dc..d2df035 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -48,6 +48,7 @@
 #include "na-desktop-environment.h"
 #include "na-gnome-vfs-uri.h"
 #include "na-selected-info.h"
+#include "na-settings.h"
 
 /* private interface data
  */
@@ -515,10 +516,17 @@ is_candidate_for_show_in( const NAIContext *object, guint target, GList *files )
 	gboolean ok = TRUE;
 	GSList *only_in = na_object_get_only_show_in( object );
 	GSList *not_in = na_object_get_not_show_in( object );
-	static const gchar *environment = NULL;
+	static gchar *environment = NULL;
 
+	/* there is a memory leak here when desktop comes from user preferences
+	 * because it is never freed (because it may come from runtime detection)
+	 * but this occurs only once..
+	 */
 	if( !environment ){
-		environment = na_desktop_environment_detect_running_desktop();
+		environment = na_settings_get_string( NA_IPREFS_DESKTOP_ENVIRONMENT, NULL, NULL );
+		if( !environment || !strlen( environment )){
+			environment = ( gchar * ) na_desktop_environment_detect_running_desktop();
+		}
 		g_debug( "%s: found %s desktop", thisfn, environment );
 	}
 



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