#!/usr/bin/env python2.5

# carman-evas.py - Main application
#
# Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import sys
sys.path.insert(0, "")

from common.carlog import setup as log_setup, INFO
log_setup()
INFO('Starting %s' % sys.argv[0])

import ecore.evas, edje
from main.mainview import MainView
from models.kbmodel import KeyBoardModel
from gauges.gaugesctrl import GaugesController

metric = True

def esc_cb():
    gauges.finalize()
    ecore.main_loop_quit()

def backslash_cb():
    global metric

    metric = not metric
    gauges.set_unit_system(metric)

def f10_cb():
    gauges.deactivate()
    gauges.set_theme("../../themes/eclipse/theme.edj")
    gauges.activate()

def f11_cb():
    gauges.deactivate()
    gauges.set_theme("../../themes/tuning/theme.edj")
    gauges.activate()

def f12_cb():
    gauges.deactivate()
    gauges.set_theme("../../themes/offroad/theme.edj")
    gauges.activate()

view = MainView()
kb = KeyBoardModel()
kb.set_default_key_down_cb("Escape", esc_cb)
kb.set_default_key_down_cb("backslash", backslash_cb)
kb.set_default_key_down_cb("F10", f10_cb)
kb.set_default_key_down_cb("F11", f11_cb)
kb.set_default_key_down_cb("F12", f12_cb)

gauges = GaugesController(None, view.get_evas_canvas(),
    "../../themes/offroad/theme.edj")
gauges.activate()

ecore.main_loop_begin()
