From 95d72bf197c0196b690a821f21f4ce37e79fe088 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Thu, 25 Aug 2011 02:20:50 +0000 Subject: Words: removal of pippy code The activity was done in Pippy. It has unneeded functions, and svg icons embedded in the code. I'm removing them to make Words code more consistent with the rest of the activities. Signed-off-by: Manuel QuiƱones Signed-off-by: Rafael Ortiz --- diff --git a/activity.py b/activity.py deleted file mode 100644 index 061187e..0000000 --- a/activity.py +++ /dev/null @@ -1,84 +0,0 @@ -from sugar.activity import activity - -class ViewSourceActivity(activity.Activity): - """Activity subclass which handles the 'view source' key.""" - def __init__(self, handle): - super(ViewSourceActivity, self).__init__(handle) - self.__source_object_id = None # XXX: persist this across invocations? - self.connect('key-press-event', self._key_press_cb) - def _key_press_cb(self, widget, event): - import gtk - if gtk.gdk.keyval_name(event.keyval) == 'XF86Start': - self.view_source() - return True - return False - def view_source(self): - """Implement the 'view source' key by saving pippy_app.py to the - datastore, and then telling the Journal to view it.""" - if self.__source_object_id is None: - from sugar import profile - from sugar.datastore import datastore - from sugar.activity.activity import get_bundle_name, get_bundle_path - from gettext import gettext as _ - import os.path - jobject = datastore.create() - metadata = { - 'title': _('%s Source') % get_bundle_name(), - 'title_set_by_user': '1', - 'suggested_filename': 'pippy_app.py', - 'icon-color': profile.get_color().to_string(), - 'mime_type': 'text/x-python', - } - for k, v in metadata.items(): - jobject.metadata[k] = v # dict.update method is missing =( - jobject.file_path = os.path.join(get_bundle_path(), 'pippy_app.py') - datastore.write(jobject) - self.__source_object_id = jobject.object_id - jobject.destroy() - self.journal_show_object(self.__source_object_id) - def journal_show_object(self, object_id): - """Invoke journal_show_object from sugar.activity.activity if it - exists.""" - try: - from sugar.activity.activity import show_object_in_journal - show_object_in_journal(object_id) - except ImportError: - pass # no love from sugar. - -class VteActivity(ViewSourceActivity): - def __init__(sfelf, handle): - import gtk, pango, vte - super(VteActivity, self).__init__(handle) - toolbox = activity.ActivityToolbox(self) - self.set_toolbox(toolbox) - toolbox.show() - - # creates vte widget - self._vte = vte.Terminal() - self._vte.set_size(30, 5) - self._vte.set_size_request(200, 300) - font = 'Monospace 10' - self._vte.set_font(pango.FontDescription(font)) - self._vte.set_colors(gtk.gdk.color_parse ('#000000'), - gtk.gdk.color_parse ('#E7E7E7'), - []) - # ...and its scrollbar - vtebox = gtk.HBox() - vtebox.pack_start(self._vte) - vtesb = gtk.VScrollbar(self._vte.get_adjustment()) - vtesb.show() - vtebox.pack_start(vtesb, False, False, 0) - self.set_canvas(vtebox) - self.show_all() - - # now start subprocess. - self._vte.grab_focus() - bundle_path = activity.get_bundle_path() - # the 'sleep 1' works around a bug with the command dying before - # the vte widget manages to snarf the last bits of its output - self._pid = self._vte.fork_command \ - (command='/bin/sh', - argv=['/bin/sh','-c', - 'python %s/pippy_app.py; sleep 1' % bundle_path], - envv=["PYTHONPATH=%s/library" % bundle_path], - directory=bundle_path) diff --git a/activity/activity.info b/activity/activity.info index 43fd48e..be2269c 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,7 +1,7 @@ [Activity] name = Words bundle_id = org.laptop.Words -class = pippy_app.WordsActivity +class = wordsactivity.WordsActivity icon = activity-icon activity_version = 10 show_launcher = yes diff --git a/pippy_app.py b/pippy_app.py deleted file mode 100644 index 52750c2..0000000 --- a/pippy_app.py +++ /dev/null @@ -1,349 +0,0 @@ -# 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 re -import os -import os.path -import subprocess - -from gettext import gettext as _ -from dbus.service import method, signal - -from activity import ViewSourceActivity -from sugar.activity.activity import ActivityToolbox, \ - get_bundle_path, get_bundle_name - -from sugar.graphics.toolbutton import ToolButton - -# logging -logger = logging.getLogger('Words') - -SERVICE = "org.laptop.Words" -IFACE = SERVICE -PATH = "/org/laptop/Words" - -class WordsActivity(ViewSourceActivity): - """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('words-activity') - - from sugar.graphics.menuitem import MenuItem - from sugar.graphics.icon import Icon - - # Instantiate a language model. - # FIXME: We should ask the language model what langs it supports. - self.langs = ["French", "German", "Italian", "Portuguese", "Spanish"] - # Initial values. - self.fromlang = "English" - self.tolang = "Spanish" - import LanguageModel - self.languagemodel = LanguageModel.LanguageModel() - - # We do not have collaboration features - # make the share option insensitive - self.max_participants = 1 - - # Main layout. - hbox = gtk.HBox(homogeneous=True, spacing=8) - vbox = gtk.VBox(spacing=16) - vbox.set_border_width(16) - - # Toolbar (compatibility with old-toolbars). - try: - from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton - from sugar.activity.widgets import ActivityButton, StopButton, \ - ShareButton, KeepButton, TitleEntry - - 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() - - 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() - except ImportError: - toolbox = ActivityToolbox(self) - self.set_toolbox(toolbox) - toolbox.show() - - # transbox: