From 1022894723040e704c73b99d4f685817d6272235 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sun, 16 Aug 2009 10:59:58 +0000 Subject: Revert export button --- (limited to 'toolbar.py') diff --git a/toolbar.py b/toolbar.py index 3004f7e..3054dec 100644 --- a/toolbar.py +++ b/toolbar.py @@ -18,9 +18,6 @@ from gettext import gettext as _ import logging -import os -import time -import dbus import abiword import gtk @@ -35,9 +32,7 @@ from sugar.graphics.objectchooser import ObjectChooser from sugar.graphics import iconentry from sugar.activity import activity from sugar.activity.widgets import * -from sugar.graphics.menuitem import MenuItem from sugar.graphics.palette import Palette -from sugar.datastore import datastore from sugar import mime from port import chooser import sugar.profile @@ -46,64 +41,6 @@ import widgets logger = logging.getLogger('write-activity') -class WriteActivityToolbarExtension: - - # file mime type, abiword exporter properties, drop down name, journal entry postfix - _EXPORT_FORMATS = [['application/rtf', _('Rich Text (RTF)'), _('RTF'), ""], - ['text/html', _('Hypertext (HTML)'), _('HTML'), "html4:yes; declare-xml:no; embed-css:yes; embed-images:yes;"], - ['text/plain', _('Plain Text (TXT)'), _('TXT'), ""]] - - def __init__(self, activity, toolbox, abiword_canvas): - - self._activity = activity - self._abiword_canvas = abiword_canvas - self._activity_toolbar = toolbox.get_activity_toolbar() - self._keep_palette = self._activity_toolbar.keep.get_palette() - - # hook up the export formats to the Keep button - for i, f in enumerate(self._EXPORT_FORMATS): - menu_item = MenuItem(f[1]) - menu_item.connect('activate', self._export_as_cb, f[0], f[2], f[3]) - self._keep_palette.menu.append(menu_item) - menu_item.show() - - def _export_as_cb(self, menu_item, mimetype, jpostfix, exp_props): - logger.debug('exporting file, mimetype: %s, exp_props: %s', mimetype, exp_props); - - # special case HTML export to set the activity name as the HTML title - if mimetype == "text/html": - exp_props += " title:" + self._activity.metadata['title'] + ';'; - - # create a new journal item - fileObject = datastore.create() - act_meta = self._activity.metadata - fileObject.metadata['title'] = act_meta['title'] + ' (' + jpostfix + ')'; - fileObject.metadata['title_set_by_user'] = act_meta['title_set_by_user'] - fileObject.metadata['mime_type'] = mimetype - fileObject.metadata['fulltext'] = \ - self._abiword_canvas.get_content(extension_or_mimetype=".txt")[:3000] - - fileObject.metadata['icon-color'] = act_meta['icon-color'] - fileObject.metadata['activity'] = act_meta['activity'] - fileObject.metadata['keep'] = act_meta['keep'] - -# TODO: Activity class should provide support for preview, see #5119 -# self._activity.take_screenshot() -# if self._activity._preview: -# preview = self._activity._get_preview() -# fileObject.metadata['preview'] = dbus.ByteArray(preview) - - fileObject.metadata['share-scope'] = act_meta['share-scope'] - - # write out the document contents in the requested format - fileObject.file_path = os.path.join(self._activity.get_activity_root(), 'instance', '%i' % time.time()) - self._abiword_canvas.save('file://' + fileObject.file_path, mimetype, exp_props) - - # store the journal item - datastore.write(fileObject, transfer_ownership=True) - fileObject.destroy() - del fileObject - class SearchToolbar(gtk.Toolbar): def __init__(self, abiword_canvas, text_toolbar): -- cgit v0.9.1