pcremote-client-n8x0 -> client sources
[remotepc] / pcremote-client-n8x0-60 / debian / pcremote-client / usr / share / pcremote-client / screenmanager.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # ****************************************************************************
5 # Copyright (c) 2008 INdT/Fucapi.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 #  This program is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU Lesser General Public License for more details.
15
16 #  You should have received a copy of the GNU Lesser General Public License
17 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 # ============================================================================
20 # Project Name :PC Remote
21 # Author       :AndrĂ© Portela
22 # Email        :andre_portela_@hotmail.com
23 # Version      :1.0
24 # Module       :main
25 # Class        :PCRemote ScreenManager handles the finite state machine which
26 #               controls the navigation between screens.
27 # ============================================================================
28
29 from edje_objects import *
30 import os
31 import sys
32
33 class ScreenManager(object):
34     '''
35     classdocs
36     '''
37     def __init__(self, main, tablet, slide, player, torrent,socket):
38         '''
39         Constructor
40         '''
41         self.main = main
42         self.tablet = tablet
43         self.slide = slide
44         self.player = player
45         self.torrent = torrent
46         self.sock = socket
47         main.signal_callback_add("mouse,up,1", "Tablet",self.run_tablet)
48         main.signal_callback_add("mouse,up,1", "Slideshow",self.run_slide)
49         main.signal_callback_add("mouse,up,1", "Player",self.run_player)
50         main.signal_callback_add("mouse,up,1", "Torrent",self.run_torrent)
51
52     def run_tablet(self, edje, emission, source):
53         self.sock.send_message(source+":#start")
54         print 'entrou no tablet'
55         #main edje object
56         edje.focus_set(False)
57         edje.hide()
58         if self.tablet is None:
59             edje_file = os.path.join(os.path.dirname(sys.argv[0]), "tablet.edj")
60             self.tablet = TabletScreen(edje.canvas_class, edje_file, 'main', 'tablet', self.sock)
61             self.tablet.signal_callback_add("mouse,up,1","tablet_bt-voltar_area",self.tablet_back)
62         self.tablet.part_text_set('pc_name',edje.sock_address)
63         self.tablet.show()
64         self.tablet.focus_set(True)
65
66     def tablet_back(self, edje, emission, source):
67         #tablet edje object
68         edje.focus_set(False)
69         edje.hide()
70         self.sock.send_message("Tablet:#stop")
71         self.main.show()
72         self.main.focus_set(True)
73
74     def run_slide(self, edje, emission, source):
75         self.sock.send_message(source+":#start")
76         print 'entrou no slide'
77         #main edje object
78         edje.focus_set(False)
79         edje.hide()
80         if self.slide is None:
81             edje_file = os.path.join(os.path.dirname(sys.argv[0]), "slide.edj")
82             self.slide = SlideScreen(edje.canvas_class, edje_file, 'main', 'slide', self.sock)
83             self.slide.signal_callback_add("unselected","slide_bt-voltar",self.slide_back)
84         #self.slide.part_text_set('pc_name',edje.sock_address)
85         #this rotates the screen 90 degrees (to fit text in vertical orientation)
86         #self.slide.x11.rotation_set(90)
87         self.slide.show()
88         self.slide.focus_set(True)
89
90     def slide_back(self, edje, emission, source):
91         #slide edje object
92         edje.focus_set(False)
93         edje.hide()
94         self.sock.send_message("Slideshow:#stop")
95         #this rotates the screen from 90 to 0 degrees (to fit text in horizontal orientation again)
96         #self.main.x11.rotation_set(0)
97         self.main.show()
98         self.main.focus_set(True)
99
100     def run_player(self, edje, emission, source):
101         print 'not implemented yet'
102
103     def player_back(self, edje, emission, source):
104         print 'not implemented yet'
105
106     def run_torrent(self, edje, emission, source):
107         print 'not implemented yet'
108
109     def torrent_back(self, edje, emission, source):
110         print 'not implemented yet'
111