[gnome-settings-daemon] sound: Use glib to get the XDG dirs



commit 6368c61a00159abe278f6361c3b3f6d1f3abcec6
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Jan 12 19:18:27 2013 +0100

    sound: Use glib to get the XDG dirs
    
    Instead of processing the environment variables by hand.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691589

 plugins/sound/gsd-sound-manager.c |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)
---
diff --git a/plugins/sound/gsd-sound-manager.c b/plugins/sound/gsd-sound-manager.c
index e41d4db..0cafaf7 100644
--- a/plugins/sound/gsd-sound-manager.c
+++ b/plugins/sound/gsd-sound-manager.c
@@ -255,8 +255,9 @@ gboolean
 gsd_sound_manager_start (GsdSoundManager *manager,
                          GError **error)
 {
-        char *p, **ps, **k;
-        const char *env, *dd;
+        guint i;
+        const gchar * const * dirs;
+        char *p;
 
         g_debug ("Starting sound manager");
         gnome_settings_profile_start (NULL);
@@ -266,30 +267,18 @@ gsd_sound_manager_start (GsdSoundManager *manager,
 
         /* ... and we listen to changes of the theme base directories
          * in $HOME ...*/
+        p = g_build_filename (g_get_user_data_dir (), "sounds", NULL);
+        register_directory_callback (manager, p, NULL);
+        g_free (p);
 
-        if ((env = g_getenv ("XDG_DATA_HOME")) && *env == '/')
-                p = g_build_filename (env, "sounds", NULL);
-        else if (((env = g_getenv ("HOME")) && *env == '/') || (env = g_get_home_dir ()))
-                p = g_build_filename (env, ".local", "share", "sounds", NULL);
-        else
-                p = NULL;
-
-        if (p) {
+        /* ... and globally. */
+        dirs = g_get_system_data_dirs ();
+        for (i = 0; dirs[i] != NULL; i++) {
+                p = g_build_filename (dirs[i], "sounds", NULL);
                 register_directory_callback (manager, p, NULL);
                 g_free (p);
         }
 
-        /* ... and globally. */
-        if (!(dd = g_getenv ("XDG_DATA_DIRS")) || *dd == 0)
-                dd = "/usr/local/share:/usr/share";
-
-        ps = g_strsplit (dd, ":", 0);
-
-        for (k = ps; *k; ++k)
-                register_directory_callback (manager, *k, NULL);
-
-        g_strfreev (ps);
-
         gnome_settings_profile_end (NULL);
 
         return TRUE;



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