Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Speak.activity
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-07-14 07:34:35 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-07-14 07:34:35 (GMT)
commit7b4871ee66b54fc1b31e8e5e3ddc09a90ba9ac98 (patch)
treef9fe183be35d4f95659edb0d4ec7cb976385bf93 /Speak.activity
parent16ce908f8277589f9b91caec23e728aaf1644d75 (diff)
Move changed cb to widgets.Voices
Diffstat (limited to 'Speak.activity')
-rw-r--r--Speak.activity/activity.py12
-rw-r--r--Speak.activity/brain.py7
-rw-r--r--Speak.activity/voice.py3
-rw-r--r--Speak.activity/widgets.py20
4 files changed, 31 insertions, 11 deletions
diff --git a/Speak.activity/activity.py b/Speak.activity/activity.py
index f4b324f..a0d4813 100644
--- a/Speak.activity/activity.py
+++ b/Speak.activity/activity.py
@@ -174,7 +174,7 @@ class SpeakActivity(SharedActivity):
cfg = cjson.decode(file(file_path, 'r').read())
status = self.face.status = face.Status().deserialize(cfg['status'])
- self.change_voice(status.voice.friendlyname, True)
+ self.voice_combo.resume(status.voice.friendlyname)
self.pitchadj.value = self.face.status.pitch
self.rateadj.value = self.face.status.rate
self.mouth_shape_combo.select(status.mouth)
@@ -192,16 +192,10 @@ class SpeakActivity(SharedActivity):
'text' : self.entry.props.text,
'history' : map(lambda i: i[0], self.entrycombo.get_model()) }
file(file_path, 'w').write(cjson.encode(cfg))
-
+
def share_instance(self, connection, is_initiator):
self.chat.messenger = Messenger(connection, is_initiator, self.chat)
- def change_voice(self, voice, silent):
- self.voice_combo.select(voice,
- column=1,
- silent_cb=(silent and self.voice_changed_cb or None))
- self.face.status.voice = self.voice_combo.get_active_item()[0]
-
def _cursor_moved_cb(self, entry, *ignored):
# make the eyes track the motion of the text cursor
index = entry.props.cursor_position
@@ -234,7 +228,7 @@ class SpeakActivity(SharedActivity):
# button.show()
self.voice_combo = widgets.Voices()
- self.voice_combo.select(self.face.status.voice.friendlyname)
+ self.voice_combo.select(name=self.face.status.voice.friendlyname)
combotool = ToolComboBox(self.voice_combo)
voicebar.insert(combotool, -1)
combotool.show()
diff --git a/Speak.activity/brain.py b/Speak.activity/brain.py
index e39e91e..b53f030 100644
--- a/Speak.activity/brain.py
+++ b/Speak.activity/brain.py
@@ -100,7 +100,12 @@ class Toolbar(gtk.Toolbar):
if voice != new_voice:
self.activity.change_voice(new_voice, True)
- self.voices.combo.select(new_voice, silent_cb=self._changed_cb)
+
+ try:
+ self.voices.combo.handler_block_by_func(self._changed_cb)
+ self.voices.combo.select(new_voice)
+ finally:
+ self.voices.combo.handler_unblock_by_func(self._changed_cb)
sorry = _("Sorry, I can speak %s, let's speak %s instead.") \
% (voice, new_voice)
diff --git a/Speak.activity/voice.py b/Speak.activity/voice.py
index 6cc6f9c..5fc732e 100644
--- a/Speak.activity/voice.py
+++ b/Speak.activity/voice.py
@@ -94,6 +94,9 @@ def allVoices():
return _allVoices
+def by_name(name):
+ return allVoices().get(name, defaultVoice())
+
def defaultVoice():
"""Try to figure out the default voice, from the current locale ($LANG).
Fall back to espeak's voice called Default."""
diff --git a/Speak.activity/widgets.py b/Speak.activity/widgets.py
index 9324ca3..e20ae35 100644
--- a/Speak.activity/widgets.py
+++ b/Speak.activity/widgets.py
@@ -12,14 +12,18 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import logging
+
from port.widgets import ComboBox
import voice
class Voices(ComboBox):
- def __init__(self, **kwargs):
+ def __init__(self, face, **kwargs):
ComboBox.__init__(self, **kwargs)
+ self.face = face
+
voices = voice.allVoices()
voicenames = voices.keys()
voicenames.sort()
@@ -28,3 +32,17 @@ class Voices(ComboBox):
self.append_item(voices[name], name)
self.select(voice.defaultVoice())
+
+ self.connect('changed', self._changed_cb)
+
+ def _changed_cb(self, widget):
+ self.face.status.voice = widget.props.value
+ self.face.say_notification(self.face.status.voice.friendlyname)
+
+ def resume(self, value):
+ try:
+ self.handler_block_by_func(self._changed_cb)
+ self.select(name=value)
+ self.face.status.voice = self.props.value
+ finally:
+ self.handler_unblock_by_func(self._changed_cb)