Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit 9b161ed20f0bf928b40479a0f01565ff16f3784e

few more changes
  
11import gi
2pygtk.require( '2.0' )
3import gtk
2pyGtk.require( '2.0' )
43from gi.repository import GObject
4from gi.repository import Gtk
55
66from RythmGenerator import *
77from common.Util.CSoundClient import new_csound_client
3232
3333 def setBeats( self, nbeats ):
3434 if self.playBackTimeout != None:
35 gobject.source_remove( self.playBackTimeout )
35 GObject.source_remove( self.playBackTimeout )
3636
3737 self.nbeats = nbeats
3838 self.clear()
4141 def setTempo( self, tempo ):
4242 self.tempo = tempo
4343 if self.playBackTimeout != None:
44 gobject.source_remove( self.playBackTimeout )
44 GObject.source_remove( self.playBackTimeout )
4545 self.play()
4646
4747 def setReverb( self, reverb ):
5252
5353 def play( self ):
5454 if self.playBackTimeout == None:
55 self.playbackTimeout = gobject.timeout_add( int(60000/self.tempo/8), self.handleClock )
55 self.playbackTimeout = GObject.timeout_add( int(60000/self.tempo/8), self.handleClock )
5656 self.handleClock()
5757
5858 def stop( self ):
5959 if self.playBackTimeout != None:
60 gobject.source_remove( self.playBackTimeout )
60 GObject.source_remove( self.playBackTimeout )
6161 self.clear()
6262
6363 def clear( self ):
  
11import gi
2pygtk.require( '2.0' )
2pyGtk.require( '2.0' )
33from gi.repository import Gtk
44
55import time
1717Tooltips = Config.Tooltips
1818
1919
20class InstrumentPanel( gtk.EventBox ):
20class InstrumentPanel( Gtk.EventBox ):
2121 def __init__(self,setInstrument=None):
22 gtk.EventBox.__init__(self)
22 Gtk.EventBox.__init__(self)
2323
2424 self._scrolled_window = None
2525
6868 if Config.DEBUG > 4: print "InstrumentPanel load", self.loadStage
6969
7070 if self.loadStage[0] == 0:
71 color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
72 self.modify_bg(gtk.STATE_NORMAL, color)
71 color = Gdk.color_parse(Config.PANEL_BCK_COLOR)
72 self.modify_bg(Gtk.STATE_NORMAL, color)
7373 self.loadStage[0] = 1
7474 if timeout >= 0 and time.time() > timeout: return False
7575
7676 if self.loadStage[0] == 1:
77 self.tooltips = gtk.Tooltips()
77 self.tooltips = Gtk.Tooltips()
7878 self.loadStage[0] = 2
7979 if timeout >= 0 and time.time() > timeout: return False
8080
8383 self.recstate = False
8484 self.lastInstrumentWidget = None
8585
86 self.mainVBox = gtk.VBox()
86 self.mainVBox = Gtk.VBox()
8787 self.loadStage[0] = 3
8888 if timeout >= 0 and time.time() > timeout: return False
8989
166166
167167 def loadToolbar( self, timeout = -1, loadStage = [0,0,0] ):
168168 if loadStage[1] == 0:
169 self.toolbarBox = gtk.HBox()
169 self.toolbarBox = Gtk.HBox()
170170
171 scrollbox = HScrolledBox(scroll_policy=gtk.POLICY_NEVER)
171 scrollbox = HScrolledBox(scroll_policy=Gtk.POLICY_NEVER)
172172 scrollbox.set_viewport(self.toolbarBox)
173 scrollbox.modify_bg(gtk.STATE_NORMAL, style.Color(Config.PANEL_BCK_COLOR).get_gdk_color())
173 scrollbox.modify_bg(Gtk.STATE_NORMAL, style.Color(Config.PANEL_BCK_COLOR).get_Gdk_color())
174174 self.mainVBox.pack_start(scrollbox, False, False)
175175
176176 self.firstTbBtn = None
262262 return True
263263
264264 def loadInstrumentViewport( self ):
265 self.instBox = gtk.Alignment(0.5, 0, 0, 1)
265 self.instBox = Gtk.Alignment(0.5, 0, 0, 1)
266266
267 box = gtk.EventBox()
268 color = gtk.gdk.color_parse(Config.INSTRUMENT_GRID_COLOR)
269 box.modify_bg(gtk.STATE_NORMAL, color)
267 box = Gtk.EventBox()
268 color = Gdk.color_parse(Config.INSTRUMENT_GRID_COLOR)
269 box.modify_bg(Gtk.STATE_NORMAL, color)
270270 box.add(self.instBox)
271271
272 scrollwin = gtk.ScrolledWindow()
273 scrollwin.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC)
272 scrollwin = Gtk.ScrolledWindow()
273 scrollwin.set_policy(Gtk.POLICY_NEVER,Gtk.POLICY_AUTOMATIC)
274274 scrollwin.add_with_viewport(box)
275 box.get_parent().set_shadow_type(gtk.SHADOW_NONE)
275 box.get_parent().set_shadow_type(Gtk.SHADOW_NONE)
276276 self.mainVBox.pack_end(scrollwin, True, True, 0)
277277
278278 self.show_all()
300300 if instrumentNum % cols is not 0: #S'il y a un reste
301301 rows = rows + 1
302302
303 self.instTable = gtk.Table(rows,cols,True)
303 self.instTable = Gtk.Table(rows,cols,True)
304304 self.instTable.set_row_spacings(0)
305305 self.instTable.set_col_spacings(0)
306306
311311 break
312312 inst = instruments[i]
313313 if self.instDic.has_key(inst):
314 self.instTable.attach(self.instDic[inst], col, col+1, row, row+1, gtk.SHRINK, gtk.SHRINK, 0, 0)
314 self.instTable.attach(self.instDic[inst], col, col+1, row, row+1, Gtk.SHRINK, Gtk.SHRINK, 0, 0)
315315
316316 self.instBox.add(self.instTable)
317317 self.instTable.show_all()
326326 def handleInstrumentButtonClick(self,widget,instrument):
327327 if widget.get_active() is True and self.recstate == False:
328328 if self.setInstrument:
329 widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event
329 widget.event( Gdk.Event( Gdk.LEAVE_NOTIFY ) ) # fake the leave event
330330 self.setInstrument(instrument)
331331 time.sleep(0.05)
332332 if self.playInstrument: self.playInstrument(instrument)
341341 if self._scrolled_window is None:
342342 parent = widget.parent
343343 while parent is not None:
344 if isinstance(parent, gtk.ScrolledWindow):
344 if isinstance(parent, Gtk.ScrolledWindow):
345345 self._scrolled_window = parent
346346 break
347347 parent = parent.parent
377377 btn.handler_unblock(btn.clickedHandler)
378378
379379
380class DrumPanel( gtk.EventBox ):
380class DrumPanel( Gtk.EventBox ):
381381 def __init__(self, setDrum = None):
382 gtk.EventBox.__init__(self)
383 color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
384 self.modify_bg(gtk.STATE_NORMAL, color)
382 Gtk.EventBox.__init__(self)
383 color = Gdk.color_parse(Config.PANEL_BCK_COLOR)
384 self.modify_bg(Gtk.STATE_NORMAL, color)
385385
386386 self.setDrum = setDrum
387387 self.instrumentList = []
413413 def setDrums(self,widget,data):
414414 if widget.get_active():
415415 if self.setDrum:
416 widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event
416 widget.event( Gdk.Event( Gdk.LEAVE_NOTIFY ) ) # fake the leave event
417417 self.setDrum(data)
418418
419419 def set_activeInstrument( self, instrument, state ):
424424 btn.handler_unblock(btn.clickedHandler)
425425
426426if __name__ == "__main__":
427 win = gtk.Window()
427 win = Gtk.Window()
428428 wc = DrumPanel(None)
429429 win.add(wc)
430430 win.show()
431 #start the gtk event loop
432 gtk.main()
431 #start the Gtk event loop
432 Gtk.main()
  
11import gi
2pygtk.require( '2.0' )
2pyGtk.require( '2.0' )
33from gi.repository import Gtk
44
55import common.Config as Config
102102 playkey(36,100, self.instrumentDB.instNamed[instrumentName].kit[pitch])
103103
104104 else:
105 if event.get_state() == gtk.gdk.MOD1_MASK:
105 if event.get_state() == Gdk.MOD1_MASK:
106106 pitch += 5
107107
108108 instrument = self.instrumentDB.instNamed[ instrumentName ]
  
11import gi
2pygtk.require( '2.0' )
2pyGtk.require( '2.0' )
33from gi.repository import Gtk
44from gi.repository import GObject
55import time
3131
3232 def setTempo( self, tempo ):
3333 self.tempo = tempo
34 gobject.source_remove( self.playBackTimeout )
34 GObject.source_remove( self.playBackTimeout )
3535 self.playState = 0
3636
3737 def handleRecordButton( self, widget, data=None ):
6363
6464 def startPlayback( self ):
6565 if not self.playState:
66 self.playbackTimeout = gobject.timeout_add( int(60000/self.tempo/12), self.handleClock )
66 self.playbackTimeout = GObject.timeout_add( int(60000/self.tempo/12), self.handleClock )
6767 self.handleClock()
6868 self.playState = 1
6969
7070 def stopPlayback( self ):
7171 if self.playbackTimeout != None:
72 gobject.source_remove( self.playbackTimeout )
72 GObject.source_remove( self.playbackTimeout )
7373 self.playbackTimeout = None
7474 self.playState = 0
7575
  
11import gi
2pygtk.require( '2.0' )
2pyGtk.require( '2.0' )
33from gi.repository import Gtk
44from gi.repository import GObject
55import os
4343
4444Tooltips = Config.Tooltips
4545
46class miniTamTamMain(gtk.EventBox):
46class miniTamTamMain(Gtk.EventBox):
4747
4848 def __init__(self, activity):
49 gtk.EventBox.__init__(self)
49 Gtk.EventBox.__init__(self)
5050
5151 self.instrumentPanel = None
5252 self.activity = activity
8989 self.csnd.setMasterVolume(self.volume)
9090 self.sequencer.beat = self.beat
9191 self.loop.beat = self.beat
92 self.tooltips = gtk.Tooltips()
92 self.tooltips = Gtk.Tooltips()
9393
94 self.mainWindowBox = gtk.HBox()
95 self.leftBox = gtk.VBox()
96 self.rightBox = gtk.VBox()
94 self.mainWindowBox = Gtk.HBox()
95 self.leftBox = Gtk.VBox()
96 self.rightBox = Gtk.VBox()
9797 self.mainWindowBox.pack_start(self.rightBox, False, True)
9898 self.mainWindowBox.pack_start(self.leftBox, True, True)
9999 self.add(self.mainWindowBox)
131131 #-- handle forced networking ---------------------------------------
132132 if self.network.isHost():
133133 self.updateSync()
134 self.syncTimeout = gobject.timeout_add( 1000, self.updateSync )
134 self.syncTimeout = GObject.timeout_add( 1000, self.updateSync )
135135 elif self.network.isPeer():
136136 self.sendTempoQuery()
137 self.syncTimeout = gobject.timeout_add( 1000, self.updateSync )
137 self.syncTimeout = GObject.timeout_add( 1000, self.updateSync )
138138 #-------------------------------------------------------------------
139139
140140 # Toolbar
198198 slidersBox = RoundVBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
199199 slidersBox.set_border_width(Config.PANEL_SPACING)
200200
201 geneSliderBox = gtk.VBox()
202 self.geneSliderBoxImgTop = gtk.Image()
201 geneSliderBox = Gtk.VBox()
202 self.geneSliderBoxImgTop = Gtk.Image()
203203 self.geneSliderBoxImgTop.set_from_file(imagefile('complex6.png'))
204 self.geneAdjustment = gtk.Adjustment(value=self.regularity, lower=0, upper=1, step_incr=0.01, page_incr=0, page_size=0)
204 self.geneAdjustment = Gtk.Adjustment(value=self.regularity, lower=0, upper=1, step_incr=0.01, page_incr=0, page_size=0)
205205 self.geneSlider = ImageVScale('sliderbutbleu.png',
206206 self.geneAdjustment, 5)
207207 self.geneSlider.set_inverted(False)
211211 geneSliderBox.pack_start(self.geneSlider, True, 20)
212212 self.tooltips.set_tip(self.geneSlider,Tooltips.COMPL)
213213
214 beatSliderBox = gtk.VBox()
215 self.beatSliderBoxImgTop = gtk.Image()
214 beatSliderBox = Gtk.VBox()
215 self.beatSliderBoxImgTop = Gtk.Image()
216216 self.beatSliderBoxImgTop.set_from_file(imagefile('beat3.png'))
217 self.beatAdjustment = gtk.Adjustment(value=self.beat, lower=2,
217 self.beatAdjustment = Gtk.Adjustment(value=self.beat, lower=2,
218218 upper=12, step_incr=1, page_incr=0, page_size=0)
219219 self.beatSlider = ImageVScale('sliderbutjaune.png',
220220 self.beatAdjustment, 5, snap=1)
228228 self.delayedTempo = 0 # used to store tempo updates while the slider is active
229229 self.tempoSliderActive = False
230230
231 tempoSliderBox = gtk.VBox()
232 self.tempoSliderBoxImgTop = gtk.Image()
231 tempoSliderBox = Gtk.VBox()
232 self.tempoSliderBoxImgTop = Gtk.Image()
233233 self.tempoSliderBoxImgTop.set_from_file(imagefile('tempo5.png'))
234 self.tempoAdjustment = gtk.Adjustment(value=self.tempo, lower=Config.PLAYER_TEMPO_LOWER, upper=Config.PLAYER_TEMPO_UPPER, step_incr=1, page_incr=1, page_size=1)
234 self.tempoAdjustment = Gtk.Adjustment(value=self.tempo, lower=Config.PLAYER_TEMPO_LOWER, upper=Config.PLAYER_TEMPO_UPPER, step_incr=1, page_incr=1, page_size=1)
235235 tempoSlider = ImageVScale('sliderbutvert.png', self.tempoAdjustment, 5)
236236 tempoSlider.set_inverted(True)
237237 self.tempoAdjustmentHandler = self.tempoAdjustment.connect("value_changed" , self.handleTempoSliderChange)
241241 tempoSliderBox.pack_start(tempoSlider, True)
242242 self.tooltips.set_tip(tempoSlider,Tooltips.TEMPO)
243243
244 volumeSliderBox = gtk.VBox()
245 self.volumeSliderBoxImgTop = gtk.Image()
244 volumeSliderBox = Gtk.VBox()
245 self.volumeSliderBoxImgTop = Gtk.Image()
246246 self.volumeSliderBoxImgTop.set_from_file(imagefile('volume2.png'))
247 self.volumeAdjustment = gtk.Adjustment(value=self.volume, lower=0, upper=200, step_incr=1, page_incr=1, page_size=1)
247 self.volumeAdjustment = Gtk.Adjustment(value=self.volume, lower=0, upper=200, step_incr=1, page_incr=1, page_size=1)
248248 volumeSlider = ImageVScale('sliderbutbleu.png',
249249 self.volumeAdjustment, 5)
250250 volumeSlider.set_inverted(True)
255255 self.tooltips.set_tip(volumeSlider,Tooltips.VOL)
256256
257257
258 slidersBoxSub = gtk.HBox()
258 slidersBoxSub = Gtk.HBox()
259259 slidersBoxSub.pack_start(beatSliderBox, True, True, 0)
260260 slidersBoxSub.pack_start(geneSliderBox, True, True, 0)
261261 slidersBoxSub.pack_start(tempoSliderBox, True, True, 0)
268268 radius=Config.PANEL_RADIUS)
269269 generateBtnSub.set_border_width(Config.PANEL_SPACING)
270270
271 #playImg = gtk.Image()
272 #playImg.set_from_icon_name('media-playback-start', gtk.ICON_SIZE_LARGE_TOOLBAR)
271 #playImg = Gtk.Image()
272 #playImg.set_from_icon_name('media-playback-start', Gtk.ICON_SIZE_LARGE_TOOLBAR)
273273 self.playButton = ImageToggleButton('miniplay.png', 'stop.png')
274 #self.playButton.set_relief(gtk.RELIEF_NONE)
274 #self.playButton.set_relief(Gtk.RELIEF_NONE)
275275 #self.playButton.set_image(playImg)
276276 self.playButton.connect('clicked',self.handlePlayButton)
277277 generateBtnSub.pack_start(self.playButton, True, True, 0)
289289 bordercolor=Config.PANEL_BCK_COLOR,
290290 radius=Config.PANEL_RADIUS)
291291
292 drum_scroll = VScrolledBox(scroll_policy=gtk.POLICY_NEVER)
292 drum_scroll = VScrolledBox(scroll_policy=Gtk.POLICY_NEVER)
293293 drum_scroll.set_viewport(drum_box)
294 drum_scroll.modify_bg(gtk.STATE_NORMAL,
295 style.Color(Config.PANEL_BCK_COLOR).get_gdk_color())
294 drum_scroll.modify_bg(Gtk.STATE_NORMAL,
295 style.Color(Config.PANEL_BCK_COLOR).get_Gdk_color())
296296 drum_i = 0
297297 drum_group = None
298298
299299 for row in range(DRUMCOUNT/2 + DRUMCOUNT%2):
300 row_box = gtk.HBox()
300 row_box = Gtk.HBox()
301301 drum_box.pack_start(row_box, False)
302302
303303 for col in range(2):
351351 self.instrumentPanel = InstrumentPanel()
352352 self.leftBox.pack_start(self.instrumentPanel, True, True, 0)
353353
354 width = gtk.gdk.screen_width() - self.rightBox.get_size_request()[0]
354 width = Gdk.screen_width() - self.rightBox.get_size_request()[0]
355355 self.instrumentPanel.configure(self.setInstrument,
356356 self.playInstrumentNote, False, self.micRec, width=width)
357357
360360 def micRec(self, widget, mic):
361361 self.csnd.inputMessage("i5600 0 4")
362362 OS.arecord(4, "crop.csd", mic)
363 self.micTimeout = gobject.timeout_add(200, self.loadMicInstrument, mic)
363 self.micTimeout = GObject.timeout_add(200, self.loadMicInstrument, mic)
364364 self.instrumentPanel.set_activeInstrument(mic,True)
365365 self.setInstrument(mic)
366366
576576
577577 def enableKeyboard( self ):
578578 self.keyboardStandAlone = KeyboardStandAlone( self.sequencer.recording, self.sequencer.adjustDuration, self.csnd.loopGetTick, self.sequencer.getPlayState, self.loop )
579 self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
579 self.add_events(Gdk.BUTTON_PRESS_MASK)
580580
581581 def setInstrument( self , instrument ):
582582 self.instrument = instrument
673673 self.activity._shared_activity.connect( "buddy-left", self.buddy_left )
674674 self.network.setMode( Net.MD_HOST )
675675 self.updateSync()
676 self.syncTimeout = gobject.timeout_add( 1000, self.updateSync )
676 self.syncTimeout = GObject.timeout_add( 1000, self.updateSync )
677677
678678 def joined( self, activity ):
679679 print "miniTamTam:: joined activity!!"
727727 def networkStatusWatcher( self, mode ):
728728 if mode == Net.MD_OFFLINE:
729729 if self.syncTimeout:
730 gobject.source_remove( self.syncTimeout )
730 GObject.source_remove( self.syncTimeout )
731731 self.syncTimeout = None
732732 if mode == Net.MD_PEER:
733733 self.updateSync()
734734 if not self.syncTimeout:
735 self.syncTimeout = gobject.timeout_add( 1000, self.updateSync )
735 self.syncTimeout = GObject.timeout_add( 1000, self.updateSync )
736736 self.sendTempoQuery()
737737
738738 def processHT_SYNC_REPLY( self, sock, message, data ):
828828
829829if __name__ == "__main__":
830830 MiniTamTam = miniTamTam()
831 #start the gtk event loop
832 gtk.main()
831 #start the Gtk event loop
832 Gtk.main()
  
1010from sugar3.graphics.palette import Palette
1111from gettext import gettext as _
1212
13class playToolbar(gtk.Toolbar):
13class playToolbar(Gtk.Toolbar):
1414 def __init__(self, miniTamTam):
15 gtk.Toolbar.__init__(self)
15 Gtk.Toolbar.__init__(self)
1616
1717 def _insertSeparator(x = 1):
1818 for i in range(x):
19 self.separator = gtk.SeparatorToolItem()
19 self.separator = Gtk.SeparatorToolItem()
2020 self.separator.set_draw(True)
2121 self.insert(self.separator,-1)
2222 self.separator.show()
2323
2424 self.miniTamTam = miniTamTam
2525
26 self.tooltips = gtk.Tooltips()
26 self.tooltips = Gtk.Tooltips()
2727
28 self.balanceSliderImgLeft = gtk.Image()
29 self.balanceSliderImgRight = gtk.Image()
28 self.balanceSliderImgLeft = Gtk.Image()
29 self.balanceSliderImgRight = Gtk.Image()
3030 self.balanceSliderImgLeft.set_from_file(imagefile('dru2.png'))
3131 self.balanceSliderImgRight.set_from_file(imagefile('instr2.png'))
32 self.balanceSliderImgLeftTool = gtk.ToolItem()
32 self.balanceSliderImgLeftTool = Gtk.ToolItem()
3333 self.balanceSliderImgLeftTool.add(self.balanceSliderImgLeft)
34 self.balanceSliderImgRightTool = gtk.ToolItem()
34 self.balanceSliderImgRightTool = Gtk.ToolItem()
3535 self.balanceSliderImgRightTool.add(self.balanceSliderImgRight)
36 self.balanceSliderAdj = gtk.Adjustment(value=50, lower=0, upper=100, step_incr=1, page_incr=0, page_size=0)
36 self.balanceSliderAdj = Gtk.Adjustment(value=50, lower=0, upper=100, step_incr=1, page_incr=0, page_size=0)
3737 self.balanceSliderAdj.connect("value_changed" , self.miniTamTam.handleBalanceSlider)
38 self.balanceSlider = gtk.HScale(adjustment = self.balanceSliderAdj)
38 self.balanceSlider = Gtk.HScale(adjustment = self.balanceSliderAdj)
3939 self.balanceSlider.set_size_request(250,15)
4040 self.balanceSlider.set_inverted(False)
4141 self.balanceSlider.set_draw_value(False)
42 self.balanceSliderTool = gtk.ToolItem()
42 self.balanceSliderTool = Gtk.ToolItem()
4343 self.balanceSliderTool.add(self.balanceSlider)
4444 self.insert(self.balanceSliderImgLeftTool, -1)
4545 self.insert(self.balanceSliderTool, -1)
5454
5555 _insertSeparator(1)
5656
57 self.reverbSliderImgRight = gtk.Image()
57 self.reverbSliderImgRight = Gtk.Image()
5858 self.reverbSliderImgRight.set_from_file(imagefile('reverb0.png'))
59 self.reverbSliderImgRightTool = gtk.ToolItem()
59 self.reverbSliderImgRightTool = Gtk.ToolItem()
6060 self.reverbSliderImgRightTool.add(self.reverbSliderImgRight)
6161
62 self.reverbSliderAdj = gtk.Adjustment(value=0.1, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0)
62 self.reverbSliderAdj = Gtk.Adjustment(value=0.1, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0)
6363 self.reverbSliderAdj.connect("value_changed" , self.miniTamTam.handleReverbSlider)
64 self.reverbSlider = gtk.HScale(adjustment = self.reverbSliderAdj)
64 self.reverbSlider = Gtk.HScale(adjustment = self.reverbSliderAdj)
6565 self.reverbSlider.set_size_request(250,15)
6666 self.reverbSlider.set_inverted(False)
6767 self.reverbSlider.set_draw_value(False)
68 self.reverbSliderTool = gtk.ToolItem()
68 self.reverbSliderTool = Gtk.ToolItem()
6969 self.reverbSliderTool.add(self.reverbSlider)
7070 self.insert(self.reverbSliderTool, -1)
7171 self.insert(self.reverbSliderImgRightTool, -1)
7878 self.show_all()
7979
8080
81class recordToolbar(gtk.Toolbar):
81class recordToolbar(Gtk.Toolbar):
8282 def __init__(self, miniTamTam):
83 gtk.Toolbar.__init__(self)
83 Gtk.Toolbar.__init__(self)
8484
8585 def _insertSeparator(x = 1):
8686 for i in range(x):
87 self.separator = gtk.SeparatorToolItem()
87 self.separator = Gtk.SeparatorToolItem()
8888 self.separator.set_draw(True)
8989 self.insert(self.separator,-1)
9090 self.separator.show()
152152
153153 self.mini = mini
154154
155 self.tooltips = gtk.Tooltips()
155 self.tooltips = Gtk.Tooltips()
156156 self.loopedSound = False
157157 self.soundLength = 1.00
158158 self.start = 0
162162 self.register = 0
163163 self.ok = True
164164
165 self.mainBox = gtk.VBox()
165 self.mainBox = Gtk.VBox()
166166
167 self.controlsBox = gtk.HBox()
167 self.controlsBox = Gtk.HBox()
168168
169169 self.GUI = {}
170170
171 self.soundBox = gtk.HBox()
172 self.soundLabel = gtk.Label(_('Sound: '))
171 self.soundBox = Gtk.HBox()
172 self.soundLabel = Gtk.Label(_('Sound: '))
173173 self.soundMenuBox = BigComboBox()
174174 self.sounds = os.listdir(Config.DATA_DIR)
175175 for sound in self.sounds:
180180
181181 self.mainBox.pack_start(self.soundBox, False, False, 10)
182182
183 nameBox = gtk.VBox()
184 self.nameEntry = gtk.Entry()
185 entrycolor = gtk.gdk.Color()
186 self.nameEntry.modify_text(gtk.STATE_NORMAL, entrycolor)
183 nameBox = Gtk.VBox()
184 self.nameEntry = Gtk.Entry()
185 entrycolor = Gdk.Color()
186 self.nameEntry.modify_text(Gtk.STATE_NORMAL, entrycolor)
187187 self.nameEntry.set_text("name_of_the_sound")
188188 nameBox.pack_start(self.nameEntry, True, True, 0)
189189 self.mainBox.pack_start(nameBox, False, False, 10)
190190
191 registerBox = gtk.HBox()
192 self.registerBoxLabel = gtk.Label(_('Register: '))
191 registerBox = Gtk.HBox()
192 self.registerBoxLabel = Gtk.Label(_('Register: '))
193193 self.registerMenuBox = BigComboBox()
194194 self.registers = ['LOW', 'MID', 'HIGH', 'PUNCH']
195195 for reg in self.registers:
199199 registerBox.pack_end(self.registerMenuBox, False, False, padding=10)
200200 self.mainBox.pack_start(registerBox, False, False, 10)
201201
202 loopedBox = gtk.HBox()
203 loopedLabel = gtk.Label("Looped sound: ")
202 loopedBox = Gtk.HBox()
203 loopedLabel = Gtk.Label("Looped sound: ")
204204 loopedToggle = ImageToggleButton('checkOff.png', 'checkOn.png')
205205 loopedToggle.connect('button-press-event', self.handleLooped )
206206 loopedBox.pack_start(loopedLabel, False, False, padding=10)
207207 loopedBox.pack_end(loopedToggle, False, False, padding=10)
208208 self.mainBox.pack_start(loopedBox, False, False, 10)
209209
210 startBox = gtk.VBox()
211 self.startAdjust = gtk.Adjustment( 0.01, 0, 1., .001, .001, 0)
212 self.GUI['startSlider'] = gtk.VScale( adjustment = self.startAdjust )
210 startBox = Gtk.VBox()
211 self.startAdjust = Gtk.Adjustment( 0.01, 0, 1., .001, .001, 0)
212 self.GUI['startSlider'] = Gtk.VScale( adjustment = self.startAdjust )
213213 self.startAdjust.connect("value-changed", self.handleStart)
214214 self.GUI['startSlider'].set_inverted(True)
215215 self.GUI['startSlider'].set_size_request(50, 200)
218218 startBox.pack_start(self.GUI['startSlider'], True, True, 5)
219219 self.controlsBox.pack_start(startBox, True, True, 0)
220220
221 endBox = gtk.VBox()
222 self.endAdjust = gtk.Adjustment( 0.9, 0, 1, .001, .001, 0)
223 self.GUI['endSlider'] = gtk.VScale( adjustment = self.endAdjust )
221 endBox = Gtk.VBox()
222 self.endAdjust = Gtk.Adjustment( 0.9, 0, 1, .001, .001, 0)
223 self.GUI['endSlider'] = Gtk.VScale( adjustment = self.endAdjust )
224224 self.endAdjust.connect("value-changed", self.handleEnd)
225225 self.GUI['endSlider'].set_inverted(True)
226226 self.GUI['endSlider'].set_size_request(50, 200)
229229 endBox.pack_start(self.GUI['endSlider'], True, True, 5)
230230 self.controlsBox.pack_start(endBox, True, True, 0)
231231
232 durBox = gtk.VBox()
233 self.durAdjust = gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0)
234 self.GUI['durSlider'] = gtk.VScale( adjustment = self.durAdjust )
232 durBox = Gtk.VBox()
233 self.durAdjust = Gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0)
234 self.GUI['durSlider'] = Gtk.VScale( adjustment = self.durAdjust )
235235 self.durAdjust.connect("value-changed", self.handleDur)
236236 self.GUI['durSlider'].set_inverted(True)
237237 self.GUI['durSlider'].set_size_request(50, 200)
240240 durBox.pack_start(self.GUI['durSlider'], True, True, 5)
241241 self.controlsBox.pack_start(durBox, True, True, 0)
242242
243 volBox = gtk.VBox()
244 self.volAdjust = gtk.Adjustment( 1, 0, 2, .01, .01, 0)
245 self.GUI['volSlider'] = gtk.VScale( adjustment = self.volAdjust )
243 volBox = Gtk.VBox()
244 self.volAdjust = Gtk.Adjustment( 1, 0, 2, .01, .01, 0)
245 self.GUI['volSlider'] = Gtk.VScale( adjustment = self.volAdjust )
246246 self.volAdjust.connect("value-changed", self.handleVol)
247247 self.GUI['volSlider'].set_inverted(True)
248248 self.GUI['volSlider'].set_size_request(50, 200)
253253
254254 self.mainBox.pack_start(self.controlsBox, False, False, 10)
255255
256 previewBox = gtk.VBox()
256 previewBox = Gtk.VBox()
257257 self.playStopButton = ImageToggleButton('miniplay.png', 'stop.png')
258258 self.playStopButton.connect('button-press-event' , self.handlePlayButton)
259259 previewBox.pack_start(self.playStopButton, True, True, 0)
260260 self.mainBox.pack_start(previewBox, False, False, 10)
261261
262 checkBox = gtk.VBox()
262 checkBox = Gtk.VBox()
263263 checkButton = ImageButton(Config.TAM_TAM_ROOT + '/icons/accept.svg')
264264 checkButton.connect('clicked' , self.handleCheck)
265265 checkBox.pack_start(checkButton, True, True, 0)
291291 self.set_values(soundLength)
292292 self.startAdjust.set_all( 0.01, 0, soundLength, .001, .001, 0)
293293 self.endAdjust.set_all( soundLength-0.01, 0, soundLength, .001, .001, 0)
294 self.timeoutLoad = gobject.timeout_add(2000, self.loopSettingsDelay)
294 self.timeoutLoad = GObject.timeout_add(2000, self.loopSettingsDelay)
295295
296296 def loopSettingsDelay(self):
297297 self.mini.load_ls_instrument(self.sndname)
298 gobject.source_remove( self.timeoutLoad )
298 GObject.source_remove( self.timeoutLoad )
299299
300300 def handleCheck(self, widget):
301301 if self.nameEntry.get_text() != self.sndname:
370370 if self.ok:
371371 self.mini.loopSettingsPlayStop(widget.get_active(), self.loopedSound)
372372 if self.loopedSound == False and widget.get_active() == False:
373 self.timeoutStop = gobject.timeout_add(int(self.soundLength * 1000)+500, self.playButtonState)
373 self.timeoutStop = GObject.timeout_add(int(self.soundLength * 1000)+500, self.playButtonState)
374374
375375 def setButtonState(self):
376376 self.ok = False
380380 def playButtonState(self):
381381 self.ok = False
382382 self.playStopButton.set_active(False)
383 gobject.source_remove(self.timeoutStop)
383 GObject.source_remove(self.timeoutStop)
384384 self.ok = True