Don't use $sysconfdir but XDG_CONFIG_DIRS should be used for search.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 22 Aug 2014 13:02:16 +0000 (16:02 +0300)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 22 Aug 2014 13:02:16 +0000 (16:02 +0300)
src/Makefile.am
src/configurator.c
src/panel.c
src/private.h

index 9274085..a70bb3e 100644 (file)
@@ -6,7 +6,6 @@ lxpanel_CFLAGS = \
        -I$(top_srcdir) \
        -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
        -DPACKAGE_DATA_DIR=\""$(datadir)/lxpanel"\" \
-       -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)/xdg/lxpanel"\" \
        -DPACKAGE_UI_DIR=\""$(datadir)/lxpanel/ui"\" \
        -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
        -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
index 1e5d020..cd859e4 100644 (file)
@@ -1546,16 +1546,23 @@ GtkWidget* create_generic_config_dlg( const char* title, GtkWidget* parent,
 void load_global_config()
 {
     GKeyFile* kf = g_key_file_new();
-    char* file = _old_system_config_file_name("config");
+    char* file = NULL;
     gboolean loaded = FALSE;
+    const gchar * const * dir = g_get_system_config_dirs();
 
     /* try to load system config file first */
-    if (g_key_file_load_from_file(kf, file, 0, NULL))
-        loaded = TRUE;
-    else /* fallback to old config place for backward compatibility */
+    if (dir) while (dir[0] && !loaded)
+    {
+        g_free(file);
+        file = _system_config_file_name(dir[0], "config");
+        if (g_key_file_load_from_file(kf, file, 0, NULL))
+            loaded = TRUE;
+        dir++;
+    }
+    if (!loaded) /* fallback to old config place for backward compatibility */
     {
         g_free(file);
-        file = _system_config_file_name("config");
+        file = _old_system_config_file_name("config");
         if (g_key_file_load_from_file(kf, file, 0, NULL))
             loaded = TRUE;
     }
index ff79c82..c3ffc1d 100644 (file)
@@ -1710,6 +1710,7 @@ static void _start_panels_from_dir(const char *panel_dir)
 static gboolean start_all_panels( )
 {
     char *panel_dir;
+    const gchar * const * dir;
 
     /* try user panels */
     panel_dir = _user_config_file_name("panels", NULL);
@@ -1717,12 +1718,17 @@ static gboolean start_all_panels( )
     g_free(panel_dir);
     if (all_panels != NULL)
         return TRUE;
-    /* else try XDG fallback */
-    panel_dir = _system_config_file_name("panels");
-    _start_panels_from_dir(panel_dir);
-    g_free(panel_dir);
-    if (all_panels != NULL)
-        return TRUE;
+    /* else try XDG fallbacks */
+    dir = g_get_system_config_dirs();
+    if (dir) while (dir[0])
+    {
+        panel_dir = _system_config_file_name(dir[0], "panels");
+        _start_panels_from_dir(panel_dir);
+        g_free(panel_dir);
+        if (all_panels != NULL)
+            return TRUE;
+        dir++;
+    }
     /* last try at old fallback for compatibility reasons */
     panel_dir = _old_system_config_file_name("panels");
     _start_panels_from_dir(panel_dir);
index 136d0d1..4548cf5 100644 (file)
@@ -163,9 +163,9 @@ int str2num(pair *p, const gchar *str, int defval);
 const gchar *num2str(pair *p, int num, const gchar *defval);
 
 #ifdef __LXPANEL_INTERNALS__
-static inline char *_system_config_file_name(const char *file_name)
+static inline char *_system_config_file_name(const char *dir, const char *file_name)
 {
-    return g_build_filename(PACKAGE_SYSCONF_DIR, cprofile, file_name, NULL);
+    return g_build_filename(dir, cprofile, file_name, NULL);
 }
 
 static inline char *_old_system_config_file_name(const char *file_name)