#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# 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 2
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
# Authors: Quinn Storm (quinn@beryl-project.org)
#          Patrick Niklaus (marex@opencompositing.org)
# Copyright (C) 2007 Quinn Storm

from optparse import OptionParser
import pygtk
pygtk.require('2.0')
import gtk

try:
    import sexy
    has_sexy = True
except ImportError:
    print "Info: No sexy-python package found, don't worry it's optional."
    has_sexy = False

if gtk.pygtk_version < (2,10,0):
    print "PyGtk 2.10.0 or later required"
    raise SystemExit

import compizconfig
import ccm
from ccm.Utils import GlobalUpdater
from ccm.Constants import Version

plugin   = None
category = None
parser   = OptionParser()
parser.add_option("-p", "--plugin", dest = "plugin",
                  help = "Directly jump to the page of PLUGIN",
                  metavar = "PLUGIN")
parser.add_option("-c", "--category", dest = "category",
                  help = "Directly jump to CATEGORY",
                  metavar = "CATEGORY")
parser.add_option("-v", "--version", dest = "version",
                  action = "store_true",
                  help = "Version")
(options, args) = parser.parse_args()
if options.version:
    print "CCSM %s" % Version
    raise SystemExit
if options.plugin:
    plugin = options.plugin
if options.category:
    category = options.category

screens = ccm.getScreens()
context = compizconfig.Context(screens)
GlobalUpdater.SetContext (context)
mainWin = ccm.MainWin(context, plugin, category)
idle = ccm.IdleSettingsParser(context)
mainWin.show_all()

gtk.main()
