#!/usr/bin/python
# Copyright (c) 2004, 2005, 2006, 2007 Tom Hinkle
# You may use and distribute this software under the terms of the
# GNU General Public License, version 2 or later

#import sys
#import signal
#signal.signal(signal.SIGINT, signal.SIG_DFL)
import sys, os, os.path, glob

for desktop_file in glob.glob('lib/plugins/*plugin.in') + glob.glob('lib/plugins/*/*plugin.in'):
    os.system('intltool-merge -d i18n/ %s %s'%(desktop_file,
                                               desktop_file[:-3])
              )

if os.path.exists('foo'):
    os.remove('foo/gourmet')
    os.rmdir('foo')

os.mkdir('foo')
os.symlink(os.path.abspath('lib'),'foo/gourmet')
sys.path = [os.path.abspath('foo')] + sys.path
sys.argv.append('--data-directory=%s'%os.path.abspath('../data/'))
sys.argv.append('--glade-directory=%s'%os.path.abspath('../glade/'))
sys.argv.append('--image-directory=%s'%os.path.abspath('../images/'))

from gourmet.OptionParser import *

def thread_debug ():
    print 'THREADING DEBUG INFO: ',threading.enumerate()
    t=threading.Timer(options.thread_debug_interval,thread_debug)
    print '(starting timer: ',t,')'
    t.terminate = lambda *args: t.cancel()
    t.start()
    
if options.thread_debug:
    import threading
    thread_debug()
elif options.psyco:
    try:
        import psyco
        psyco.full()
    except ImportError:
        # ignore
        pass

import gourmet.GourmetRecipeManager
gourmet.GourmetRecipeManager.startGUI()
#for mod in sys.modules:
#    print mod,sys.modules[mod]
