static gboolean dasher_action_speech_preview(DasherAction *pSelf, DasherEditor *pEditor) { const gchar *szData = dasher_editor_get_all_text(pEditor); if(!szData) return false; const gchar *szWord = strrchr(szData, ' ') + 1; DasherActionSpeechPrivate *pDasherActionSpeechPrivate = DASHER_ACTION_SPEECH_GET_PRIVATE(pSelf); if(pDasherActionSpeechPrivate->speaker != NULL) { GNOME_Speech_Speaker_say(pDasherActionSpeechPrivate->speaker, szWord, &(pDasherActionSpeechPrivate->ev)); } return false; }
static gboolean dasher_action_speech_execute(DasherAction *pSelf, DasherEditor *pEditor, int iIdx) { DasherActionSpeechPrivate *pDasherActionSpeechPrivate = DASHER_ACTION_SPEECH_GET_PRIVATE(pSelf); const char *szData; switch(iIdx) { case 0: szData = dasher_editor_get_all_text(pEditor); break; case 1: szData = dasher_editor_get_new_text(pEditor); break; case 2: szData = pDasherActionSpeechPrivate->szLast; break; default: szData = NULL; break; } if(szData && (strlen(szData) > 0)) { // XXX PRLW - bolt-on if(pDasherActionSpeechPrivate->speaker == NULL) dasher_action_speech_activate(pSelf); if(pDasherActionSpeechPrivate->speaker == NULL) cerr << "Didn't activate speech\n"; if(pDasherActionSpeechPrivate->speaker != NULL) { GNOME_Speech_Speaker_say(pDasherActionSpeechPrivate->speaker, szData, &(pDasherActionSpeechPrivate->ev)); if(pDasherActionSpeechPrivate->szLast) g_free(pDasherActionSpeechPrivate->szLast); pDasherActionSpeechPrivate->szLast = g_strdup(szData); return true; } else { return false; } } else { return false; } }
const gchar * gtk_dasher_control_get_all_text(GtkDasherControl *pControl) { GtkDasherControlPrivate *pPrivate = GTK_DASHER_CONTROL_GET_PRIVATE(pControl); return dasher_editor_get_all_text(pPrivate->pEditor); }
/** * Clear all text out of the dasher editor. * @param pSelf a reference to an instance of DasherEditor */ void dasher_editor_clear_text(DasherEditor *pSelf) { int editorTextLen = strlen(dasher_editor_get_all_text(pSelf)); dasher_editor_delete(pSelf, editorTextLen, 0); }