[gnome-games] application: Add Application.get_covers_dir()



commit f994061c002760a7c5503aba6f46610d4d1f81e7
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri May 13 09:07:52 2016 +0200

    application: Add Application.get_covers_dir()
    
    This will be used to cache covers fetched from the web.

 src/ui/application.vala |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 65ca8ee..e5bf86f 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -76,6 +76,29 @@ private class Games.Application : Gtk.Application {
                return @"$data_dir/snapshots";
        }
 
+       public static string get_cache_dir () {
+               var cache_dir = Environment.get_user_cache_dir ();
+
+               return @"$cache_dir/gnome-games";
+       }
+
+       public static string get_covers_dir () {
+               var cache_dir = get_cache_dir ();
+
+               return @"$cache_dir/covers";
+       }
+
+       public static void try_make_dir (string path) {
+               var file = File.new_for_path (path);
+               try {
+                       if (!file.query_exists ())
+                               file.make_directory_with_parents ();
+               }
+               catch (Error e) {
+                       warning (@"$(e.message)\n");
+               }
+       }
+
        protected override void activate () {
                Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
 


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