Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TamTam.py
blob: b77d4d8ce2e3f38b1d776cd6ab352317071823a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import pygtk
pygtk.require( '2.0' )
import gtk


from Framework.Constants import Constants
from Framework.CSound.CSoundConstants import CSoundConstants
from Framework.CSound.CSoundClient import CSoundClient
from Framework.CSound.CSoundServer import CsoundServerMult
import os
import sys
import signal
import time

from GUI.StandalonePlayer import StandAlonePlayer
from GUI.Core.MainWindow import MainWindow

from Framework.Core.Profiler import TP

if __name__ == "__main__": 
    def run_sugar_mode():
        CSoundClient.initialize(True)
        CSoundClient.setMasterVolume(100)
        tamtam = StandAlonePlayer()
        #tamtam = gtk.Button("adsf")
        mainwin = gtk.Window(gtk.WINDOW_TOPLEVEL)
        #mainwin.set_size_request(1200,600)
        mainwin.set_title('miniTamTam')
        mainwin.set_resizable(False)
        mainwin.connect('destroy' , gtk.main_quit )
        mainwin.connect( "key-press-event", tamtam.keyboardStandAlone.onKeyPress )
        mainwin.connect( "key-release-event", tamtam.keyboardStandAlone.onKeyRelease )
        mainwin.add(tamtam)
        tamtam.show()
        mainwin.show()
        gtk.main()
        CSoundClient.initialize(False)
        sys.exit(0)

    def run_edit_mode():
        TP.Profile("TT::init")
        TP.Profile("TT::init::csound")
        CSoundClient.initialize(True)
        CSoundClient.setMasterVolume(100)
        TP.Profile("TT::init::csound")
        TP.Profile("TT::init::mainwin")
        TP.Profile("TT::init::mainwin::init")
        tamtam = MainWindow()
        TP.Profile("TT::init::mainwin::init")
        TP.Profile("TT::init::mainwin::connect")
        mainwin = gtk.Window(gtk.WINDOW_TOPLEVEL)
        mainwin.set_title('TamTam Player')
        mainwin.set_geometry_hints( None, 1200, 900, 1200, 900, 1200, 900 )
        #mainwin.fullscreen() # don't need to specify full screen, it seem to sit properly anyway
        mainwin.set_resizable(False)
        mainwin.connect('destroy' , tamtam.destroy )
        #mainwin.connect( "configure-event", tamtam.handleConfigureEvent )
        mainwin.connect( "key-press-event", tamtam.onKeyPress )
        mainwin.connect( "key-release-event", tamtam.onKeyRelease )
        mainwin.connect( "delete_event", tamtam.delete_event )
        mainwin.add(tamtam)
        TP.Profile("TT::init::mainwin::add")
        TP.Profile("TT::init::mainwin")
        TP.Profile("TT::init::show")
        tamtam.show()
        mainwin.show()
        TP.Profile("TT::init::show")
        TP.Profile("TT::init")
        gtk.main()
        CSoundClient.initialize(False)
        sys.exit(0)

    if len(sys.argv) > 1 and sys.argv[1] == 'edit':
        run_edit_mode()
    else:
        run_sugar_mode()

from sugar.activity.Activity import Activity
class TamTam(Activity):
    def __init__(self):

        Activity.__init__(self)

        self.tamtam = StandAlonePlayer()
        self.connect('focus_in_event',self.handleFocusIn)
        self.connect('focus_out_event',self.handleFocusOut)
        self.connect('destroy', self.do_quit)
        self.add(self.tamtam)
        self.tamtam.show()
        self.set_title('TamTam')
        self.set_resizable(False)
        self.connect( "key-press-event", self.tamtam.keyboardStandAlone.onKeyPress )
        self.connect( "key-release-event", self.tamtam.keyboardStandAlone.onKeyRelease )
    
    def handleFocusIn(self, event, data=None):
        CSoundClient.initialize(True)
        CSoundClient.setMasterVolume(100)
    
    def handleFocusOut(self, event, data=None):
        CSoundClient.initialize(False)

    def do_quit(self, arg2):
        CSoundClient.initialize(False)
        del self.tamtam