#! /usr/bin/env python

# glChess is a 2D/3D chess game for GNOME. This is the startup
# script which imports the relevant modules. Please keep the startup
# script in sync between glChess and gnome-sudoku.
#
# Copyright (c) 2008  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('glchess')
except:
  #No bugbuddy support
  pass

import sys
installed_mode = True

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:
    try:
      # Import glChess from pyexecdir or system installation.
      installed_mode = True
      import sys
      if "/home/thomas/newsvn/test/lib/python2.5/site-packages" not in sys.path:
          sys.path.insert(0, "/home/thomas/newsvn/test/lib/python2.5/site-packages")
      from glchess.glchess import start_game

    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('/home/thomas/newsvn/test', '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()
