#! /usr/bin/env python

# GNOME Sudoku is a simple sudoku generator and player. Sudoku is a 
# japanese logic puzzle. This is the startup script which imports 
# the relevant modules. Please keep the startup script in sync 
# between glChess and gnome-sudoku.
#
# 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 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:
    try:
      # Import gnome-sudoku from pyexecdir or system installation.
      installed_mode = True
      from gnome_sudoku.gnome_sudoku import start_game

    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('/usr/local', '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()
