gnome-games r7127 - in trunk: . glchess glchess/src glchess/src/lib gnome-sudoku gnome-sudoku/src gnome-sudoku/src/lib po



Author: andreasr
Date: Thu Jan 10 22:04:52 2008
New Revision: 7127
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7127&view=rev

Log:
Allow glChess and Sudoku to be executed from the source distribution
without being installed. To run, execute the 'glchess/src/glchess'
script. 


Added:
   trunk/glchess/src/glchess.in.in
   trunk/gnome-sudoku/src/gnome-sudoku.in.in
Removed:
   trunk/glchess/src/glchess.in
   trunk/gnome-sudoku/src/gnome-sudoku.in
Modified:
   trunk/configure.in
   trunk/glchess/ChangeLog
   trunk/glchess/src/lib/defaults.py.in
   trunk/gnome-sudoku/ChangeLog
   trunk/gnome-sudoku/src/lib/defaults.py.in
   trunk/po/POTFILES.in

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Jan 10 22:04:52 2008
@@ -840,6 +840,7 @@
 glchess/data/Makefile
 glchess/glade/Makefile
 glchess/help/Makefile
+glchess/src/glchess.in
 glchess/src/Makefile
 glchess/src/lib/Makefile
 glchess/src/lib/defaults.py
@@ -853,6 +854,7 @@
 glchess/src/lib/ui/Makefile
 glchess/textures/Makefile
 gnome-sudoku/Makefile
+gnome-sudoku/src/gnome-sudoku.in
 gnome-sudoku/src/Makefile
 gnome-sudoku/src/lib/Makefile
 gnome-sudoku/src/lib/defaults.py

Added: trunk/glchess/src/glchess.in.in
==============================================================================
--- (empty file)
+++ trunk/glchess/src/glchess.in.in	Thu Jan 10 22:04:52 2008
@@ -0,0 +1,52 @@
+#! /usr/bin/env python
+
+# Setup bugbuddy to report unhandled exceptions.
+try: 
+  import bugbuddy
+  bugbuddy.install('glchess')
+except:
+  #No bugbuddy support
+  pass
+
+import sys
+installed_mode = True
+
+try:
+    # Import glchess from system installation.
+    from glchess.glchess import start_game
+except ImportError:
+    import sys
+    if "@pyexecdir@" not in sys.path:
+        sys.path.insert(0, "@pyexecdir@")
+
+    try:
+	# Import glchess from system installation (with pyexecdir in path).
+        from glchess.glchess import start_game
+    except ImportError:
+
+      try:
+	  # Import glchess module from source distribution.
+          import lib;
+          sys.modules["glchess"] = sys.modules["lib"];
+          from glchess.glchess import start_game
+	  installed_mode = False
+      except ImportError:
+	  # Import of glchess failed. Show error message.
+          import gtk
+  	  import os.path
+	  import gettext
+          from gettext import gettext as _
+        
+	  gettext.bindtextdomain('gnome-games', os.path.join('@prefix@', 'share', 'locale'))
+	  gettext.textdomain('gnome-games')
+          title = _("Chess incorrectly installed")
+          description = _("""Chess is not able to start because required application files are not installed. If you are currently upgrading your system please wait until the upgrade has completed.""")
+          dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
+          dialog.format_secondary_text(description)
+          dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
+          dialog.run()
+          sys.exit(0)
+
+sys.modules["glchess"].installed_mode = installed_mode
+
+start_game()

Modified: trunk/glchess/src/lib/defaults.py.in
==============================================================================
--- trunk/glchess/src/lib/defaults.py.in	(original)
+++ trunk/glchess/src/lib/defaults.py.in	Thu Jan 10 22:04:52 2008
@@ -1,21 +1,35 @@
 # -*- coding: utf-8 -*-
 
-import os, os.path
+import sys, os, os.path
 import errno
 import gettext 
 
-APP_DATA_DIR     = os.path.join('@prefix@', 'share') 
-ICON_DIR         = os.path.join(APP_DATA_DIR, 'pixmaps')
-TEXTURE_DIR      = os.path.join(ICON_DIR, 'glchess')
-GLADE_DIR        = os.path.join(APP_DATA_DIR, 'glchess')
-BASE_DIR         = os.path.join(APP_DATA_DIR, 'glchess')
-LOCALEDIR        = os.path.join(APP_DATA_DIR, 'locale')
-DATA_DIR         = os.path.expanduser('~/.gnome2/glchess/')
-LOG_DIR          = os.path.join(DATA_DIR, 'logs')
-CONFIG_FILE      = os.path.join(DATA_DIR, 'config.xml')
-HISTORY_DIR      = os.path.join(DATA_DIR, 'history')
-UNFINISHED_FILE  = os.path.join(HISTORY_DIR, 'unfinished')
-LOCAL_AI_CONFIG  = os.path.join(DATA_DIR, 'ai.xml')
+if sys.modules["glchess"].installed_mode:
+    APP_DATA_DIR     = os.path.join('@prefix@', 'share') 
+    ICON_DIR         = os.path.join(APP_DATA_DIR, 'pixmaps')
+    TEXTURE_DIR      = os.path.join(ICON_DIR, 'glchess')
+    GLADE_DIR        = os.path.join(APP_DATA_DIR, 'glchess')
+    BASE_DIR         = os.path.join(APP_DATA_DIR, 'glchess')
+    LOCALEDIR        = os.path.join(APP_DATA_DIR, 'locale')
+    DATA_DIR         = os.path.expanduser('~/.gnome2/glchess/')
+    LOG_DIR          = os.path.join(DATA_DIR, 'logs')
+    CONFIG_FILE      = os.path.join(DATA_DIR, 'config.xml')
+    HISTORY_DIR      = os.path.join(DATA_DIR, 'history')
+    UNFINISHED_FILE  = os.path.join(HISTORY_DIR, 'unfinished')
+    LOCAL_AI_CONFIG  = os.path.join(DATA_DIR, 'ai.xml')
+else:
+    APP_DATA_DIR     = os.path.join('@abs_top_builddir@', 'glchess', 'data')
+    ICON_DIR         = os.path.join('@abs_top_builddir@', 'glchess', 'textures')
+    TEXTURE_DIR      = os.path.join('@abs_top_builddir@', 'glchess', 'textures')
+    GLADE_DIR        = os.path.join('@abs_top_builddir@', 'glchess', 'glade')
+    BASE_DIR         = os.path.join('@abs_top_builddir@', 'glchess', 'data')
+    LOCALEDIR        = os.path.join(APP_DATA_DIR, 'locale')
+    DATA_DIR         = os.path.expanduser('~/.gnome2/glchess/')
+    LOG_DIR          = os.path.join(DATA_DIR, 'logs')
+    CONFIG_FILE      = os.path.join(DATA_DIR, 'config.xml')
+    HISTORY_DIR      = os.path.join(DATA_DIR, 'history')
+    UNFINISHED_FILE  = os.path.join(HISTORY_DIR, 'unfinished')
+    LOCAL_AI_CONFIG  = os.path.join(DATA_DIR, 'ai.xml')
 
 DOMAIN = 'gnome-games'
 gettext.bindtextdomain(DOMAIN, LOCALEDIR)

Added: trunk/gnome-sudoku/src/gnome-sudoku.in.in
==============================================================================
--- (empty file)
+++ trunk/gnome-sudoku/src/gnome-sudoku.in.in	Thu Jan 10 22:04:52 2008
@@ -0,0 +1,55 @@
+#! /usr/bin/env python
+# Copyright (c) 2005 Tom Hinkle You may use and distribute this
+# software under the terms of the GNU General Public License, version
+# 2 or later
+
+# Setup bugbuddy to report unhandled exceptions.
+try: 
+  import bugbuddy
+  bugbuddy.install('gnome-sudoku')
+except:
+  #No bugbuddy support
+  pass 
+
+import sys
+installed_mode = True
+
+try:
+    # Import gnome-sudoku from system installation.
+    from gnome_sudoku.gnome_sudoku import start_game
+except ImportError:
+    import sys
+    if "@pyexecdir@" not in sys.path:
+        sys.path.insert(0, "@pyexecdir@")
+
+    try:
+	# Import gnome-sudoku from system installation (with pyexecdir in path).
+        from gnome_sudoku.gnome_sudoku import start_game
+    except ImportError:
+
+      try:
+	  # Import gnome_sudoku module from source distribution.
+          import lib;
+          sys.modules["gnome_sudoku"] = sys.modules["lib"];
+          from gnome_sudoku.gnome_sudoku import start_game
+	  installed_mode = False
+      except ImportError:
+	  # Import of gnome-sudoku failed. Show error message.
+          import gtk
+  	  import os.path
+	  import gettext
+          from gettext import gettext as _
+        
+	  gettext.bindtextdomain('gnome-games', os.path.join('@prefix@', 'share', 'locale'))
+	  gettext.textdomain('gnome-games')
+          title = _("Sudoku incorrectly installed")
+          description = _("""Sudoku is not able to start because required application files are not installed. If you are currently upgrading your system please wait until the upgrade has completed.""")
+          dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
+          dialog.format_secondary_text(description)
+          dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
+          dialog.run()
+          sys.exit(0)
+
+sys.modules["gnome_sudoku"].installed_mode = installed_mode
+
+start_game()

Modified: trunk/gnome-sudoku/src/lib/defaults.py.in
==============================================================================
--- trunk/gnome-sudoku/src/lib/defaults.py.in	(original)
+++ trunk/gnome-sudoku/src/lib/defaults.py.in	Thu Jan 10 22:04:52 2008
@@ -2,11 +2,18 @@
 import errno
 import gettext
 
-APP_DATA_DIR = os.path.join('@prefix@', 'share') 
-IMAGE_DIR = os.path.join(APP_DATA_DIR, 'pixmaps', 'gnome-sudoku')
-LOCALEDIR = os.path.join(APP_DATA_DIR, 'locale')
-GLADE_DIR = os.path.join(APP_DATA_DIR,'gnome-sudoku')
-BASE_DIR = os.path.join(APP_DATA_DIR,'gnome-sudoku')
+if sys.modules["glchess"].installed_mode:
+    APP_DATA_DIR = os.path.join('@prefix@', 'share') 
+    IMAGE_DIR = os.path.join(APP_DATA_DIR, 'pixmaps', 'gnome-sudoku')
+    LOCALEDIR = os.path.join(APP_DATA_DIR, 'locale')
+    GLADE_DIR = os.path.join(APP_DATA_DIR,'gnome-sudoku')
+    BASE_DIR = os.path.join(APP_DATA_DIR,'gnome-sudoku')
+else:
+    APP_DATA_DIR = os.path.join('@abs_top_builddir@', 'gnome-sudoku', 'data') 
+    IMAGE_DIR = os.path.join('@abs_top_builddir@', 'glchess', 'images')
+    LOCALEDIR = os.path.join(APP_DATA_DIR, 'locale')
+    GLADE_DIR = os.path.join('@abs_top_builddir@', 'gnome-sudoku', 'glade')
+    BASE_DIR = os.path.join('@abs_top_builddir@', 'gnome-sudoku', 'data') 
 
 DOMAIN = 'gnome-games'
 gettext.bindtextdomain(DOMAIN, LOCALEDIR)

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Thu Jan 10 22:04:52 2008
@@ -136,7 +136,7 @@
 glchess/glade/glchess.glade
 glchess/glade/new_game.glade
 glchess/glchess.desktop.in.in
-glchess/src/glchess.in
+glchess/src/glchess.in.in
 glchess/src/lib/gtkui/__init__.py
 glchess/src/lib/gtkui/dialogs.py
 glchess/src/lib/gtkui/gtkui.py
@@ -225,7 +225,7 @@
 gnome-sudoku/glade/puzzle_generator.glade
 gnome-sudoku/glade/select_game.glade
 gnome-sudoku/glade/tracker.glade
-gnome-sudoku/src/gnome-sudoku.in
+gnome-sudoku/src/gnome-sudoku.in.in
 gnome-sudoku/src/lib/simple_debug.py
 gnome-sudoku/src/lib/colors.py
 gnome-sudoku/src/lib/sudoku_maker.py



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