Author: kelnos
Date: 2008-11-08 21:52:11 +0000 (Sat, 08 Nov 2008)
New Revision: 28676

Modified:
   xfconf/trunk/NEWS
   xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c
Log:
only consider the file under $XDG_CONFIG_HOME as the user dir.  all
others in $XDG_CONFIG_DIRS should be considered system dirs (bug 4592).

Modified: xfconf/trunk/NEWS
===================================================================
--- xfconf/trunk/NEWS   2008-11-08 20:50:50 UTC (rev 28675)
+++ xfconf/trunk/NEWS   2008-11-08 21:52:11 UTC (rev 28676)
@@ -13,6 +13,10 @@
   * Add libxfconf perl bindings.
   * Remove xfconf_channel_remove_property() and
     xfconf_channel_remove_properties().
+  * Only treat the XML file under $XDG_CONFIG_HOME as a "user" file,
+    and treat all others as system files.  This fixes the problem where
+    Xfce-installed defaults get read *after* the user's config when
+    Xfce is installed to a user-writable prefix (bug 4592).
 
 
 Xfce 4.6beta1 (Xfce 4.5.91)

Modified: xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c
===================================================================
--- xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c        2008-11-08 
20:50:50 UTC (rev 28675)
+++ xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c        2008-11-08 
21:52:11 UTC (rev 28676)
@@ -1645,8 +1645,7 @@
                                            GError **error)
 {
     XfconfChannel *channel = NULL;
-    gchar *filename_stem = NULL, **filenames = NULL;
-    GSList *system_files = NULL, *user_files = NULL, *l;
+    gchar *filename_stem, **filenames, *user_file;
     gint i;
     XfconfProperty *prop;
 
@@ -1654,19 +1653,11 @@
 
     filename_stem = g_strdup_printf(CONFIG_FILE_FMT, channel_name);
     filenames = xfce_resource_lookup_all(XFCE_RESOURCE_CONFIG, filename_stem);
+    user_file = xfce_resource_save_location(XFCE_RESOURCE_CONFIG,
+                                            filename_stem, FALSE);
     g_free(filename_stem);
 
-    for(i = 0; filenames[i]; ++i) {
-        if(!access(filenames[i], W_OK))  /* we can write, it's ours */
-            user_files = g_slist_append(user_files, filenames[i]);
-        else if(!access(filenames[i], R_OK))  /* we can read, it's system */
-            system_files = g_slist_append(system_files, filenames[i]);
-        else  /* we can't even read, so skip it */
-            g_free(filenames[i]);
-    }
-    g_free(filenames);
-
-    if(!system_files && !user_files) {
+    if((!filenames || !filenames[0]) && !user_file) {
         if(error) {
             g_set_error(error, XFCONF_ERROR,
                         XFCONF_ERROR_CHANNEL_NOT_FOUND,
@@ -1680,26 +1671,26 @@
     prop->name = g_strdup("/");
     channel->properties = g_node_new(prop);
 
-    for(l = system_files; l && !channel->locked; l = l->next) {
-        xfconf_backend_perchannel_xml_merge_file(xbpx, l->data, TRUE,
+    /* read in system files */
+    for(i = 0; filenames[i]; ++i) {
+        if(user_file && !strcmp(filenames[i], user_file))
+            continue;
+        xfconf_backend_perchannel_xml_merge_file(xbpx, filenames[i], TRUE,
                                                  channel, NULL);
     }
-    if(!channel->locked) {
-        for(l = user_files; l; l = l->next) {
-            xfconf_backend_perchannel_xml_merge_file(xbpx, l->data, FALSE,
-                                                     channel, NULL);
-        }
+
+    if(!channel->locked && user_file) {
+        /* read in user file */
+        xfconf_backend_perchannel_xml_merge_file(xbpx, user_file, FALSE,
+                                                 channel, NULL);
     }
 
     g_tree_insert(xbpx->channels, g_ascii_strdown(channel_name, -1), channel);
 
 out:
+    g_strfreev(filenames);
+    g_free(user_file);
 
-    g_slist_foreach(user_files, (GFunc)g_free, NULL);
-    g_slist_free(user_files);
-    g_slist_foreach(system_files, (GFunc)g_free, NULL);
-    g_slist_free(system_files);
-
     return channel;
 }
 

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to