# Copyright 2008 Chris Ball. # # 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """Words Activity: A multi-lingual dictionary with speech synthesis.""" """Actividad Palabras: Un diccionario multi-lengua con sintesis de habla""" import gtk import logging import pango import os import subprocess from gettext import gettext as _ from sugar.activity import activity from sugar.activity.activity import ActivityToolbox, \ get_bundle_path, get_bundle_name from sugar.graphics.icon import Icon OLD_TOOLBARS = False try: from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton from sugar.activity.widgets import ActivityButton, StopButton, \ ShareButton, KeepButton, TitleEntry except ImportError: OLD_TOOLBARS = True # logging _logger = logging.getLogger('Words') class WordsActivity(activity.Activity): """Words Activity as specified in activity.info""" def __init__(self, handle): """Set up the Words activity.""" super(WordsActivity, self).__init__(handle) self._logger = logging.getLogger('Init words-activity') # Instantiate a language model. # FIXME: We should ask the language model what langs it supports. self.langs = ["French", "German", "Italian", "Portuguese", "Spanish"] # Initial values | Valores iniciales self.fromlang = "English" self.tolang = "Spanish" import LanguageModel self.languagemodel = LanguageModel.LanguageModel() # We do not have collaboration features | No tenemos caracteristicas de colaboracion # make the share option insensitive | haciendo la opcion de compartir insensible self.max_participants = 1 # Main layout | disposicion general hbox = gtk.HBox(homogeneous=True, spacing=8) vbox = gtk.VBox(spacing=16) vbox.set_border_width(16) # Toolbar (compatibility with old-toolbars) | Toolbar, compatibilidad con barras anteriores if not OLD_TOOLBARS: toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() try: from sugar.activity.widgets import DescriptionItem except ImportError: logging.debug('DescriptionItem button is not available,' + 'toolkit version < 0.96') else: description_item = DescriptionItem(self) toolbar_box.toolbar.insert(description_item, -1) description_item.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbar_box) toolbar_box.show() else: toolbox = ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show() # transbox: