[buoh] Respect XDG directory specification



commit 438eccd42c96e6c3ef778674c5aec8ee7f895636
Author: Jan Tojnar <jtojnar gmail com>
Date:   Sat Feb 2 16:16:10 2019 +0100

    Respect XDG directory specification
    
    - store cache files to $XDG_CACHE_HOME/buoh
    - store configuration to $XDG_CONFIG_HOME/buoh
    - if the legacy $HOME/.buoh exists, use that for configuration
    
    No migration step was added, users will need to migrate manually
    if they want to.

 data/org.gnome.buoh.appdata.xml.in | 1 +
 src/buoh-application.c             | 7 ++++++-
 src/buoh-comic-cache.c             | 4 +++-
 3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.buoh.appdata.xml.in b/data/org.gnome.buoh.appdata.xml.in
index 7b30eb2..4cc1022 100644
--- a/data/org.gnome.buoh.appdata.xml.in
+++ b/data/org.gnome.buoh.appdata.xml.in
@@ -25,6 +25,7 @@
          <li>Updated GTK stuff</li>
          <li>Updated buoh.dia UML diagram</li>
          <li>Added different sizes icons</li>
+         <li>Added support for XDG directory specification; feel free to move your configuration to 
$XDG_CONFIG_HOME/buoh</li>
       </ul>
     </description>
   </release>
diff --git a/src/buoh-application.c b/src/buoh-application.c
index 1bb19d9..803a035 100644
--- a/src/buoh-application.c
+++ b/src/buoh-application.c
@@ -364,7 +364,7 @@ buoh_application_create_user_dir (BuohApplication *buoh)
 
         g_free (filename);
 
-        cache_dir = g_build_filename (buoh->datadir, "cache", NULL);
+        cache_dir = g_build_filename (g_get_user_cache_dir (), "buoh", NULL);
 
         if (!g_file_test (cache_dir, G_FILE_TEST_IS_DIR)) {
                 buoh_debug ("Cache directory doesn't exist, creating it ...");
@@ -379,7 +379,12 @@ buoh_application_create_user_dir (BuohApplication *buoh)
 static void
 buoh_application_init (BuohApplication *buoh)
 {
+        // If legacy path exists, use that
         buoh->datadir = g_build_filename (g_get_home_dir (), ".buoh", NULL);
+        if (!g_file_test (buoh->datadir, G_FILE_TEST_IS_DIR)) {
+                g_free (buoh->datadir);
+                buoh->datadir = g_build_filename (g_get_user_config_dir (), "buoh", NULL);
+        }
         buoh_application_create_user_dir (buoh);
 
         buoh->comic_list = buoh_application_create_model_from_file (buoh);
diff --git a/src/buoh-comic-cache.c b/src/buoh-comic-cache.c
index 4121d22..9aa3d3a 100644
--- a/src/buoh-comic-cache.c
+++ b/src/buoh-comic-cache.c
@@ -52,7 +52,9 @@ static void
 buoh_comic_cache_init (BuohComicCache *buoh_comic_cache)
 {
         buoh_comic_cache->cache_dir =
-                g_build_filename (buoh_application_get_datadir (buoh_application_get_instance ()), "cache", 
NULL);
+                g_build_filename (g_get_user_cache_dir (),
+                                  "buoh",
+                                  NULL);
 
         buoh_comic_cache->image_hash =
                 g_hash_table_new_full (g_str_hash,


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