Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/readactivity.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-03-06 14:51:08 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-03-06 14:51:08 (GMT)
commit5aeab071e373d17102925a8a87c10c2e1fec61ef (patch)
tree0230497674a655c16726c4847510adce5c262a5b /readactivity.py
parentc94773d68f7810a54aba28031d7f6aabff39a668 (diff)
Import only the needed backend
The activity only open one tipe of file at time, but was importing all the backends. Now import the needed backend after having the mimetype, to have better startup times and lower memory use. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'readactivity.py')
-rw-r--r--readactivity.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/readactivity.py b/readactivity.py
index 201f90b..bfcedb1 100644
--- a/readactivity.py
+++ b/readactivity.py
@@ -28,6 +28,9 @@ import dbus
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Gdk
+
+GObject.threads_init()
+
import telepathy
from sugar3.activity import activity
@@ -51,9 +54,6 @@ from readtoolbar import SpeechToolbar
from readsidebar import Sidebar
from readtopbar import TopBar
from readdb import BookmarkManager
-import epubadapter
-import evinceadapter
-import textadapter
import speech
from sugarmenuitem import SugarMenuItem
@@ -788,10 +788,13 @@ class ReadActivity(activity.Activity):
return
mimetype = mime.get_for_file(filepath)
if mimetype == 'application/epub+zip':
+ import epubadapter
self._view = epubadapter.EpubViewer()
elif mimetype == 'text/plain' or mimetype == 'application/zip':
+ import textadapter
self._view = textadapter.TextViewer()
else:
+ import evinceadapter
self._view = evinceadapter.EvinceViewer()
self._view.setup(self)