[gnome-games/glchess-vala] Load data from installed location
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/glchess-vala] Load data from installed location
- Date: Sat, 11 Dec 2010 04:23:58 +0000 (UTC)
commit b2cab31b4650b044d34bd4e5771445db236791c3
Author: Robert Ancell <robert ancell canonical com>
Date: Sat Dec 11 15:23:04 2010 +1100
Load data from installed location
glchess/src/Makefile.am | 8 ++++++--
glchess/src/chess-view-2d.vala | 2 +-
glchess/src/chess-view-3d.vala | 12 ++++++------
glchess/src/config.vapi | 26 ++++++++++++++++++++++++++
glchess/src/glchess.vala | 6 +++---
5 files changed, 42 insertions(+), 12 deletions(-)
---
diff --git a/glchess/src/Makefile.am b/glchess/src/Makefile.am
index 6ed8d92..7e5df58 100644
--- a/glchess/src/Makefile.am
+++ b/glchess/src/Makefile.am
@@ -15,6 +15,7 @@ glchess_SOURCES = \
chess-view-options.vala
glchess_CFLAGS = \
+ -DPKGDATADIR=\"@datadir@/glchess\" \
$(GMODULE_CFLAGS) \
$(GTK_CFLAGS) \
$(GDK_X11_CFLAGS) \
@@ -37,12 +38,15 @@ glchess_VALAFLAGS = \
--pkg gtk+-3.0 \
--pkg gdk-x11-3.0 \
--pkg gmodule-2.0 \
- --pkg glx \
--pkg librsvg-2.0 \
--pkg posix \
--vapidir . \
+ --pkg config \
--pkg gl \
- --pkg glu
+ --pkg glu \
+ --pkg glx
+
+EXTRA_DIST = config.vapi gl.vapi glu.vapi glx.vapi
DISTCLEANFILES = \
Makefile.in
diff --git a/glchess/src/chess-view-2d.vala b/glchess/src/chess-view-2d.vala
index 5a9e375..caae57f 100644
--- a/glchess/src/chess-view-2d.vala
+++ b/glchess/src/chess-view-2d.vala
@@ -175,7 +175,7 @@ private class ChessView2D : ChessView
Rsvg.Handle handle;
try
{
- handle = new Rsvg.Handle.from_file ("data/pieces/" + options.theme_name + "/" + file_name + ".svg");
+ handle = new Rsvg.Handle.from_file (Path.build_filename (Config.PKGDATADIR, "pieces", options.theme_name, file_name + ".svg", null));
}
catch (GLib.Error e)
{
diff --git a/glchess/src/chess-view-3d.vala b/glchess/src/chess-view-3d.vala
index 7b881d8..b83d6b2 100644
--- a/glchess/src/chess-view-3d.vala
+++ b/glchess/src/chess-view-3d.vala
@@ -43,12 +43,12 @@ private class ChessView3D : ChessView
double_buffered = false;
try
{
- pawn_model = new TDSModel (File.new_for_path ("data/pieces/3d/pawn.3ds"));
- knight_model = new TDSModel (File.new_for_path ("data/pieces/3d/knight.3ds"));
- bishop_model = new TDSModel (File.new_for_path ("data/pieces/3d/bishop.3ds"));
- rook_model = new TDSModel (File.new_for_path ("data/pieces/3d/rook.3ds"));
- queen_model = new TDSModel (File.new_for_path ("data/pieces/3d/queen.3ds"));
- king_model = new TDSModel (File.new_for_path ("data/pieces/3d/king.3ds"));
+ pawn_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "pawn.3ds", null)));
+ knight_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "knight.3ds", null)));
+ bishop_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "bishop.3ds", null)));
+ rook_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "rook.3ds", null)));
+ queen_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "queen.3ds", null)));
+ king_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "king.3ds", null)));
}
catch (GLib.Error e)
{
diff --git a/glchess/src/config.vapi b/glchess/src/config.vapi
new file mode 100644
index 0000000..ff1b2c8
--- /dev/null
+++ b/glchess/src/config.vapi
@@ -0,0 +1,26 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- *//*
+ * Copyright (C) 2009 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * idst under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by Neil Jagdish Patel <neil patel canonical com>
+ *
+ */
+
+[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
+namespace Config
+{
+ public const string PKGDATADIR;
+ public const string GETTEXT_PACKAGE;
+ public const string VERSION;
+}
diff --git a/glchess/src/glchess.vala b/glchess/src/glchess.vala
index 8575905..3476e27 100644
--- a/glchess/src/glchess.vala
+++ b/glchess/src/glchess.vala
@@ -44,7 +44,7 @@ public class Application
builder = new Gtk.Builder ();
try
{
- builder.add_from_file ("data/glchess.ui");
+ builder.add_from_file (Path.build_filename (Config.PKGDATADIR, "glchess.ui", null));
}
catch (GLib.Error e)
{
@@ -225,7 +225,7 @@ public class Application
public void start ()
{
- ai_profiles = load_ai_profiles ("data/engines.conf");
+ ai_profiles = load_ai_profiles (Path.build_filename (Config.PKGDATADIR, "engines.conf", null));
foreach (var profile in ai_profiles)
GLib.message ("Detected AI profile %s", profile.name);
@@ -609,7 +609,7 @@ public class Application
preferences_builder = new Gtk.Builder ();
try
{
- preferences_builder.add_from_file ("data/preferences.ui");
+ preferences_builder.add_from_file (Path.build_filename (Config.PKGDATADIR, "preferences.ui", null));
}
catch (GLib.Error e)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]