[anjuta] run-program: bgo #640726 - Anjuta stops updating session information



commit fb6b3099b0d3ff70e4d90f260c5f39837d6a1652
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Thu Jan 27 20:52:46 2011 +0100

    run-program: bgo #640726 - Anjuta stops updating session information

 libanjuta/anjuta-session.c       |    7 ++++---
 plugins/run-program/parameters.c |    9 ++++++---
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/libanjuta/anjuta-session.c b/libanjuta/anjuta-session.c
index b7c1bb0..b6c3b46 100644
--- a/libanjuta/anjuta-session.c
+++ b/libanjuta/anjuta-session.c
@@ -314,7 +314,8 @@ anjuta_session_set_string_list (AnjutaSession *session,
 	node = value;
 	while (node)
 	{
-		if (node->data && strlen (node->data) > 0)
+		/* Keep empty string */
+		if (node->data != NULL)
 		{
 			if (first_item)
 				first_item = FALSE;
@@ -440,8 +441,8 @@ anjuta_session_get_string_list (AnjutaSession *session,
 			ptr = str;
 			while (*ptr)
 			{
-				if (strlen (*ptr) > 0)
-					value = g_list_prepend (value, g_strdup (*ptr));
+				/* Keep empty string */
+				value = g_list_prepend (value, g_strdup (*ptr));
 				ptr++;
 			}
 			g_strfreev (str);
diff --git a/plugins/run-program/parameters.c b/plugins/run-program/parameters.c
index 82441fd..dc2cb4c 100644
--- a/plugins/run-program/parameters.c
+++ b/plugins/run-program/parameters.c
@@ -229,7 +229,7 @@ save_environment_variables (RunProgramPlugin *plugin, GtkTreeModel *model)
 static void
 save_dialog_data (RunDialog* dlg)
 {
-	const gchar *arg;
+	gchar *arg;
 	const gchar *filename;
 	gchar *uri;
 	GList *find;
@@ -237,16 +237,19 @@ save_dialog_data (RunDialog* dlg)
 	RunProgramPlugin *plugin = dlg->plugin;
 
 	/* Save arguments */
-	arg = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dlg->args))));
+	arg = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dlg->args)))));
+	arg = g_strstrip (arg);
 	if (arg != NULL)
 	{
+		/* Remove empty string in list, allow it only as first item */
+		if (*(gchar *)(plugin->recent_args->data) == '\0') plugin->recent_args = g_list_delete_link (plugin->recent_args, plugin->recent_args);
 		find = g_list_find_custom(plugin->recent_args, arg, (GCompareFunc)strcmp);
 		if (find)
 		{
 			g_free (find->data);
 			plugin->recent_args = g_list_delete_link (plugin->recent_args, find);
 		}
-		plugin->recent_args = g_list_prepend (plugin->recent_args, g_strdup (arg));
+		plugin->recent_args = g_list_prepend (plugin->recent_args, arg);
 	}	
 
 	/* Save target */



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