SF.net SVN: geany:[5736] trunk/src/filetypes.c

colombanw at users.sourceforge.net colombanw at xxxxx
Sun Apr 24 15:30:33 UTC 2011


Revision: 5736
          http://geany.svn.sourceforge.net/geany/?rev=5736&view=rev
Author:   colombanw
Date:     2011-04-24 15:30:32 +0000 (Sun, 24 Apr 2011)

Log Message:
-----------
When copying filetype groups, add keys from both system and user ones

This makes sure we use the user filetypes in precedence over system ones
even if both are present.

Modified Paths:
--------------
    trunk/src/filetypes.c

Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c	2011-04-24 15:30:20 UTC (rev 5735)
+++ trunk/src/filetypes.c	2011-04-24 15:30:32 UTC (rev 5736)
@@ -1248,22 +1248,30 @@
 
 static void add_group_keys(GKeyFile *kf, const gchar *group, GeanyFiletype *ft)
 {
-	GKeyFile *src = g_key_file_new();
-	gchar *f;
+	gchar *files[2];
+	gboolean loaded = FALSE;
+	guint i;
 
-	f = filetypes_get_filename(ft, FALSE);
-	if (!g_file_test(f, G_FILE_TEST_EXISTS))
-		f = filetypes_get_filename(ft, TRUE);
+	files[0] = filetypes_get_filename(ft, FALSE);
+	files[1] = filetypes_get_filename(ft, TRUE);
 
-	if (!g_key_file_load_from_file(src, f, G_KEY_FILE_NONE, NULL))
+	for (i = 0; i < G_N_ELEMENTS(files); i++)
 	{
-		geany_debug("Could not read config file %s for [%s=%s]!", f, group, ft->name);
-		g_free(f);
-		return;
+		GKeyFile *src = g_key_file_new();
+
+		if (g_key_file_load_from_file(src, files[i], G_KEY_FILE_NONE, NULL))
+		{
+			add_keys(kf, group, src);
+			loaded = TRUE;
+		}
+		g_key_file_free(src);
 	}
-	g_free(f);
 
-	add_keys(kf, group, src);
+	if (!loaded)
+		geany_debug("Could not read config file %s for [%s=%s]!", files[0], group, ft->name);
+
+	g_free(files[0]);
+	g_free(files[1]);
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list