[gnumeric] Auto format: make this work again after config changes.



commit eb92622f5929d92f04ea795c6b07c4774ceb0e1d
Author: Morten Welinder <terra gnome org>
Date:   Fri Sep 11 21:31:25 2009 -0400

    Auto format: make this work again after config changes.

 ChangeLog         |    3 +++
 NEWS              |    1 +
 src/file-autoft.c |   33 +++++++++++++++++++++++++--------
 3 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 84686ab..f3f507f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-09-11  Morten Welinder  <terra gnome org>
 
+	* src/file-autoft.c (category_group_list_get): Make this work
+	again after config changes a few versions back.
+
 	* src/rendered-value.c (gnm_rvc_new, gnm_rvc_free, gnm_rvc_query,
 	gnm_rvc_store, gnm_rvc_remove): New functions.
 
diff --git a/NEWS b/NEWS
index d16a8a2..6fe576c 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Morten:
 	* Fix minor status line issue.  [#594469]
 	* Fix print crash for sheet object.  [#594862]
 	* Limit memory usage for rendered values.
+	* Fix auto-format.
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.12
diff --git a/src/file-autoft.c b/src/file-autoft.c
index 7bc40fe..6556b8c 100644
--- a/src/file-autoft.c
+++ b/src/file-autoft.c
@@ -192,22 +192,39 @@ category_list_free (GList *categories)
 	g_list_free (categories);
 }
 
+static void
+add_dir (GSList **pl, const char *dir, const char *base_dir)
+{
+	char *dirc = NULL;
+	if (g_path_is_absolute (dir))
+		dirc = g_strdup (dir);
+	else
+		dirc = g_build_filename (base_dir, dir, NULL);
+	*pl = g_slist_prepend (*pl, dirc);
+}
+
 GList *
 category_group_list_get (void)
 {
 	GList *category_groups = NULL;
-	GSList *dir_list;
+	GSList *dir_list = NULL, *sl;
 	GList *categories, *l;
 	FormatTemplateCategoryGroup *current_group;
 
-	dir_list = go_slist_create ((char *)gnm_conf_get_autoformat_sys_dir (),
-				    (char *)gnm_conf_get_autoformat_usr_dir (),
-				    NULL);
-	dir_list = g_slist_concat
-		(dir_list,
-		 g_slist_copy (gnm_conf_get_autoformat_extra_dirs ()));
+	add_dir (&dir_list,
+		 gnm_conf_get_autoformat_sys_dir (),
+		 gnm_sys_data_dir ());
+	add_dir (&dir_list,
+		 gnm_conf_get_autoformat_usr_dir (),
+		 gnm_usr_dir ());
+
+	for (sl = gnm_conf_get_autoformat_extra_dirs (); sl; sl = sl->next) {
+		const char *dir = sl->data;
+		add_dir (&dir_list, dir, g_get_home_dir ());
+	}
+	dir_list = g_slist_reverse (dir_list);
 	categories = category_list_get_from_dir_list (dir_list);
-	g_slist_free (dir_list); /* we do not own the strings here */
+	go_slist_free_custom (dir_list, g_free);
 
 	categories = g_list_sort (categories, category_compare_name_and_dir);
 



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