[gnome-games] lightsoff: Install data files into PKGDATADIR



commit 2f9601359fd217d05a9b02a3385c9230685e773f
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date:   Tue Dec 27 16:17:46 2011 +0100

    lightsoff: Install data files into PKGDATADIR

 lightsoff/src/Makefile.am    |    3 ++-
 lightsoff/src/config.vapi    |    9 +++++++--
 lightsoff/src/game-view.vala |   12 ++++++------
 lightsoff/src/lightsoff.vala |   11 +++++++++--
 4 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/lightsoff/src/Makefile.am b/lightsoff/src/Makefile.am
index 320240d..20f5ff0 100644
--- a/lightsoff/src/Makefile.am
+++ b/lightsoff/src/Makefile.am
@@ -11,7 +11,7 @@ lightsoff_SOURCES = \
 
 lightsoff_VALAFLAGS = \
 	--pkg posix \
-    --pkg gmodule-2.0 \
+	--pkg gmodule-2.0 \
 	--pkg clutter-gtk-1.0 \
 	--vapidir $(top_srcdir)/libgames-support \
 	--pkg GnomeGamesSupport-1.0
@@ -20,6 +20,7 @@ lightsoff_CFLAGS = \
 	-I$(top_srcdir)/libgames-support \
 	-DVERSION=\"$(VERSION)\" \
 	-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
+	-DPKGDATADIR=\""$(pkgdatadir)/lightsoff"\" \
 	$(GHTREAD_CFLAGS) \
 	$(GMODULE_CFLAGS) \
 	$(GTK_CFLAGS) \
diff --git a/lightsoff/src/config.vapi b/lightsoff/src/config.vapi
index 6477226..f697a31 100644
--- a/lightsoff/src/config.vapi
+++ b/lightsoff/src/config.vapi
@@ -1,2 +1,7 @@
-public const string VERSION;
-public const string GETTEXT_PACKAGE;
\ No newline at end of file
+[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/lightsoff/src/game-view.vala b/lightsoff/src/game-view.vala
index fce0ee4..77f2b0c 100644
--- a/lightsoff/src/game-view.vala
+++ b/lightsoff/src/game-view.vala
@@ -34,12 +34,12 @@ public class GameView : Clutter.Group
     {
         try
         {
-            backing_texture = new Clutter.Texture.from_file ("data/backing.svg");
-            highlight_texture = new Clutter.Texture.from_file ("data/highlight.svg");
-            off_texture = new Clutter.Texture.from_file ("data/off.svg");
-            on_texture = new Clutter.Texture.from_file ("data/on.svg");
-            led_back_texture = new Clutter.Texture.from_file ("data/led-back.svg");
-            arrow_texture = new Clutter.Texture.from_file ("data/arrow.svg");
+            backing_texture = new Clutter.Texture.from_file (Path.build_filename (Config.PKGDATADIR, "backing.svg"));
+            highlight_texture = new Clutter.Texture.from_file (Path.build_filename (Config.PKGDATADIR, "highlight.svg"));
+            off_texture = new Clutter.Texture.from_file (Path.build_filename (Config.PKGDATADIR, "off.svg"));
+            on_texture = new Clutter.Texture.from_file (Path.build_filename (Config.PKGDATADIR, "on.svg"));
+            led_back_texture = new Clutter.Texture.from_file (Path.build_filename (Config.PKGDATADIR, "led-back.svg"));
+            arrow_texture = new Clutter.Texture.from_file (Path.build_filename (Config.PKGDATADIR, "arrow.svg"));
         }
         catch (Clutter.TextureError e)
         {
diff --git a/lightsoff/src/lightsoff.vala b/lightsoff/src/lightsoff.vala
index a75c81b..299e54b 100644
--- a/lightsoff/src/lightsoff.vala
+++ b/lightsoff/src/lightsoff.vala
@@ -10,7 +10,14 @@ public class LightsOff
         settings = new Settings ("org.gnome.lightsoff");
 
         ui = new Gtk.Builder();
-        ui.add_from_file ("data/lightsoff.ui");
+        try
+        {
+            ui.add_from_file (Path.build_filename (Config.PKGDATADIR, "lightsoff.ui"));
+        }
+        catch (Error e)
+        {
+            warning ("Could not load UI: %s", e.message);
+        }
         ui.connect_signals (this);
 
         window = (Gtk.Window) ui.get_object ("game_window");
@@ -116,7 +123,7 @@ public class LightsOff
 
         Gtk.show_about_dialog (window,
                                "program-name", _("Lights Off"),
-                               "version", VERSION,
+                               "version", Config.VERSION,
                                "comments",
                                _("Turn off all the lights\n\nLights Off is a part of GNOME Games."),
                                "copyright", "Copyright \xa9 2009 Tim Horton",



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