#!/usr/bin/env python2
 
#  Gnome15 - Suite of tools for the Logitech G series keyboards and headsets
#  Copyright (C) 2010 Brett Smith <tanktarta@blueyonder.co.uk>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
import os

# with pygobject-3.14.0 this seems to fix the import error
import gconf

# Allow running from local path
path = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "..")
if os.path.exists(path):
    sys.path.insert(0, path)

#Logging
import gnome15.g15logging as g15logging
logger = g15logging.get_root_logger()

# This is a work around - Now Gio is used in the lens plugin, it must be 
# initialised before GTK. 
try:
    from gi.repository import Gio
except Exception as a:
    logger.debug("Error when importing Gio", exc_info = a)
    pass

import pygtk
pygtk.require('2.0')
import gtk
import gconf
import gobject
gobject.threads_init()
       
# DBUS - Use to check current desktop service status or stop it
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from dbus.mainloop.glib import threads_init
dbus.mainloop.glib.threads_init()
DBusGMainLoop(set_as_default=True)

import gnome15.g15config as g15config
import gnome15.g15globals as g15globals
import gnome15.g15drivermanager as g15drivermanager

a = g15config.G15Config()
a.run()
