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>
Gonzalo Odiard
12 years ago
1 | 1 |
import logging
|
2 | 2 |
|
3 | 3 |
import epubview
|
|
4 |
|
4 | 5 |
import speech
|
5 | 6 |
|
6 | 7 |
from cStringIO import StringIO
|
14 | 14 |
# along with this program; if not, write to the Free Software
|
15 | 15 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
16 | 16 |
|
17 | |
from gi.repository import GObject
|
18 | |
|
19 | |
GObject.threads_init()
|
20 | |
|
21 | 17 |
from epub import _Epub as Epub
|
22 | 18 |
from epubview import _View as EpubView
|
23 | 19 |
from jobs import _JobFind as JobFind
|
27 | 27 |
from gi.repository import GObject
|
28 | 28 |
from gi.repository import Gtk
|
29 | 29 |
from gi.repository import Gdk
|
|
30 |
|
|
31 |
GObject.threads_init()
|
|
32 |
|
30 | 33 |
import telepathy
|
31 | 34 |
|
32 | 35 |
from sugar3.activity import activity
|
|
50 | 53 |
from readsidebar import Sidebar
|
51 | 54 |
from readtopbar import TopBar
|
52 | 55 |
from readdb import BookmarkManager
|
53 | |
import epubadapter
|
54 | |
import evinceadapter
|
55 | |
import textadapter
|
56 | 56 |
import speech
|
57 | 57 |
from sugarmenuitem import SugarMenuItem
|
58 | 58 |
|
|
787 | 787 |
return
|
788 | 788 |
mimetype = mime.get_for_file(filepath)
|
789 | 789 |
if mimetype == 'application/epub+zip':
|
|
790 |
import epubadapter
|
790 | 791 |
self._view = epubadapter.EpubViewer()
|
791 | 792 |
elif mimetype == 'text/plain' or mimetype == 'application/zip':
|
|
793 |
import textadapter
|
792 | 794 |
self._view = textadapter.TextViewer()
|
793 | 795 |
else:
|
|
796 |
import evinceadapter
|
794 | 797 |
self._view = evinceadapter.EvinceViewer()
|
795 | 798 |
|
796 | 799 |
self._view.setup(self)
|