From 130a7e5a69b1af4b9c909b6c4fc4520ca120dd68 Mon Sep 17 00:00:00 2001
From: "Silas S. Brown" <ssb22@cam.ac.uk>
Date: Wed, 25 Nov 2009 09:12:42 +0000
Subject: [PATCH] Gradint update

git-svn-id: http://svn.code.sf.net/p/e-guidedog/code/ssb22/gradint@451 29193198-4895-4776-b068-10539e920549
---
 gradint-build/Makefile          |  2 +-
 gradint-build/advanced.txt      |  6 ++---
 gradint-build/src/booktime.py   |  2 +-
 gradint-build/src/filescan.py   |  2 +-
 gradint-build/src/frontend.py   | 20 +++++++++--------
 gradint-build/src/lessonplan.py |  2 +-
 gradint-build/src/loop.py       |  2 +-
 gradint-build/src/makeevent.py  |  2 +-
 gradint-build/src/play.py       |  2 +-
 gradint-build/src/recording.py  | 39 +++++++++++++++++----------------
 gradint-build/src/sequence.py   |  2 +-
 gradint-build/src/synth.py      |  2 +-
 gradint-build/src/system.py     |  2 +-
 gradint-build/src/top.py        |  2 +-
 gradint-build/thindown.py       |  2 +-
 15 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/gradint-build/Makefile b/gradint-build/Makefile
index 3312d4d..ea77a7a 100644
--- a/gradint-build/Makefile
+++ b/gradint-build/Makefile
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/advanced.txt b/gradint-build/advanced.txt
index 91076a2..71ca4bf 100644
--- a/gradint-build/advanced.txt
+++ b/gradint-build/advanced.txt
@@ -649,7 +649,7 @@ GUI_translations={
 "Big print":{"zh":u"大号字体","zh2":u"大號字體"},
 "Compressing, please wait":{"zh":u"正在压缩...","zh2":u"正在壓縮..."},
 "All recordings have been compressed to MP3.  Do you also want to make a ZIP file for sending as email?":{"zh":u"所有录音都压缩成为MP3了。 你也想做一个ZIP文件所以能随email附上吗?","zh2":u"所有錄音都壓縮成為MP3了。 你也想做一個ZIP文件所以能隨email附上嗎?"},
-"Compress all recordings":{"zh":u"压缩一切录音","zh2":u"壓縮一切錄音"},
+"Compress all":{"zh":u"压缩一切","zh2":u"壓縮一切"},
 "Play":{"zh":u"æ¼”"},
 "Re-record":{"zh":u"从新录音","zh2":u"從新錄音"},
 "(empty)":{"zh":u"(空虚)","zh2":u"(空虛)"},
@@ -657,15 +657,13 @@ GUI_translations={
 "Add more words":{"zh":u"加多词","zh2":u"加多詞"},
 "New folder":{"zh":u"新卷宗"},
 "Stop":{"zh":u"停止"},
-"Action of spacebar during recording:":{"zh":u"空格键在录音的时候的功能:","zh2":u"空格鍵在錄音的時候的功能:"},
+"Action of spacebar during recording":{"zh":u"空格键在录音的时候的功能","zh2":u"空格鍵在錄音的時候的功能"},
 "move down":{"zh":u"进步下面"},
 "move along":{"zh":u"进步右边","zh2":u"進步右邊"},
 "stop":{"zh":u"停止"},
 "(Up)":{"zh":u"(上面)"},
 "Record from %s":{"zh":u"从%s做录音","zh2":u"從%s做錄音"},
 "Record from file":{"zh":u"从文件做录音","zh2":u"從文件做錄音"},
-"Manage recorded words using Gradint":{"zh":u"用这个软件管理录音","zh2":u"用這個軟件管理錄音"},
-"Open the recorded words folder":{"zh":u"打开录音的卷宗","zh2":u"打開錄音的卷宗"},
     }
 
 # scriptVariants optionally maps language abbreviation to default script
diff --git a/gradint-build/src/booktime.py b/gradint-build/src/booktime.py
index 367246a..234fe97 100644
--- a/gradint-build/src/booktime.py
+++ b/gradint-build/src/booktime.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/filescan.py b/gradint-build/src/filescan.py
index 02b5367..fc395ca 100644
--- a/gradint-build/src/filescan.py
+++ b/gradint-build/src/filescan.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/frontend.py b/gradint-build/src/frontend.py
index a964091..3f1a71c 100644
--- a/gradint-build/src/frontend.py
+++ b/gradint-build/src/frontend.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
@@ -408,11 +408,11 @@ def deleteUser(i):
     select_userNumber(0) ; app.userNo.set(0) # save confusion
     updateUserRow()
 
-def setupScrollbar(parent,rowNo):
+def setupScrollbar(parent,rowNo=0):
     s = Tkinter.Scrollbar(parent)
-    s.grid(row=rowNo,column=cond(winCEsound or olpc,0,1),sticky="ns"+cond(winCEsound or olpc,"e","w"))
+    s.grid(row=rowNo,column=cond(winCEsound or olpc,0,1),sticky="ns"+cond(winCEsound or olpc,"w","e"))
     c=Tkinter.Canvas(parent,bd=0,width=200,height=100,yscrollcommand=s.set)
-    c.grid(row=rowNo,column=cond(winCEsound or olpc,1,0),sticky="ns"+cond(winCEsound or olpc,"w","e"))
+    c.grid(row=rowNo,column=cond(winCEsound or olpc,1,0),sticky="nsw")
     s.config(command=c.yview)
     scrolledFrame=Tkinter.Frame(c) ; c.create_window(0,0,window=scrolledFrame,anchor="nw")
     for w in [parent,c,s]:
@@ -643,6 +643,9 @@ def startTk():
                     self.BriefIntButton.pack_forget() ; del self.BriefIntButton
                 elif hasattr(self.todo,"add_briefinterrupt_button"): del self.todo.add_briefinterrupt_button # cancel pressed while still making lesson
                 del self.todo.remove_briefinterrupt_button
+            if hasattr(self.todo,"clear_text_boxes"):
+                self.Text1.set("") ; self.Text2.set("") ; self.Entry1.focus()
+                del self.todo.clear_text_boxes
             if hasattr(self.todo,"exit_ASAP"):
                 self.master.destroy()
                 self.pollInterval = 0
@@ -867,7 +870,7 @@ def startTk():
             extra_buttons_waiting_list = extra_buttons_waiting_list[1:]
         def openVocabFile(self,*args): self.fileToEdit, self.menu_response = vocabFile,"edit"
         def openAdvancedTxt(self,*args): self.fileToEdit, self.menu_response = "advanced"+dottxt,"edit"
-        def showRecordedWords(self,*args): doRecordedWordsMenu()
+        def showRecordedWords(self,*args): doRecWords()
         def showCopyFrom(self,*args):
             m=Tkinter.Menu(None, tearoff=0, takefocus=0)
             for i in range(len(lastUserNames)):
@@ -1329,7 +1332,7 @@ def gui_wrapped_main_loop():
                         listToCheck.remove(item)
                         listToCheck.append((newItem0,item[1],item[2]))
                         d.save() ; app.unset_watch_cursor = 1
-                        app.Text1.set("") ; app.Text2.set("") ; app.Entry1.focus()
+                        app.todo.clear_text_boxes = 1
                     found = 1 ; break
             if not found:
                 app.unset_watch_cursor = 1
@@ -1343,7 +1346,7 @@ def gui_wrapped_main_loop():
                 o.write(text1+"="+text2+"\n") # was " = " but it slows down parseSynthVocab
                 o.close()
                 if hasattr(app,"vocabList"): app.vocabList.append((app.Text1.get(),app.Text2.get()))
-                app.Text1.set("") ; app.Text2.set("") ; app.Entry1.focus()
+                app.todo.clear_text_boxes=1
         elif app.menu_response=="delete" or app.menu_response=="replace":
             app.set_watch_cursor = 1
             lang2,lang1 = app.toDelete
@@ -1391,8 +1394,7 @@ def gui_wrapped_main_loop():
                         d.save()
                         break
             del app.vocabList # re-read
-            app.Text1.set("") ; app.Text2.set("")
-            app.Entry1.focus()
+            app.todo.clear_text_boxes=1
             app.unset_watch_cursor = 1
             if not found: app.todo.alert = "OOPS: Item to delete/replace was not found in "+vocabFile
         if app: del app.menu_response
diff --git a/gradint-build/src/lessonplan.py b/gradint-build/src/lessonplan.py
index 70f299c..81a3621 100644
--- a/gradint-build/src/lessonplan.py
+++ b/gradint-build/src/lessonplan.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/loop.py b/gradint-build/src/loop.py
index a6f05a8..7d351b2 100644
--- a/gradint-build/src/loop.py
+++ b/gradint-build/src/loop.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/makeevent.py b/gradint-build/src/makeevent.py
index fe8be03..f784865 100644
--- a/gradint-build/src/makeevent.py
+++ b/gradint-build/src/makeevent.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/play.py b/gradint-build/src/play.py
index 25e90a9..573d932 100644
--- a/gradint-build/src/play.py
+++ b/gradint-build/src/play.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/recording.py b/gradint-build/src/recording.py
index 0b7f77c..6b43a54 100644
--- a/gradint-build/src/recording.py
+++ b/gradint-build/src/recording.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
@@ -480,6 +480,11 @@ class RecorderControls:
             button.grid(row=row,column=0,columnspan=1+3*len(self.languagesToDraw),sticky="w")
             self.coords2buttons[(row,0)] = button
             del self.current_recordFrom_button
+    def do_openInExplorer(self,*args):
+        openDirectory(self.currentDir)
+        tkMessageBox.showinfo(app.master.title(),localise("Gradint has opened the current folder for you to work on.  When you press OK, Gradint will re-scan the folder for new files."))
+        self.undraw()
+        self.draw()
     def do_recordFromFile(self,*args):
         if not tkSnack or tkSnack=="MicOnly": return tkMessageBox.showinfo(app.master.title(),localise("Sorry, cannot record from file on this computer because the tkSnack library (python-tksnack) is not installed"))
         msg1 = localise("You can record from an existing recording (i.e. copy parts from it) if you first put the existing recording into the samples folder and then press its Play button.")+"\n\n"
@@ -507,16 +512,15 @@ class RecorderControls:
 
         self.need_reRecord_enabler = 0 # no previously-existing words yet (when we get existing words we 'lock' them and have to unlock by pressing a global 'rerecord' button 1st, just in case)
 
-        Tkinter.Label(self.frame,text=localise("Action of spacebar during recording:")).grid(row=0,column=0,sticky="w")
-        r=Tkinter.Frame(self.frame)
-        r.grid(row=1,column=0,sticky="w")
+        r = Tkinter.Frame(self.frame)
+        r.grid(row=1,sticky="e",columnspan=2)
+        Tkinter.Label(r,text=localise("Action of spacebar during recording")).pack()
+        r=Tkinter.Frame(r) ; r.pack()
         Tkinter.Radiobutton(r, text=localise("move down"), variable=app.scanrow, value="0", indicatoron=1).pack({"side":"left"})
         Tkinter.Radiobutton(r, text=localise("move along"), variable=app.scanrow, value="1", indicatoron=1).pack({"side":"left"})
         Tkinter.Radiobutton(r, text=localise("stop"), variable=app.scanrow, value="2", indicatoron=1).pack({"side":"left"})
 
-        r=Tkinter.Frame(self.frame)
-        r.grid(row=2,column=0,sticky="w")
-        self.grid,self.ourCanvas = setupScrollbar(r,2)
+        self.grid,self.ourCanvas = setupScrollbar(self.frame,2)
         if hasattr(self,"oldCanvasBbox"): del self.oldCanvasBbox # unconditionally reconfigure scrollbar even if bounds are unchanged
         
         curRow = 0 ; prefix2row = {}
@@ -565,15 +569,19 @@ class RecorderControls:
         self.addMoreRow = curRow ; self.maxPrefix = maxPrefix+1
         self.add_addMore_button()
         if curRow<3 and not hadDirectories: self.addMore() # anyway
+
         r=Tkinter.Frame(self.frame)
-        r.grid(row=3,column=0)
-        Tkinter.Button(r,text=localise("Record from file"),command=self.do_recordFromFile).pack(side="left")
-        if got_program("lame"): self.CompressButton = Tkinter.Button(r,text=localise("Compress all recordings"),command=(lambda *args:self.all2mp3_or_zip()))
+        r.grid(row=3,columnspan=2)
+        r2 = Tkinter.Frame(r) ; r2.pack(side="left")
+        Tkinter.Button(r2,text=localise("Advanced"),command=self.do_openInExplorer).pack()
+        Tkinter.Button(r2,text=localise("Record from file"),command=self.do_recordFromFile).pack()
+        if got_program("lame"): self.CompressButton = Tkinter.Button(r,text=localise("Compress all"),command=(lambda *args:self.all2mp3_or_zip())) # was "Compress all recordings" but it takes too much width
         # TODO else can we see if it's possible to get the encoder on the fly, like in the main screen? (would need some restructuring)
         elif got_program("zip") and (explorerCommand or winCEsound): self.CompressButton = Tkinter.Button(r,text=localise("Zip for email"),command=(lambda *args:self.all2mp3_or_zip()))
         if hasattr(self,"CompressButton"): self.CompressButton.pack(side="left")
-        Tkinter.Button(r,text=localise(cond(recorderMode,"Quit","Back to main menu")),command=self.finished).pack()
-        Tkinter.Label(self.frame,text="Choose a word and start recording. Then press space to advance (see control at top). You can also browse and manage previous recordings. Click on filenames at left to rename (multi-line pastes are allowed); click on synthesized text to edit it.",wraplength=cond(olpc or winCEsound,self.ourCanvas.winfo_screenwidth(),min(int(self.ourCanvas.winfo_screenwidth()*.7),512))).grid(row=4,column=0) # (512-pixel max. so the column isn't too wide to read on wide screens, TODO increase if the font is large)
+        Tkinter.Button(r,text=localise(cond(recorderMode,"Quit","Back to main menu")),command=self.finished).pack(side="left")
+        
+        Tkinter.Label(self.frame,text="Choose a word and start recording. Then press space to advance (see control at top). You can also browse and manage previous recordings. Click on filenames at left to rename (multi-line pastes are allowed); click on synthesized text to edit it.",wraplength=cond(olpc or winCEsound,self.ourCanvas.winfo_screenwidth(),min(int(self.ourCanvas.winfo_screenwidth()*.7),512))).grid(row=4,columnspan=2) # (512-pixel max. so the column isn't too wide to read on wide screens, TODO increase if the font is large)
         # (Don't worry about making the text files editable - editable filenames should be enough + easier to browse the result outside Gradint; can include both languages in the filename if you like - hope the users figure this out as we don't want to make the instructions too complex)
 
 def doRecWords(): # called from GUI thread
@@ -583,10 +591,3 @@ def doRecWords(): # called from GUI thread
     try: theRecorderControls
     except: theRecorderControls=RecorderControls()
     theRecorderControls.draw()
-def doRecordedWordsMenu(*args): # called when the 'recorded words' button is pressed
-    if olpc and not explorerCommand: return doRecWords()
-    def openFolder(): app.menu_response="samples"
-    m=Tkinter.Menu(None, tearoff=0, takefocus=1)
-    m.add_command(label=localise("Manage recorded words using Gradint"), command=doRecWords)
-    m.add_command(label=localise("Open the recorded words folder"), command=openFolder)
-    m.tk_popup(app.RecordedWordsButton.winfo_rootx(),app.RecordedWordsButton.winfo_rooty(),entry="0")
diff --git a/gradint-build/src/sequence.py b/gradint-build/src/sequence.py
index 3e3d827..8646540 100644
--- a/gradint-build/src/sequence.py
+++ b/gradint-build/src/sequence.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/synth.py b/gradint-build/src/synth.py
index 2d2154c..bc69a4f 100644
--- a/gradint-build/src/synth.py
+++ b/gradint-build/src/synth.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/system.py b/gradint-build/src/system.py
index 0da8414..31aa616 100644
--- a/gradint-build/src/system.py
+++ b/gradint-build/src/system.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
diff --git a/gradint-build/src/top.py b/gradint-build/src/top.py
index 3633694..0ad78d0 100644
--- a/gradint-build/src/top.py
+++ b/gradint-build/src/top.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-program_name = "gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+."
+program_name = "gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+."
 
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
diff --git a/gradint-build/thindown.py b/gradint-build/thindown.py
index 13d92ee..2b9e9dd 100644
--- a/gradint-build/thindown.py
+++ b/gradint-build/thindown.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v0.9935 (c) 2002-2009 Silas S. Brown. GPL v3+.
+# gradint v0.9936 (c) 2002-2009 Silas S. Brown. GPL v3+.
 #    This program 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
-- 
GitLab