From 5771b0c895d2b5646da0caccb4df7d991b313e36 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 19 Jul 2007 20:19:03 +0000 Subject: Change xbook -> read --- diff --git a/activity/activity.info b/activity/activity.info index 1ab62ef..ad5fb97 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -2,7 +2,8 @@ name = Read service_name = org.laptop.sugar.ReadActivity icon = activity-read -class = XbookActivity.XbookActivity +class = readactivity.ReadActivity show_launcher = no activity_version = 22 mime_types = application/pdf + diff --git a/XbookActivity.py b/readactivity.py index 61efce0..a710d85 100644 --- a/XbookActivity.py +++ b/readactivity.py @@ -25,7 +25,7 @@ import os from sugar.activity import activity from sugar import network -from xbooktoolbar import XbookToolbar +from readtoolbar import ReadToolbar _READ_PORT = 17982 @@ -38,14 +38,14 @@ class ReadHTTPServer(network.GlibTCPServer): self._filepath = filepath network.GlibTCPServer.__init__(self, server_address, ReadHTTPRequestHandler) -class XbookActivity(activity.Activity): +class ReadActivity(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) self._document = None self._filepath = None self._fileserver = None - logging.debug('Starting xbook...') + logging.debug('Starting read...') self.set_title(_('Read Activity')) evince.job_queue_init() @@ -53,7 +53,7 @@ class XbookActivity(activity.Activity): toolbox = activity.ActivityToolbox(self) - self._toolbar = XbookToolbar(self._view) + self._toolbar = ReadToolbar(self._view) toolbox.add_toolbar(_('View'), self._toolbar) self._toolbar.show() @@ -74,7 +74,8 @@ class XbookActivity(activity.Activity): if handle.uri: self._load_document(handle.uri) - elif self._shared_activity: + + if self._shared_activity or not self._document: self._tried_buddies = [] if self.get_shared(): # Already joined for some reason, just get the document @@ -84,16 +85,12 @@ class XbookActivity(activity.Activity): self.connect("joined", self._joined_cb) def read_file(self, file_path): - logging.debug('XbookActivity.read_file: ' + file_path) + logging.debug('ReadActivity.read_file: ' + file_path) self._load_document('file://' + file_path) def _download_result_cb(self, getter, tempfile, suggested_name, buddy): del self._tried_buddies logging.debug("Got document %s (%s) from %s (%s)" % (tempfile, suggested_name, buddy.props.nick, buddy.props.ip4_address)) - import shutil - dest = os.path.join(os.path.expanduser("~"), suggested_name) - shutil.copyfile(tempfile, dest) - os.remove(tempfile) self._load_document("file://%s" % dest) def _download_error_cb(self, getter, err, buddy): @@ -106,7 +103,7 @@ class XbookActivity(activity.Activity): getter.connect("finished", self._download_result_cb, buddy) getter.connect("error", self._download_error_cb, buddy) logging.debug("Starting download...") - getter.start() + getter.start(self.) return False def _get_document(self): diff --git a/xbooktoolbar.py b/readtoolbar.py index 297d64b..a5201ac 100644 --- a/xbooktoolbar.py +++ b/readtoolbar.py @@ -23,8 +23,8 @@ import gtk from sugar.graphics.toolbutton import ToolButton -class XbookToolbar(gtk.Toolbar): - __gtype_name__ = 'XbookToolbar' +class ReadToolbar(gtk.Toolbar): + __gtype_name__ = 'ReadToolbar' def __init__(self, evince_view): gtk.Toolbar.__init__(self) -- cgit v0.9.1