Use $XDG_DATA_HOME/icons for icon theme install, not ~/.icons
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 30 May 2015 16:16:34 +0000 (19:16 +0300)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 30 May 2015 18:01:22 +0000 (21:01 +0300)
The XDG specification was updated back in 2012, we should conform with it.
GTK3 already uses that path as preferred one.

src/icon-theme.c
src/icon-theme.h
src/lxappearance.c
src/utils.c

index eacd339..7fba616 100644 (file)
@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include "utils.h"
 
-char** icon_theme_dirs = NULL;
+static char** icon_theme_dirs = NULL;
 
 gint icon_theme_cmp_name(IconTheme* t, const char* name)
 {
index 46ab1d7..7ba2ac1 100644 (file)
@@ -26,7 +26,7 @@
 
 G_BEGIN_DECLS
 
-extern char** icon_theme_dirs;
+//extern char** icon_theme_dirs;
 
 typedef struct
 {
index 718fafe..1550049 100644 (file)
@@ -124,10 +124,12 @@ static gboolean verify_cursor_theme(GKeyFile *kf, const char *cursor_theme,
     ret = g_key_file_load_from_file(kf, fpath, 0, NULL);
     g_free(fpath);
 
-    fpath = g_build_filename("icons", cursor_theme, "index.theme", NULL);
     if (!ret)
+    {
+        fpath = g_build_filename("icons", cursor_theme, "index.theme", NULL);
         ret = g_key_file_load_from_data_dirs(kf, fpath, NULL, 0, NULL);
-    g_free(fpath);
+        g_free(fpath);
+    }
 
     if (ret)
     {
index bd13ab7..09d356d 100644 (file)
@@ -116,7 +116,8 @@ static void insert_theme_to_models(IconTheme* theme)
 static gboolean install_icon_theme_package(const char* package_path)
 {
     GPid pid = -1;
-    const char* user_icons_dir = icon_theme_dirs[0];
+    /* Use new XDG path $XDG_DATA_HOME/icons to install icons theme */
+    char* user_icons_dir = g_build_filename(g_get_user_data_dir(), "icons", NULL);
     char* tmp_dir = g_build_filename(user_icons_dir, "tmp.XXXXXX", NULL);
     const char* argv[]= {
         "tar",
@@ -129,10 +130,15 @@ static gboolean install_icon_theme_package(const char* package_path)
     };
 
     if(g_mkdir_with_parents(user_icons_dir, 0700) == -1)
-        return FALSE;
+        goto _failed;
 
     if(!mkdtemp(tmp_dir))
+    {
+_failed:
+        g_free(user_icons_dir);
+        g_free(tmp_dir);
         return FALSE;
+    }
 
     if(g_str_has_suffix(package_path, ".tar.gz"))
         argv[1] = "--gzip";
@@ -159,7 +165,7 @@ static gboolean install_icon_theme_package(const char* package_path)
             load_icon_themes_from_dir(user_icons_dir, tmp_dir, kf);
             g_key_file_free(kf);
 
-            /* now really move this themes to ~/.icons dir and also update the GUI */
+            /* now really move this themes to $XDG_DATA_HOME/icons dir and also update the GUI */
             dir = g_dir_open(tmp_dir, 0, NULL);
             if(dir)
             {
@@ -175,7 +181,7 @@ static gboolean install_icon_theme_package(const char* package_path)
                         char* theme_target = g_build_filename(user_icons_dir, name, NULL);
                         if(g_rename(theme_tmp, theme_target) == 0)
                         {
-                            /* the theme is already installed to ~/.icons */
+                            /* the theme is now installed to $XDG_DATA_HOME/icons */
                             GSList* l= g_slist_find_custom(app.icon_themes, name, (GCompareFunc)icon_theme_cmp_name);
                             if(l)
                             {
@@ -204,6 +210,7 @@ static gboolean install_icon_theme_package(const char* package_path)
     }
 
 _out:
+    g_free(user_icons_dir);
     g_free(tmp_dir);
     return (pid != -1);
 }