diff src/filefilter.c @ 743:77ff94c0490a

Try to load a system-wide rc file if any, before per-user rc file. For now, system-wide rc file path is set to /etc/geeqie/geeqierc (defined by GQ_SYSTEM_WIDE_DIR in main.h). filter_parse() was modified to replace entries having the same key, needed since it may be called more than once. Please test heavily.
author zas_
date Fri, 23 May 2008 00:20:56 +0000
parents a7289f9e8d29
children 2d2cca2bceb0
line wrap: on
line diff
--- a/src/filefilter.c	Thu May 22 23:22:12 2008 +0000
+++ b/src/filefilter.c	Fri May 23 00:20:56 2008 +0000
@@ -79,11 +79,11 @@
 	filter_entry_free(fe);
 }
 
-static gint filter_key_exists(const gchar *key)
+static FilterEntry *filter_get_by_key(const gchar *key)
 {
 	GList *work;
 
-	if (!key) return FALSE;
+	if (!key) return NULL;
 
 	work = filter_list;
 	while (work)
@@ -91,10 +91,15 @@
 		FilterEntry *fe = work->data;
 		work = work->next;
 
-		if (strcmp(fe->key, key) == 0) return TRUE;
+		if (strcmp(fe->key, key) == 0) return fe;
 		}
 
-	return FALSE;
+	return NULL;
+}
+
+static gint filter_key_exists(const gchar *key)
+{
+	return (filter_get_by_key(key) == NULL ? FALSE : TRUE);
 }
 
 void filter_add(const gchar *key, const gchar *description, const gchar *extensions, FileFormatClass file_class, gint enabled)
@@ -419,7 +424,13 @@
 		enabled = FALSE;
 		}
 
-	if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, file_class, enabled);
+	if (key && strlen(key) > 0 && ext)
+		{
+		FilterEntry *fe = filter_get_by_key(key);
+
+		if (fe != NULL) filter_remove_entry(fe);
+		filter_add(key, desc, ext, file_class, enabled);
+		}
 
 	g_free(key);
 	g_free(ext);