[nautilus-actions] Be compliant with XDG specifications



commit 5cc2b86a5fc79b4acd2462a5a797e3c9c3b81a76
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Jul 17 23:10:30 2014 +0200

    Be compliant with XDG specifications
    
    Fix #730994 reported by Mauricio C Antunes, and with his advices

 src/core/na-settings.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/src/core/na-settings.c b/src/core/na-settings.c
index 570f602..7fc28bd 100644
--- a/src/core/na-settings.c
+++ b/src/core/na-settings.c
@@ -414,19 +414,36 @@ settings_new( void )
        static const gchar *thisfn = "na_settings_new";
        gchar *dir;
        GList *content;
+       const gchar * const *array;
+       gchar **iter;
 
        if( !st_settings ){
+               content = NULL;
                st_settings = g_object_new( NA_SETTINGS_TYPE, NULL );
 
+               /* iterate through system config dirs until having found a
+                * config file */
                g_debug( "%s: reading mandatory configuration", thisfn );
-               dir = g_build_filename( SYSCONFDIR, "xdg", PACKAGE, NULL );
-               st_settings->private->mandatory = key_file_new( dir );
-               g_free( dir );
-               st_settings->private->mandatory->mandatory = TRUE;
-               content = content_load_keys( NULL, st_settings->private->mandatory );
+               array = g_get_system_config_dirs();
+               iter = ( gchar ** ) array;
+               while( *iter ){
+                       if( st_settings->private->mandatory ){
+                               release_key_file( st_settings->private->mandatory );
+                       }
+                       g_debug( "iter=%s", *iter );
+                       dir = g_build_filename( *iter, PACKAGE, NULL );
+                       st_settings->private->mandatory = key_file_new( dir );
+                       g_free( dir );
+                       st_settings->private->mandatory->mandatory = TRUE;
+                       content = content_load_keys( NULL, st_settings->private->mandatory );
+                       if( content ){
+                               break;
+                       }
+                       iter++;
+               }
 
                g_debug( "%s: reading user configuration", thisfn );
-               dir = g_build_filename( g_get_home_dir(), ".config", PACKAGE, NULL );
+               dir = g_build_filename( g_get_user_config_dir(), PACKAGE, NULL );
                g_mkdir_with_parents( dir, 0750 );
                st_settings->private->user = key_file_new( dir );
                g_free( dir );


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