[gcompris/gcomprismusic] save file option is working but as keypress returns twice, each note is saved twice



commit 6a2bffb95ca45ea42d58984543d214ec49fbc369
Author: Karthik Subramanian <itskarthik s gmail com>
Date:   Tue Jun 21 21:18:16 2011 +0530

    save file option is working but as keypress returns twice, each note is saved twice

 src/piano-activity/piano.py                      |   25 ++++++++++++++++++---
 src/piano-activity/resources/piano/savenotes.txt |    1 +
 2 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/piano-activity/piano.py b/src/piano-activity/piano.py
index 3bca94c..222e2de 100644
--- a/src/piano-activity/piano.py
+++ b/src/piano-activity/piano.py
@@ -120,6 +120,18 @@ class Gcompris_piano:
         pixbuf = gcompris.utils.load_pixmap("piano/save.svg")
         )
     gcompris.utils.item_focus_init(self.saveicon,None)
+ 
+    self.savestatus = goocanvas.Text(
+       parent = self.rootitem,
+       x = 670.0,
+       y = 280.0,
+       text = "",
+       font = 'sans bold 15',
+       fill_color = "black",
+       anchor = gtk.ANCHOR_CENTER,
+       alignment = pango.ALIGN_CENTER
+       )
+
     
     self.saveicon.connect("button-press-event", self.savenotes)
 
@@ -140,7 +152,11 @@ class Gcompris_piano:
 
   def savenotes(self, item, event, attr):
     self.save = True
-    notesfile = open("savenotes.txt","w")
+    filename = gcompris.DATA_DIR + '/' + self.gcomprisBoard.name + '/savenotes.txt'
+
+    self.notesfile = open(filename, 'w')
+    self.savestatus.props.text = "Saving.."
+   
 
   def end(self):
     print "piano end"
@@ -167,8 +183,9 @@ class Gcompris_piano:
     
     notename = fname[fname.find('/')+1:fname.find('.')]
     self.notetext.props.text = notename
-    if self.save is True:
-      notesfile.write(notename + " ")
+    if self.save == True:
+   
+      self.notesfile.write(notename + " ")
 
     print '#'+notename
     self.pianobg.props.visibility = goocanvas.ITEM_INVISIBLE
@@ -178,7 +195,7 @@ class Gcompris_piano:
     gcompris.sound.play_ogg(fname)
 
   def key_press(self, keyval, commit_str, preedit_str):
- 
+
     utf8char = gtk.gdk.keyval_to_unicode(keyval)
     allowed = ['a','s','d','f','g','h','j','k','w','e','t','y','u']
     strn = u'%c' % utf8char
diff --git a/src/piano-activity/resources/piano/savenotes.txt b/src/piano-activity/resources/piano/savenotes.txt
old mode 100644
new mode 100755
index e69de29..4a09261
--- a/src/piano-activity/resources/piano/savenotes.txt
+++ b/src/piano-activity/resources/piano/savenotes.txt
@@ -0,0 +1 @@
+c2 c2 d2 d2 e2 e2 f2 f2 c2 c2 d2 d2 e2 e2 f2 f2 g2 g2 a2 a2 b2 b2 a2 a2 g2 g2 a2 a2 g2 g2 f2 f2 e2 e2 d2 d2 c2 c2 
\ No newline at end of file



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]