[gnome-chess] Look for AI profiles in two different locations



commit 7d55d4c51334c67274a54e3b2e9019e50d12104c
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri Feb 7 19:51:27 2014 -0600

    Look for AI profiles in two different locations
    
    We'll now search for AI profiles in:
    
    * ~/.config/gnome-chess/engines.conf (first)
    * /etc/gnome-chess/engines.conf
    
    I'm torn as to whether to continue reading /etc/chess-engines.conf. I
    think it'd be best to ignore it -- if users modified it manually to add
    an engine, they will notice that the engine has disappeared. They're not
    likely to notice that they're not getting the important GNUChess
    improvements I'm hoping to land soon....

 data/Makefile.am                          |    3 ++-
 data/{chess-engines.conf => engines.conf} |    0
 src/gnome-chess.vala                      |   10 +++++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index bf9016b..c420d57 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -20,7 +20,8 @@ dist_ui_DATA = \
 gsettings_SCHEMAS = org.gnome.gnome-chess.gschema.xml
 @GSETTINGS_RULES@
 
-dist_sysconf_DATA = chess-engines.conf
+pkgsysconfdir = $(sysconfdir)/gnome-chess
+dist_pkgsysconf_DATA = engines.conf
 
 dist_man_MANS = gnome-chess.6
 
diff --git a/data/chess-engines.conf b/data/engines.conf
similarity index 100%
rename from data/chess-engines.conf
rename to data/engines.conf
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 5214dd8..5e70780 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -167,7 +167,15 @@ public class Application : Gtk.Application
         settings.changed.connect (settings_changed_cb);
         settings_changed_cb (settings, "show-3d");
 
-        ai_profiles = AIProfile.load_ai_profiles (Path.build_filename (SYSCONFDIR, "chess-engines.conf", 
null));
+        var system_engine_cfg = Path.build_filename (SYSCONFDIR, "gnome-chess", "engines.conf", null);
+        var user_engine_cfg = Path.build_filename (Environment.get_user_config_dir (), "gnome-chess", 
"engines.conf", null);
+        if (FileUtils.test (user_engine_cfg, FileTest.EXISTS))
+            ai_profiles = AIProfile.load_ai_profiles (user_engine_cfg);
+        else if (FileUtils.test (system_engine_cfg, FileTest.EXISTS))
+            ai_profiles = AIProfile.load_ai_profiles (system_engine_cfg);
+        else
+            warning ("engines.conf not found");
+
         foreach (var profile in ai_profiles)
             debug ("Detected AI profile %s in %s", profile.name, profile.path);
 


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