#!/usr/bin/env python
# 
# Copyright 2013 Canonical Ltd.
# 
# This file is part of python-ubuntu-platform-api.
# 
# python-upa 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; version 3. 
# 
# python-upa 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/>.

from functools import partial
from time import sleep

import upa

def generic_callback(name, *args):
    print "Session %s" % name
    print args


if __name__ == '__main__':
    upa.set_session_requested_callback(partial(generic_callback, "requested"))
    upa.set_session_born_callback(partial(generic_callback, "born"))
    upa.set_session_focused_callback(partial(generic_callback, "focused"))
    upa.set_session_unfocused_callback(partial(generic_callback, "unfocused"))
    upa.set_session_died_callback(partial(generic_callback, "died"))
    upa.start_monitoring()
    while True:
        try:
            sleep(1)
        except KeyboardInterrupt:
            exit(0)
