[gnome-games] Load background image from correct location



commit 3f86e977134a73070ca3943c564e620fed543702
Author: Robert Ancell <robert ancell gmail com>
Date:   Sat Apr 24 08:53:26 2010 +1000

    Load background image from correct location

 glchess/src/lib/defaults.py.in          |    4 ++++
 glchess/src/lib/scene/cairo/__init__.py |    8 ++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/glchess/src/lib/defaults.py.in b/glchess/src/lib/defaults.py.in
index 997ccdb..85d475f 100644
--- a/glchess/src/lib/defaults.py.in
+++ b/glchess/src/lib/defaults.py.in
@@ -14,8 +14,10 @@ root_dir = os.path.dirname(__file__)
 if not os.path.exists(os.path.join(root_dir, 'Makefile.am')):
     # Running in installed mode
     APP_DATA_DIR     = os.path.join('@prefix@', 'share')
+    SHARED_DATA_DIR  = os.path.join(APP_DATA_DIR, 'gnome-games')
     BASE_DIR         = os.path.join(APP_DATA_DIR, 'glchess')
     TEXTURE_DIR      = os.path.join(BASE_DIR, 'textures')
+    SHARED_IMAGE_DIR = os.path.join(SHARED_DATA_DIR, 'pixmaps')
     UI_DIR           = BASE_DIR
     LOCALEDIR        = os.path.join(APP_DATA_DIR, 'locale')
     DATA_DIR         = os.path.expanduser('~/.gnome2/glchess/')
@@ -29,7 +31,9 @@ if not os.path.exists(os.path.join(root_dir, 'Makefile.am')):
 else:
     # Running in uninstalled mode
     APP_DATA_DIR     = os.path.join(root_dir, '../../data')
+    SHARED_DATA_DIR  = '.'
     TEXTURE_DIR      = os.path.join(root_dir, '../../textures')
+    SHARED_IMAGE_DIR = os.path.join(SHARED_DATA_DIR, 'pixmaps')
     UI_DIR           = os.path.join(root_dir, '../../data')
     BASE_DIR         = os.path.join(root_dir, '../../data')
     LOCALEDIR        = os.path.join(APP_DATA_DIR, 'locale')
diff --git a/glchess/src/lib/scene/cairo/__init__.py b/glchess/src/lib/scene/cairo/__init__.py
index f951ef7..a248f38 100644
--- a/glchess/src/lib/scene/cairo/__init__.py
+++ b/glchess/src/lib/scene/cairo/__init__.py
@@ -4,6 +4,7 @@ import os.path
 import math
 import cairo
 import rsvg
+import gobject
 import gtk.gdk
 
 import glchess.scene
@@ -193,8 +194,11 @@ class Scene(glchess.scene.Scene):
         self.redrawStatic    = True
         self.showNumbering   = False
         self.faceToFace      = False
-        pixbuf = gtk.gdk.pixbuf_new_from_file('/home/bob/git/gnome-games/build/share/gnome-games/pixmaps/baize.png')
-        (self.background_pixmap, _) = pixbuf.render_pixmap_and_mask()
+        try:
+            pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(glchess.defaults.SHARED_IMAGE_DIR, 'baize.png'))
+            (self.background_pixmap, _) = pixbuf.render_pixmap_and_mask()
+        except gobject.GError:
+            self.background_pixmap = None
 
     def addChessPiece(self, chessSet, name, coord, feedback, style = 'simple'):
         """Add a chess piece model into the scene.



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