diff options
Diffstat (limited to 'ListenSpell.py')
-rwxr-xr-x | ListenSpell.py | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/ListenSpell.py b/ListenSpell.py index 68c8c80..689ce29 100755 --- a/ListenSpell.py +++ b/ListenSpell.py @@ -28,7 +28,10 @@ class ListenSpell(activity.Activity): DBname = "dict.db" self.las.load_db(DBname) - self.use_phoneme = False + + self.las.load_speechd_config() + + self.use_phoneme = False self.load_activity_interface() self.las.play_sound("begin") @@ -39,16 +42,7 @@ class ListenSpell(activity.Activity): def load_activity_interface(self): - #query = {'title':'listen-spell'} - #(result, count) = datastore.find(query) - #md = datastore.DSMetadata() - #if count > 0: - #dso = result[0] - #md = dso.get_metadata() - #md.get() - - - + if self.is_stand_alone: self.main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.main_window.connect("destroy", self.destroy) @@ -56,20 +50,7 @@ class ListenSpell(activity.Activity): self.main_window.set_title("Listen and Spell") if not self.is_stand_alone: - toolbox = activity.ActivityToolbox(self) - #conf_toolbar = ConfigToolBar() - - #mytoolbar = gtk.Toolbar() - #helpbut = gtk.ToolButton(label = 'help') #Stock help icon - #helpbut.set_tooltip(_("Get help")) - #helpbut.connect('clicked', self.help_button_pressed) - #mytoolbar.insert(helpbut, -1) - #helpbut.show() - #mytoolbar.show() - - - #toolbox.add_toolbar("my toolbar",mytoolbar) - + toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show_all() # Set title for our Activity @@ -213,6 +194,8 @@ class ListenSpell(activity.Activity): + + def _update_configuration(self, widget, attribute ): if attribute == "voice": self.las.speechd_config(attribute, widget.get_active_text()) @@ -224,7 +207,7 @@ class ListenSpell(activity.Activity): self.las.say_text(str(speech_text)) def speech_configuration_button_clicked(self, widget, data = None): - self.config_dialog = gtk.Dialog("Change Speech Configuration", self,0,(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + self.config_dialog = gtk.Dialog("Speech Configuration", self,0,(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) #self.las.say_text("Skill Level") #vbox = gtk.VBox(False, 8) #Vbox.set_border_width(8) @@ -238,9 +221,12 @@ class ListenSpell(activity.Activity): self.config_dialog.vbox.pack_start(speech_frame, False, False, 0) - volume_adj = gtk.Adjustment(0, -100, 101, 1, 1, 1) - rate_adj = gtk.Adjustment(0, -100, 101, 1, 1, 1) - pitch_adj = gtk.Adjustment(0, -100, 101, 1, 1, 1) + speech_config = self.las.get_speechd_config() + previous_speechd_config = speech_config + + volume_adj = gtk.Adjustment(float(speech_config['volume']), -100, 101, 1, 1, 1) + rate_adj = gtk.Adjustment(float(speech_config['rate']), -100, 101, 1, 1, 1) + pitch_adj = gtk.Adjustment(float(speech_config['pitch']), -100, 101, 1, 1, 1) volume_hscale = gtk.HScale(volume_adj) @@ -261,7 +247,13 @@ class ListenSpell(activity.Activity): #hscale4 = gtk.HScale(adj4) for voice in voice_list: voice_box.append_text(voice) - voice_box.set_active(0) + + try: + voice_index = voice_list.index(speech_config['voice']) + except ValueError: + voice_box.set_active(0) + else: + voice_box.set_active(voice_index) volume_label = gtk.Label("Volume") rate_label = gtk.Label("Rate") @@ -312,6 +304,16 @@ class ListenSpell(activity.Activity): self.config_dialog.show_all() response = self.config_dialog.run() + + if response == gtk.RESPONSE_OK: + self.config_dialog.destroy() + elif response == gtk.RESPONSE_CANCEL: + print "going back" + for k in previous_speechd_config: + #print k + " " + str(previous_speechd_config[k]) + self.las.speechd_config(k, previous_speechd_config[k]) + self.config_dialog.destroy() + @@ -480,7 +482,7 @@ class ListenSpell(activity.Activity): self.pronounelem = self.las.get_word_info(self.wordid, "phnm") #get a pronounciation from the list self.display_console("Spell...") # say the explanation if the word is ambiguous. - if self.elem != self.pronounelem and self.use_phoneme: # determine whether to bother pronouncing a description + if self.use_phoneme and self.elem != self.pronounelem: # determine whether to bother pronouncing a description self.las.say_text("Spell..." + self.pronounelem, is_phoneme = True) else: #print "Spell... " @@ -530,16 +532,16 @@ class ListenSpell(activity.Activity): ################################################################ + + def close(self): + self.game_exit() def game_exit(self): + self._logger.debug('Quiting Game') self.las.exit_game() gtk.main_quit() - ########################Game Logic############################## - - ################################################################ - - + def main(self): # All PyGTK applications must have a gtk.main(). Control ends here |