dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
-AC_INIT(mstardict, 0.4, roman.moravcik@gmail.com)
+AC_INIT(mstardict, 0.5, roman.moravcik@gmail.com)
AC_CONFIG_SRCDIR(src/mstardict.cpp)
dnl Don't include maintainer make-rules by default
AC_SUBST(MSTARDICT_LIBS)
AC_SUBST(MSTARDICT_CFLAGS)
+# check for libespeak (consider moving this to maemo5)
+AC_CHECK_HEADERS(espeak/speak_lib.h, [
+MSTARDICT_CFLAGS="$MSTARDICT_CFLAGS -DESPEAK"
+MSTARDICT_LIBS="$MSTARDICT_LIBS -lespeak"
+])
+
dnl fill cflags for libstardict
PKG_CHECK_MODULES(LIB_STARDICT, glib-2.0 >= 2.6.1 gtk+-2.0 >= 2.12 sigc++-2.0)
AC_SUBST(LIB_STARDICT_CFLAGS)
+mstardict (0.5-1) unstable; urgency=low
+
+ * Added espeak support.
+
+ -- Roman Moravcik <roman.moravcik@gmail.com> Mon, 15 Feb 2010 16:09:47 +0100
+
mstardict (0.4-4) unstable; urgency=low
* Result window was showing "No search reasult" after Enter
Priority: optional
Section: user/utilities
Maintainer: Roman Moravcik <roman.moravcik@gmail.com>
-Build-Depends: debhelper (>= 5.0.0), gettext, libhildon1-dev, libosso-dev, libgtk2.0-dev, libglib2.0-dev, libsigc++-2.0-dev, zlib1g-dev, maemo-optify, libgconf2-dev
+Build-Depends: debhelper (>= 5.0.0), gettext, libhildon1-dev, libosso-dev, libgtk2.0-dev, libglib2.0-dev, libsigc++-2.0-dev, zlib1g-dev, maemo-optify, libgconf2-dev, libespeak-dev
Standards-Version: 3.8.3
Package: mstardict
src/dictmngr.cpp
src/libwrapper.cpp
src/mstardict.cpp
+src/prefsdlg.cpp
src/transwin.cpp
+src/tts.cpp
msgstr ""
"Project-Id-Version: mstardict\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-02-08 16:04+0100\n"
-"PO-Revision-Date: 2010-02-08 16:04+0100\n"
+"POT-Creation-Date: 2010-02-15 11:23+0100\n"
+"PO-Revision-Date: 2010-02-15 13:26+0100\n"
"Last-Translator: Roman Moravčík <roman.moravcik@gmail.com>\n"
"Language-Team: Slovak <sk-i18n@lists.linux.sk>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../src/dictmngr.cpp:88 ../src/mstardict.cpp:380
+#: ../src/dictmngr.cpp:88 ../src/mstardict.cpp:451
msgid "Dictionaries"
msgstr "Slovníky"
-#: ../src/libwrapper.cpp:127
+#: ../src/libwrapper.cpp:126
msgid "XDXF data parsing plug-in is not found!"
msgstr "Modul pre spracovanie XDXF dát nebol nájdený!"
-#: ../src/libwrapper.cpp:132
+#: ../src/libwrapper.cpp:131
msgid "PowerWord data parsing plug-in is not found!"
msgstr "Modul na spracovanie PowerWord dát nebol nájdený!"
-#: ../src/libwrapper.cpp:137
+#: ../src/libwrapper.cpp:136
msgid "Wiki data parsing plug-in is not found!"
msgstr "Modul pre spracovanie Wiki dát nebol nájdený!"
-#: ../src/libwrapper.cpp:142
+#: ../src/libwrapper.cpp:141
msgid "HTML data parsing plug-in is not found!"
msgstr "Modul pre spracovanie HTML dát nebol nájdený!"
-#: ../src/libwrapper.cpp:147
+#: ../src/libwrapper.cpp:146
msgid "WordNet data parsing plug-in is not found!"
msgstr "Modul na spracovanie PowerWord dát nebol nájdený!"
-#: ../src/libwrapper.cpp:193
+#: ../src/libwrapper.cpp:192
msgid "<span foreground=\"red\">[Load image error!]</span>"
msgstr "<span foreground=\\\"red\\\">[Chyba pri načítaní obrázku!]</span>"
-#: ../src/libwrapper.cpp:197
+#: ../src/libwrapper.cpp:196
msgid "<span foreground=\"red\">[Missing Image]</span>"
msgstr "<span foreground=\\\"red\\\">[Chýbajúci obrázok]</span>"
-#: ../src/libwrapper.cpp:211
+#: ../src/libwrapper.cpp:210
msgid "Unknown data type"
msgstr "Neznámy dátový typ"
-#: ../src/mstardict.cpp:265
+#: ../src/mstardict.cpp:297
msgid "Searching"
msgstr "Hľadám"
-#: ../src/mstardict.cpp:267
+#: ../src/mstardict.cpp:299
msgid "Cancel"
msgstr "Zrušiť"
-#: ../src/mstardict.cpp:301
+#: ../src/mstardict.cpp:333
msgid "MStardict"
msgstr "Slovník"
#. no_search_result label
-#: ../src/mstardict.cpp:318 ../src/mstardict.cpp:463
+#: ../src/mstardict.cpp:350 ../src/mstardict.cpp:540
msgid "No search result"
msgstr "Žiadne výsledky hľadania"
-#: ../src/mstardict.cpp:386
+#: ../src/mstardict.cpp:457 ../src/prefsdlg.cpp:66
+msgid "Preferencies"
+msgstr "Predvoľby"
+
+#: ../src/mstardict.cpp:463
msgid "Quit"
msgstr "Zavrieť"
-#: ../src/mstardict.cpp:476
+#: ../src/mstardict.cpp:553
msgid "No loaded dictionary"
msgstr "Žiadne načítané slovníky"
-#: ../src/transwin.cpp:107
+#: ../src/transwin.cpp:123
msgid "Translation"
msgstr "Preklad"
+
+#: ../src/transwin.cpp:167
+msgid "Say"
+msgstr "Vysloviť"
+
+#: ../src/tts.cpp:60
+msgid "Afrikaans"
+msgstr ""
+
+#: ../src/tts.cpp:61
+msgid "Bosnian"
+msgstr ""
+
+#: ../src/tts.cpp:62
+msgid "Catalan"
+msgstr ""
+
+#: ../src/tts.cpp:63
+msgid "Czech"
+msgstr ""
+
+#: ../src/tts.cpp:64
+msgid "Welsh"
+msgstr ""
+
+#: ../src/tts.cpp:65
+msgid "Danish"
+msgstr ""
+
+#: ../src/tts.cpp:66
+msgid "German"
+msgstr ""
+
+#: ../src/tts.cpp:67
+msgid "Greek"
+msgstr ""
+
+#: ../src/tts.cpp:68
+msgid "English (Scottish)"
+msgstr ""
+
+#: ../src/tts.cpp:69
+msgid "English"
+msgstr ""
+
+#: ../src/tts.cpp:70
+msgid "English (Lancashire)"
+msgstr ""
+
+#: ../src/tts.cpp:71
+msgid "English (Received Pronunciation)"
+msgstr ""
+
+#: ../src/tts.cpp:72
+msgid "English (West Midlands)"
+msgstr ""
+
+#: ../src/tts.cpp:73
+msgid "English (American)"
+msgstr ""
+
+#: ../src/tts.cpp:74
+msgid "English (Westindies)"
+msgstr ""
+
+#: ../src/tts.cpp:75
+msgid "Esperanto"
+msgstr ""
+
+#: ../src/tts.cpp:76
+msgid "Spanish"
+msgstr ""
+
+#: ../src/tts.cpp:77
+msgid "Spanish (Latin American)"
+msgstr ""
+
+#: ../src/tts.cpp:78
+msgid "Finnish"
+msgstr ""
+
+#: ../src/tts.cpp:79
+msgid "French"
+msgstr ""
+
+#: ../src/tts.cpp:80
+msgid "French (Belgium)"
+msgstr ""
+
+#: ../src/tts.cpp:81
+msgid "Greek (Ancient)"
+msgstr ""
+
+#: ../src/tts.cpp:82
+msgid "Hindi"
+msgstr ""
+
+#: ../src/tts.cpp:83
+msgid "Croatian"
+msgstr ""
+
+#: ../src/tts.cpp:84
+msgid "Hungarian"
+msgstr ""
+
+#: ../src/tts.cpp:85
+msgid "Armenian"
+msgstr ""
+
+#: ../src/tts.cpp:86
+msgid "Armenian (West)"
+msgstr ""
+
+#: ../src/tts.cpp:87
+msgid "Indonesian"
+msgstr ""
+
+#: ../src/tts.cpp:88
+msgid "Icelandic"
+msgstr ""
+
+#: ../src/tts.cpp:89
+msgid "Italian"
+msgstr ""
+
+#: ../src/tts.cpp:90
+msgid "Lojban"
+msgstr ""
+
+#: ../src/tts.cpp:91
+msgid "Kurdish"
+msgstr ""
+
+#: ../src/tts.cpp:92
+msgid "Latin"
+msgstr ""
+
+#: ../src/tts.cpp:93
+msgid "Latvian"
+msgstr ""
+
+#: ../src/tts.cpp:94
+msgid "Macedonian"
+msgstr ""
+
+#: ../src/tts.cpp:95
+msgid "Dutch"
+msgstr ""
+
+#: ../src/tts.cpp:96
+msgid "Norwegian"
+msgstr ""
+
+#: ../src/tts.cpp:97
+msgid "Papiamento"
+msgstr ""
+
+#: ../src/tts.cpp:98
+msgid "Polish"
+msgstr ""
+
+#: ../src/tts.cpp:99
+msgid "Brazil"
+msgstr ""
+
+#: ../src/tts.cpp:100
+msgid "Portugal"
+msgstr ""
+
+#: ../src/tts.cpp:101
+msgid "Romanian"
+msgstr ""
+
+#: ../src/tts.cpp:102
+msgid "Russian"
+msgstr ""
+
+#: ../src/tts.cpp:103
+msgid "Slovak"
+msgstr ""
+
+#: ../src/tts.cpp:104
+msgid "Albanian"
+msgstr ""
+
+#: ../src/tts.cpp:105
+msgid "Serbian"
+msgstr ""
+
+#: ../src/tts.cpp:106
+msgid "Swedish"
+msgstr ""
+
+#: ../src/tts.cpp:107
+msgid "Swahihi"
+msgstr ""
+
+#: ../src/tts.cpp:108
+msgid "Tamil"
+msgstr ""
+
+#: ../src/tts.cpp:109
+msgid "Turkish"
+msgstr ""
+
+#: ../src/tts.cpp:110
+msgid "Vietnam"
+msgstr ""
+
+#: ../src/tts.cpp:111
+msgid "Mandarin"
+msgstr ""
+
+#: ../src/tts.cpp:112
+msgid "Chinese (Cantonese)"
+msgstr ""
+
+#: ../src/tts.cpp:113
+msgid "Default"
+msgstr ""
+
+#: ../src/tts.cpp:263
+msgid "Text-To-Speech"
+msgstr "Výslovnosť"
+
+#: ../src/tts.cpp:270
+msgid "Enable"
+msgstr "Povoliť"
+
+#: ../src/tts.cpp:278
+msgid "Male"
+msgstr "Muž"
+
+#: ../src/tts.cpp:282
+msgid "Female"
+msgstr "Žena"
+
+#: ../src/tts.cpp:288
+msgid "Language"
+msgstr "Jazyk"
dictmngr.cpp dictmngr.hpp \
libwrapper.cpp libwrapper.hpp \
mstardict.cpp mstardict.hpp \
- transwin.cpp transwin.hpp
+ prefsdlg.cpp prefsdlg.hpp \
+ transwin.cpp transwin.hpp \
+ tts.cpp tts.hpp
mstardict_DEPENDENCIES = lib/libstardict.a
mstardict_LDADD = @MSTARDICT_LIBS@ @LIBINTL@ lib/libstardict.a
{
}
+bool Conf::GetBool(const gchar *key,
+ bool *val)
+{
+ GConfValue *value = NULL;
+
+ if (!gconf_client)
+ return false;
+
+ value = gconf_client_get(gconf_client, key, NULL);
+ if (value) {
+ *val = gconf_value_get_bool(value);
+ gconf_value_free(value);
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool Conf::SetBool(const gchar *key,
+ bool val)
+{
+ gboolean ret = false;
+
+ if (!gconf_client)
+ return false;
+
+ ret = gconf_client_set_bool(gconf_client, key, val, NULL);
+ return ret;
+}
+
+bool Conf::GetInt(const gchar *key,
+ int *val)
+{
+ GConfValue *value = NULL;
+
+ if (!gconf_client)
+ return false;
+
+ value = gconf_client_get(gconf_client, key, NULL);
+ if (value) {
+ *val = gconf_value_get_int(value);
+ gconf_value_free(value);
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool Conf::SetInt(const gchar *key,
+ int val)
+{
+ gboolean ret = false;
+
+ if (!gconf_client)
+ return false;
+
+ ret = gconf_client_set_int(gconf_client, key, val, NULL);
+ return ret;
+}
+
+bool Conf::GetString(const gchar *key,
+ gchar **val)
+{
+ GConfValue *value = NULL;
+ const gchar *sValue = NULL;
+
+ if (!gconf_client)
+ return false;
+
+ value = gconf_client_get(gconf_client, key, NULL);
+ if (value) {
+ sValue = gconf_value_get_string(value);
+
+ if (*val)
+ g_free(*val);
+ *val = g_strdup(sValue);
+
+ gconf_value_free(value);
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool Conf::SetString(const gchar *key,
+ const gchar *val)
+{
+ gboolean ret = false;
+
+ if (!gconf_client)
+ return false;
+
+ if (!val)
+ return false;
+
+ ret = gconf_client_set_string(gconf_client, key, val, NULL);
+ return ret;
+}
+
bool Conf::GetStringList(const gchar *key,
std::list < std::string > &list)
{
Conf();
~Conf();
+ bool GetBool(const gchar *key,
+ bool *val);
+ bool SetBool(const gchar *key,
+ bool val);
+ bool GetInt(const gchar *key,
+ int *val);
+ bool SetInt(const gchar *key,
+ int val);
+ bool GetString(const gchar *key,
+ gchar **val);
+ bool SetString(const gchar *key,
+ const gchar *val);
bool GetStringList(const gchar *key,
std::list < std::string > &list);
bool SetStringList(const gchar *key,
data_size = get_uint32(data);
p += sizeof(guint32);
size_t iPlugin;
- size_t nPlugins = pMStarDict->oStarDictPlugins->ParseDataPlugins.nplugins();
+ size_t nPlugins = pMStarDict->oPlugins->ParseDataPlugins.nplugins();
unsigned int parsed_size;
ParseResult parse_result;
while (guint32(p - data) < data_size) {
for (iPlugin = 0; iPlugin < nPlugins; iPlugin++) {
parse_result.clear();
- if (pMStarDict->oStarDictPlugins->ParseDataPlugins.parse(iPlugin, p, &parsed_size, parse_result, oword)) {
+ if (pMStarDict->oPlugins->ParseDataPlugins.parse(iPlugin, p, &parsed_size, parse_result, oword)) {
p += parsed_size;
break;
}
for (i = 0; i < count; i++) {
result = (SearchResult *) g_malloc(sizeof(struct SearchResult));
result->bookname = g_strdup(dict_name(iLib).c_str());
- result->def = g_strdup(poGetOrigWord(iIndex[iLib].idx, iRealLib));
- result->exp = g_strdup(parse_data(poGetOrigWordData(iIndex[iLib].idx + i, iRealLib), poGetOrigWord(iIndex[iLib].idx, iRealLib)).c_str());
+ result->exp = g_strdup(poGetOrigWord(iIndex[iLib].idx, iRealLib));
+ result->def = g_strdup(parse_data(poGetOrigWordData(iIndex[iLib].idx + i, iRealLib), poGetOrigWord(iIndex[iLib].idx, iRealLib)).c_str());
*result_data = g_list_append(*result_data, result);
}
i = 1;
iWordIdx = poGetOrigSynonymWordIdx(iIndex[iLib].synidx + j, iRealLib);
result = (SearchResult *) g_malloc(sizeof(struct SearchResult));
result->bookname = g_strdup(dict_name(iLib).c_str());
- result->def = g_strdup(poGetOrigWord(iWordIdx, iRealLib));
- result->exp = g_strdup(parse_data(poGetOrigWordData(iWordIdx, iRealLib), poGetOrigWord(iWordIdx, iRealLib)).c_str());
+ result->exp = g_strdup(poGetOrigWord(iWordIdx, iRealLib));
+ result->def = g_strdup(parse_data(poGetOrigWordData(iWordIdx, iRealLib), poGetOrigWord(iWordIdx, iRealLib)).c_str());
*result_data = g_list_append(*result_data, result);
}
struct SearchResult {
const gchar *bookname;
- const gchar *def;
const gchar *exp;
+ const gchar *def;
};
using std::string;
#include "conf.hpp"
#include "dictmngr.hpp"
#include "libwrapper.hpp"
+#include "prefsdlg.hpp"
#include "transwin.hpp"
+#include "tts.hpp"
#include "mstardict.hpp"
MStarDict *pMStarDict;
/* initialize stardict plugins */
std::list < std::string > plugin_order_list;
std::list < std::string > plugin_disable_list;
- oStarDictPlugins = new StarDictPlugins("/usr/lib/mstardict/plugins",
- plugin_order_list,
- plugin_disable_list);
+ oPlugins = new StarDictPlugins("/usr/lib/mstardict/plugins",
+ plugin_order_list,
+ plugin_disable_list);
/* initialize dict manager */
oDict = new DictMngr(this);
+ /* initialize prefs dialog */
+ oPrefs = new PrefsDlg(this);
+
/* initialize translation window */
oTransWin = new TransWin(this);
+ /* initialize tts */
+ oTts = new Tts(this);
+
/* initialize stardict library */
oLibs = new Library(this);
}
/* deinitialize stardict library */
delete oLibs;
+ /* deinitialize tts */
+ delete oTts;
+
/* deinitialize translation window */
delete oTransWin;
+ /* deinitialize prefs dialog */
+ delete oPrefs;
+
/* deinitialize dict manager */
delete oDict;
/* deinitialize stardict plugins */
- delete oStarDictPlugins;
+ delete oPlugins;
/* deinitialize configuration */
delete oConf;
}
gboolean
+MStarDict::onPreferenciesMenuItemClicked(GtkButton *button,
+ MStarDict *mStarDict)
+{
+ mStarDict->oPrefs->CreatePrefsDialog();
+ return true;
+}
+
+gboolean
MStarDict::onQuitMenuItemClicked(GtkButton *button,
MStarDict *mStarDict)
{
}
GtkWidget *
+MStarDict::GetMainWindow()
+{
+ return window;
+}
+
+GtkWidget *
MStarDict::CreateSearchBar()
{
GtkWidget *hbox, *entry, *button;
hildon_app_menu_append(menu, GTK_BUTTON(item));
g_signal_connect(item, "clicked", G_CALLBACK(onDictionariesMenuItemClicked), this);
+ /* preferencies menu item */
+ item = hildon_gtk_button_new(HILDON_SIZE_AUTO);
+ gtk_button_set_label(GTK_BUTTON(item), _("Preferencies"));
+ hildon_app_menu_append(menu, GTK_BUTTON(item));
+ g_signal_connect(item, "clicked", G_CALLBACK(onPreferenciesMenuItemClicked), this);
+
/* quit menu item */
item = hildon_gtk_button_new(HILDON_SIZE_AUTO);
gtk_button_set_label(GTK_BUTTON(item), _("Quit"));
class TransWin;
class Library;
class MStarDict;
+class PrefsDlg;
+class Tts;
class MStarDict {
private:
MStarDict *mStarDict);
static gboolean onDictionariesMenuItemClicked(GtkButton *button,
MStarDict *mStarDict);
+ static gboolean onPreferenciesMenuItemClicked(GtkButton *button,
+ MStarDict *mStarDict);
static gboolean onQuitMenuItemClicked(GtkButton *button,
MStarDict *mStarDict);
static gboolean onLookupProgressDialogResponse(GtkDialog *dialog,
DictMngr *oDict;
TransWin *oTransWin;
Library *oLibs;
- StarDictPlugins *oStarDictPlugins;
+ StarDictPlugins *oPlugins;
+ PrefsDlg *oPrefs;
+ Tts *oTts;
GtkWidget *CreateLookupProgressDialog(bool *cancel);
void DestroyLookupProgressDialog(GtkWidget *dialog);
void CreateMainWindow();
+ GtkWidget *GetMainWindow();
GtkWidget *CreateSearchBar();
void CreateMainMenu();
--- /dev/null
+/*
+ * MStarDict - International dictionary for Maemo.
+ * Copyright (C) 2010 Roman Moravcik
+ *
+ * base on code of stardict:
+ * Copyright (C) 2003-2007 Hu Zheng <huzheng_001@163.com>
+ *
+ * based on code of sdcv:
+ * Copyright (C) 2005-2006 Evgeniy <dushistov@mail.ru>
+ *
+ * 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <list>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+
+#include "conf.hpp"
+#include "tts.hpp"
+#include "prefsdlg.hpp"
+#include "mstardict.hpp"
+
+#define _HL(str) dgettext("hildon-libs",str)
+
+PrefsDlg::PrefsDlg(MStarDict *mStarDict)
+{
+ oStarDict = mStarDict;
+}
+
+PrefsDlg::~PrefsDlg()
+{
+}
+
+void
+PrefsDlg::CreatePrefsDialog()
+{
+ GtkWidget *dialog, *vbox, *tts_conf;
+
+ /* create configuration dialog */
+ dialog = gtk_dialog_new();
+ gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(oStarDict->GetMainWindow()));
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Preferencies"));
+ gtk_dialog_add_button(GTK_DIALOG(dialog), _HL("wdgt_bd_save"), GTK_RESPONSE_ACCEPT);
+
+ /* main vbox */
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox);
+
+ /* tts configuration widget */
+ tts_conf = oStarDict->oTts->CreateTtsConfWidget();
+ gtk_box_pack_start(GTK_BOX(vbox), tts_conf, TRUE, TRUE, 0);
+
+ /* load tts configuration */
+ oStarDict->oTts->TtsConfWidgetLoadConf();
+
+ /* run the dialog */
+ gtk_widget_show_all(GTK_WIDGET(dialog));
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ /* save tts configuration */
+ oStarDict->oTts->TtsConfWidgetSaveConf();
+ }
+
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+}
--- /dev/null
+/*
+ * MStarDict - International dictionary for Maemo.
+ * Copyright (C) 2010 Roman Moravcik
+ *
+ * base on code of stardict:
+ * Copyright (C) 2003-2007 Hu Zheng <huzheng_001@163.com>
+ *
+ * based on code of sdcv:
+ * Copyright (C) 2005-2006 Evgeniy <dushistov@mail.ru>
+ *
+ * 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class MStarDict;
+
+class PrefsDlg {
+ private:
+ MStarDict *oStarDict;
+
+ public:
+ PrefsDlg(MStarDict *mStarDict);
+ ~PrefsDlg();
+
+ void CreatePrefsDialog();
+};
#include "libwrapper.hpp"
#include "mstardict.hpp"
+#include "tts.hpp"
#include "transwin.hpp"
TransWin::TransWin(MStarDict *mStarDict)
{
oStarDict = mStarDict;
window = NULL;
+ sExpression = NULL;
}
TransWin::~TransWin()
{
+ if (sExpression)
+ g_free(sExpression);
+}
+
+gboolean
+TransWin::onSayMenuItemClicked(GtkButton *button,
+ TransWin *mTransWin)
+{
+ mTransWin->oStarDict->oTts->SayText(mTransWin->sExpression);
+ return true;
}
GtkWidget *
bookname = g_markup_printf_escaped("<span color=\"dimgray\" size=\"x-small\">%s</span>",
result->bookname);
- def = g_markup_printf_escaped("<span color=\"darkred\" weight=\"heavy\" size=\"large\">%s</span>",
- result->def);
- exp = g_strdup(result->exp);
+ exp = g_markup_printf_escaped("<span color=\"darkred\" weight=\"heavy\" size=\"large\">%s</span>",
+ result->exp);
+ def = g_strdup(result->def);
vbox = gtk_vbox_new(FALSE, 0);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
- label = gtk_label_new("Definition");
+ label = gtk_label_new("Expression");
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- if (def) {
- gtk_label_set_markup(GTK_LABEL(label), def);
- g_free(def);
+ if (exp) {
+ gtk_label_set_markup(GTK_LABEL(label), exp);
+ g_free(exp);
}
label = gtk_label_new("Bookname");
g_free(bookname);
}
- label = gtk_label_new("Expresion");
+ label = gtk_label_new("Definition");
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_widget_set_size_request(label, 750, -1);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
- if (exp) {
- gtk_label_set_markup(GTK_LABEL(label), exp);
- g_free(exp);
+ if (def) {
+ gtk_label_set_markup(GTK_LABEL(label), def);
+ g_free(def);
}
+ if (sExpression == NULL)
+ sExpression = g_strdup(result->exp);
+
return vbox;
}
void
TransWin::CreateTransWindow(GList *results)
{
- GtkWidget *window, *alignment, *pannable, *vbox, *trans, *separator;
+ GtkWidget *alignment, *pannable, *vbox, *trans, *separator;
GList *result = NULL;
window = hildon_stackable_window_new();
vbox = gtk_vbox_new(FALSE, 16);
hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable), vbox);
+ if (sExpression)
+ g_free(sExpression);
+ sExpression = NULL;
+
for (result = results; result != NULL; result = result->next) {
trans = CreateTransWidget((SearchResult *) result->data);
gtk_box_pack_start(GTK_BOX(vbox), trans, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
}
+ /* create translation menu */
+ CreateTransMenu();
+
gtk_widget_show_all(window);
}
+
+void
+TransWin::CreateTransMenu()
+{
+ HildonAppMenu *menu;
+ GtkWidget *item;
+
+ menu = HILDON_APP_MENU(hildon_app_menu_new());
+ hildon_window_set_app_menu(HILDON_WINDOW(window), menu);
+
+ /* Say menu item */
+ if (oStarDict->oTts->IsEnabled()) {
+ item = hildon_gtk_button_new(HILDON_SIZE_AUTO);
+ gtk_button_set_label(GTK_BUTTON(item), _("Say"));
+ hildon_app_menu_append(menu, GTK_BUTTON(item));
+ g_signal_connect(item, "clicked", G_CALLBACK(onSayMenuItemClicked), this);
+ }
+
+ /* show main menu */
+ gtk_widget_show_all(GTK_WIDGET(menu));
+}
+
MStarDict *oStarDict;
GtkWidget *window;
+ gchar *sExpression;
+
GtkWidget *CreateTransWidget(SearchResult *result);
+ static gboolean onSayMenuItemClicked(GtkButton *button,
+ TransWin *mTransWin);
+
public:
TransWin(MStarDict *mStarDict);
~TransWin();
void CreateTransWindow(GList *result_data);
+ void CreateTransMenu();
};
--- /dev/null
+/*
+ * MStarDict - International dictionary for Maemo.
+ * Copyright (C) 2010 Roman Moravcik
+ *
+ * base on code of stardict:
+ * Copyright (C) 2003-2007 Hu Zheng <huzheng_001@163.com>
+ *
+ * based on code of sdcv:
+ * Copyright (C) 2005-2006 Evgeniy <dushistov@mail.ru>
+ *
+ * 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <list>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+
+#include "conf.hpp"
+#include "tts.hpp"
+#include "mstardict.hpp"
+
+#include <espeak/speak_lib.h>
+
+enum {
+ DISPNAME_COLUMN,
+ NAME_COLUMN,
+ N_COLUMNS
+};
+
+enum {
+ GENDER_NONE = 0,
+ GENDER_MALE,
+ GENDER_FEMALE
+};
+
+static TtsVoice voices[] = {
+ {"afrikaans", N_("Afrikaans")},
+ {"bosnian", N_("Bosnian")},
+ {"catalan", N_("Catalan")},
+ {"czech", N_("Czech")},
+ {"welsh-test", N_("Welsh")},
+ {"danish", N_("Danish")},
+ {"german", N_("German")},
+ {"greek", N_("Greek")},
+ {"en-scottish", N_("English (Scottish)")},
+ {"english", N_("English")},
+ {"lancashire", N_("English (Lancashire)")},
+ {"english_rp", N_("English (Received Pronunciation)")},
+ {"english_wmids", N_("English (West Midlands)")},
+ {"english-us", N_("English (American)")},
+ {"en-westindies", N_("English (Westindies)")},
+ {"esperanto", N_("Esperanto")},
+ {"spanish", N_("Spanish")},
+ {"spanish-latin-american", N_("Spanish (Latin American)")},
+ {"finnish", N_("Finnish")},
+ {"french", N_("French")},
+ {"french (Belgium)", N_("French (Belgium)")},
+ {"greek-ancient", N_("Greek (Ancient)")},
+ {"hindi-test", N_("Hindi")},
+ {"croatian", N_("Croatian")},
+ {"hungarian", N_("Hungarian")},
+ {"armenian", N_("Armenian")},
+ {"armenian-west", N_("Armenian (West)")},
+ {"indonesian-test", N_("Indonesian")},
+ {"icelandic-test", N_("Icelandic")},
+ {"italian", N_("Italian")},
+ {"lojban", N_("Lojban")},
+ {"kurdish", N_("Kurdish")},
+ {"latin", N_("Latin")},
+ {"latvian", N_("Latvian")},
+ {"macedonian-test", N_("Macedonian")},
+ {"dutch-test", N_("Dutch")},
+ {"norwegian", N_("Norwegian")},
+ {"papiamento-test", N_("Papiamento")},
+ {"polish", N_("Polish")},
+ {"brazil", N_("Brazil")},
+ {"portugal", N_("Portugal")},
+ {"romanian", N_("Romanian")},
+ {"russian_test", N_("Russian")},
+ {"slovak", N_("Slovak")},
+ {"albanian", N_("Albanian")},
+ {"serbian", N_("Serbian")},
+ {"swedish", N_("Swedish")},
+ {"swahihi-test", N_("Swahihi")},
+ {"tamil", N_("Tamil")},
+ {"turkish", N_("Turkish")},
+ {"vietnam-test", N_("Vietnam")},
+ {"Mandarin", N_("Chinese (Mandarin)")},
+ {"cantonese-test", N_("Chinese (Cantonese)")},
+ {"default", N_("Default")},
+ {NULL, NULL}
+};
+
+
+Tts::Tts(MStarDict *mStarDict)
+{
+ int rate = 0;
+ bool tts_enabled = false;
+ gchar *language = NULL;
+ int gender = GENDER_NONE;
+
+ oStarDict = mStarDict;
+ Enabled = false;
+
+ /* initialize espeak */
+ rate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL, 0);
+
+ /* check if tts is enabled */
+ if (!oStarDict->oConf->GetBool("/apps/maemo/mstardict/tts_enabled", &tts_enabled)) {
+ tts_enabled = true;
+ }
+ Enable(tts_enabled);
+
+ /* read configured language */
+ if (!oStarDict->oConf->GetString("/apps/maemo/mstardict/tts_language", &language)) {
+ language = g_strdup("english");
+ }
+
+ /* read configured gender */
+ if (!oStarDict->oConf->GetInt("/apps/maemo/mstardict/tts_gender", &gender)) {
+ gender = GENDER_MALE;
+ }
+ SetVoice(language, gender);
+
+ if (language) {
+ g_free(language);
+ }
+}
+
+Tts::~Tts()
+{
+ /* deinitialize espeak */
+ espeak_Terminate();
+}
+
+void
+Tts::Enable(bool bEnable)
+{
+ Enabled = bEnable;
+}
+
+bool
+Tts::IsEnabled()
+{
+ return Enabled;
+}
+
+void
+Tts::SetVoice(const gchar *language, int gender)
+{
+ espeak_VOICE voice;
+
+ memset(&voice, 0, sizeof(espeak_VOICE));
+ voice.name = language;
+ voice.gender = gender;
+
+ espeak_SetVoiceByProperties(&voice);
+}
+
+void
+Tts::SayText(const gchar *sText)
+{
+ espeak_Synth(sText, strlen(sText) + 1, 0, POS_CHARACTER, 0, espeakCHARS_UTF8, NULL, NULL);
+}
+
+GtkListStore *
+Tts::GetVoicesList()
+{
+ const espeak_VOICE **espeak_voices;
+ GtkListStore *list_store;
+ GtkTreeIter iter;
+ size_t i = 0;
+
+ list_store = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
+
+ espeak_voices = espeak_ListVoices(NULL);
+ while (espeak_voices[i]) {
+ gchar *disp_name = NULL;
+
+ for (int j = 0; voices[j].name != NULL; j++) {
+ if (!strcmp(espeak_voices[i]->name, voices[j].name)) {
+ disp_name = g_strdup(voices[j].disp_name);
+ break;
+ }
+ }
+
+ if (disp_name == NULL)
+ disp_name = g_strdup(espeak_voices[i]->name);
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set(list_store,
+ &iter,
+ DISPNAME_COLUMN, disp_name,
+ NAME_COLUMN, espeak_voices[i]->name,
+ -1);
+
+ if (disp_name)
+ g_free(disp_name);
+
+ i++;
+ }
+ return list_store;
+}
+
+gboolean
+Tts::onTtsEnableButtonClicked(GtkButton *button,
+ Tts *oTts)
+{
+ if (hildon_check_button_get_active(HILDON_CHECK_BUTTON(button))) {
+ gtk_widget_set_sensitive(GTK_WIDGET(oTts->gender_male_button), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(oTts->gender_female_button), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(oTts->language_button), TRUE);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(oTts->gender_male_button), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(oTts->gender_female_button), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(oTts->language_button), FALSE);
+ }
+ return true;
+}
+
+gboolean
+Tts::onTtsGenderButtonClicked(GtkToggleButton *button1,
+ GtkToggleButton *button2)
+{
+ if (gtk_toggle_button_get_active(button1))
+ gtk_toggle_button_set_active(button2, FALSE);
+ else
+ gtk_toggle_button_set_active(button2, TRUE);
+ return true;
+}
+
+GtkWidget *
+Tts::CreateTtsConfWidget()
+{
+ GtkWidget *frame, *vbox, *hbox;
+ GtkWidget *selector;
+ HildonTouchSelectorColumn *column;
+ GtkListStore *voices_list;
+
+ frame = gtk_frame_new(_("Text-To-Speech"));
+
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
+
+ /* enable tts button */
+ enable_button = hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT);
+ gtk_button_set_label(GTK_BUTTON(enable_button), _("Enable"));
+ gtk_box_pack_start(GTK_BOX(vbox), enable_button, TRUE, TRUE, 0);
+
+ /* gender selection */
+ hbox = gtk_hbox_new(TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+ gender_male_button = hildon_gtk_toggle_button_new(HILDON_SIZE_FINGER_HEIGHT);
+ gtk_button_set_label(GTK_BUTTON(gender_male_button), _("Male"));
+ gtk_box_pack_start(GTK_BOX(hbox), gender_male_button, TRUE, TRUE, 0);
+
+ gender_female_button = hildon_gtk_toggle_button_new(HILDON_SIZE_FINGER_HEIGHT);
+ gtk_button_set_label(GTK_BUTTON(gender_female_button), _("Female"));
+ gtk_box_pack_start(GTK_BOX(hbox), gender_female_button, TRUE, TRUE, 0);
+
+ /* language picker button */
+ language_button = hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT,
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+ hildon_button_set_title(HILDON_BUTTON(language_button), _("Language"));
+ hildon_button_set_alignment(HILDON_BUTTON(language_button), 0.0, 0.5, 1.0, 0.0);
+ hildon_button_set_title_alignment(HILDON_BUTTON(language_button), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(vbox), language_button, TRUE, TRUE, 0);
+
+ /* get list of voices */
+ voices_list = GetVoicesList();
+
+ /* sort list of voices */
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(voices_list),
+ DISPNAME_COLUMN, GTK_SORT_ASCENDING);
+
+ /* voices selector */
+ selector = hildon_touch_selector_new();
+ column = hildon_touch_selector_append_text_column(HILDON_TOUCH_SELECTOR(selector),
+ GTK_TREE_MODEL(voices_list), TRUE);
+ g_object_set(G_OBJECT(column), "text-column", DISPNAME_COLUMN, NULL);
+
+ hildon_picker_button_set_selector(HILDON_PICKER_BUTTON(language_button),
+ HILDON_TOUCH_SELECTOR(selector));
+
+ g_signal_connect(enable_button, "clicked", G_CALLBACK(onTtsEnableButtonClicked), this);
+ g_signal_connect(gender_male_button, "clicked", G_CALLBACK(onTtsGenderButtonClicked), gender_female_button);
+ g_signal_connect(gender_female_button, "clicked", G_CALLBACK(onTtsGenderButtonClicked), gender_male_button);
+
+ return frame;
+}
+
+void
+Tts::TtsConfWidgetLoadConf()
+{
+ HildonTouchSelector *selector;
+ GtkTreeIter iter;
+ int gender = GENDER_NONE;
+ gchar *language = NULL;
+ GtkTreeModel *model;
+ gboolean iter_valid = TRUE;
+
+ if (IsEnabled()) {
+ hildon_check_button_set_active(HILDON_CHECK_BUTTON(enable_button), TRUE);
+ gtk_widget_set_sensitive(language_button, TRUE);
+ } else {
+ hildon_check_button_set_active(HILDON_CHECK_BUTTON(enable_button), FALSE);
+ gtk_widget_set_sensitive(language_button, FALSE);
+ }
+
+ if (oStarDict->oConf->GetInt("/apps/maemo/mstardict/tts_gender", &gender)) {
+ if (gender == GENDER_MALE)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gender_male_button), TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gender_female_button), TRUE);
+ } else {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gender_male_button), TRUE);
+ }
+
+ if (oStarDict->oConf->GetString("/apps/maemo/mstardict/tts_language", &language)) {
+ if (language) {
+ selector = hildon_picker_button_get_selector(HILDON_PICKER_BUTTON(language_button));
+ model = hildon_touch_selector_get_model(HILDON_TOUCH_SELECTOR(selector), DISPNAME_COLUMN);
+ for (iter_valid = gtk_tree_model_get_iter_first(model, &iter); iter_valid; iter_valid = gtk_tree_model_iter_next(model, &iter)) {
+ const gchar *tmp;
+ gtk_tree_model_get(model, &iter, NAME_COLUMN, &tmp, -1);
+ if (strcmp(tmp, language) == 0) {
+ hildon_touch_selector_select_iter(HILDON_TOUCH_SELECTOR(selector), DISPNAME_COLUMN, &iter, FALSE);
+ break;
+ }
+ }
+ g_free(language);
+ }
+ } else {
+ hildon_picker_button_set_active (HILDON_PICKER_BUTTON (language_button), -1);
+ }
+}
+
+void
+Tts::TtsConfWidgetSaveConf()
+{
+ bool enabled = false;
+ HildonTouchSelector *selector;
+ GtkTreeIter iter;
+ int gender = GENDER_NONE;
+ const gchar *language;
+
+ enabled = hildon_check_button_get_active(HILDON_CHECK_BUTTON(enable_button));
+ if (oStarDict->oConf->SetBool("/apps/maemo/mstardict/tts_enabled", enabled))
+ Enable(enabled);
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gender_male_button)))
+ gender = GENDER_MALE;
+ else
+ gender = GENDER_FEMALE;
+ oStarDict->oConf->SetInt("/apps/maemo/mstardict/tts_gender", gender);
+
+ if (hildon_picker_button_get_active(HILDON_PICKER_BUTTON(language_button)) > -1) {
+ selector = hildon_picker_button_get_selector(HILDON_PICKER_BUTTON(language_button));
+ if (hildon_touch_selector_get_selected(selector, DISPNAME_COLUMN, &iter)) {
+ gtk_tree_model_get(hildon_touch_selector_get_model(selector, DISPNAME_COLUMN), &iter, NAME_COLUMN, &language, -1);
+
+ /* fixme convert back disp_name */
+ if (oStarDict->oConf->SetString("/apps/maemo/mstardict/tts_language", language))
+ SetVoice(language, gender);
+ }
+ }
+}
--- /dev/null
+/*
+ * MStarDict - International dictionary for Maemo.
+ * Copyright (C) 2010 Roman Moravcik
+ *
+ * base on code of stardict:
+ * Copyright (C) 2003-2007 Hu Zheng <huzheng_001@163.com>
+ *
+ * based on code of sdcv:
+ * Copyright (C) 2005-2006 Evgeniy <dushistov@mail.ru>
+ *
+ * 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+typedef struct {
+ const char *name;
+ const char *disp_name;
+} TtsVoice;
+
+class MStarDict;
+
+class Tts {
+ private:
+ MStarDict *oStarDict;
+ bool Enabled;
+
+ GtkWidget *enable_button;
+ GtkWidget *gender_male_button;
+ GtkWidget *gender_female_button;
+ GtkWidget *language_button;
+
+ static gboolean onTtsEnableButtonClicked(GtkButton *button,
+ Tts *oTts);
+ static gboolean onTtsGenderButtonClicked(GtkToggleButton *button1,
+ GtkToggleButton *button2);
+
+ public:
+ Tts(MStarDict *mStarDict);
+ ~Tts();
+
+ void Enable(bool bEnable);
+ bool IsEnabled();
+
+ void SetVoice(const gchar *language, int gender);
+ GtkListStore *GetVoicesList();
+
+ void SayText(const gchar *sText);
+
+ GtkWidget *CreateTtsConfWidget();
+ void TtsConfWidgetLoadConf();
+ void TtsConfWidgetSaveConf();
+};