#!/usr/bin/env python2.5

#  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
#
#  This file is part of carman-python.
#
#  carman-python 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.
#
#  carman-python 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
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 maps.mapsctrl import MapsController

metric = True

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

def backslash_cb():
    global metric

    metric = not metric
    maps.set_unit_system(metric)

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

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

def f12_cb():
    maps.deactivate()
    maps.set_theme("../themes/offroad/theme.edj")
    maps.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)

maps = MapsController(None, view.get_evas_canvas(),
    "../themes/offroad/theme.edj")
maps.activate()

ecore.main_loop_begin()
