Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/theorie.py
blob: 98589392be035f36931bd955404745ac25673ece (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
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#------------------------------------------------------------------------------

# Copyright 2008-2009 : François Sénéquier
# Email : francois.senequier@netcourrier.com

# This file is part of 'Theorie'.
#
# 'Theorie' 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
# any later version.
#
# 'Theorie' 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.

#------------------------------------------------------------------------------

import initialisations
import jouer_notes

import os
import pygtk
import gtk
from gtk.gdk import *

from sugar.activity import activity

#------------------------------------------------------------------------------

from modele import *
from commun import *
from composant_selection import *
from composant_affichage import *
from composant_degres import *
from composant_notes import *
from composant_comparaison import *
from composant_harmonica import *
from composant_flute import *
from composant_guitare import *
from composant_clarinette import *
from composant_piano import *
from composant_reconnaitre import *
from composant_ecouter import *
from composant_quadrant import *

#------------------------------------------------------------------------------

class Theorie(activity.Activity):

	def __keyPress(self, widget, event):
		key = gtk.gdk.keyval_name(event.keyval)
		if key == 'KP_Page_Up':
			widget.get_toplevel().child_focus(gtk.DIR_TAB_BACKWARD)
			return True
		elif key == 'KP_Page_Down':
			widget.get_toplevel().child_focus(gtk.DIR_TAB_FORWARD)
			return True
		return False

	def __del__(self):
		jouer_notes.delPygameMixer()

	def __init__(self, handle):
		# initialisations
		activity.Activity.__init__(self, handle)
		self.set_title(TXT_TIT_APP)
		toolbox = activity.ActivityToolbox(self)
		self.set_toolbox(toolbox)
		toolbox.show()
		# initialisation de pygame.mixer
		jouer_notes.iniPygameMixer()
		# creation des composants
		SET_AFF(MOD_NOT)
		SET_CMP(MOD_OCT)
		# creation des onglets gammes, accords, notes
		compGAM = ComposantGammes()
		compACC = ComposantAccords()
		compNOT = ComposantNotes()
		compSEL = ComposantSelection("", [compGAM, compACC, compNOT], gtk.POS_TOP)
		# recuperation des dimensions de l'ecran
		lar = screen_width()
		hau = screen_height()
		tracer("ComposantTheorie", "__init__", "Résolution = %d %d" %(lar, hau))
		# recuperation des notes initiales
		notes = compGAM.getNotes()
		# creation des onglets instruments et theorie
		compCMP = ComposantComparaison(notes)
		compREC = ComposantReconnaitre(notes)
		compECO = ComposantEcouter(notes)
		compQUA = ComposantQuadrant(notes)
		compHAR = ComposantHarmonica(notes)
		compFLU = ComposantFlute(notes)
		compGUI = ComposantGuitare(notes)
		compCLA = ComposantClarinette(notes)
		compPIA = ComposantPiano(notes)
		compINS = ComposantAffichage(TXT_ONG_INS, notes, [compGUI, compHAR, compFLU, compCLA, compPIA], gtk.POS_BOTTOM)
		compTHE = ComposantAffichage(TXT_ONG_THE, notes, [compQUA, compREC, compECO, compCMP], gtk.POS_BOTTOM)
		compAFF = ComposantAffichage("", notes, [compINS, compTHE], gtk.POS_TOP)
		panedUI = definirVPANED(compSEL.getContainer(), compAFF.getContainer())
		# liaison 'evenement' entre les deux zones
		compSEL.addObserver(compAFF)
		# ajout de l'ensemble dans la fenetre et affichage
		self.set_canvas(panedUI)
		# gestion des evenements 'clavier'
		self.connect('key-press-event', self.__keyPress)