#!/usr/bin/env python
'''
Creates an instance of the program GUI and starts the main event loop.

@author: Peter Parente
@author: Eitan Isaacson
@organization: IBM Corporation
@copyright: Copyright (c) 2006 IBM Corporation
@license: BSD

All rights reserved. This program and the accompanying materials are made 
available under the terms of the BSD which accompanies this distribution, and 
is available at U{http://www.opensource.org/licenses/bsd-license.php}
'''
import gi

import sys, os
# Load gail module no matter what the desktop-wide settings are.
os.environ['GTK_MODULES'] = 'gail:atk-bridge'
# make the ~/.accerciser directory part of the path to aid user imports
sys.path.append(os.path.join(os.environ['HOME'], '.accerciser'))
# We can't rely on prefix if we're installed by relocated RPM. Instead, we 
# use __file__ and for now hope that lib is relative to bin.
sys.prefix = '/usr'

# TODO: Remove completely gnome dependency
# make this program accessible
#
#import gnome
## make this program accessible
#props = { gnome.PARAM_APP_DATADIR : os.path.join(sys.prefix, 'share')}
#gnome.program_init('accerciser', '3.4.1', 
#                   properties=props, argv=['accerciser'] + sys.argv[1:])

from gi.repository import Gtk as gtk
# initialize threads
# get global icon resources
it = gtk.IconTheme()
try:
  icons = [it.load_icon('accerciser', size, gtk.IconLookupFlags.NO_SVG) 
           for size in (16, 22, 32)]
except Exception:
  # ignore errors, and just don't use the icon
  pass
else:
  # TODO: REVIEW
  gtk.Window.set_default_icon_list(icons)
  
import accerciser
accerciser.main()
