Codebase list sugar-read-activity / 5aeab07
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
3 changed file(s) with 7 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
11 import logging
22
33 import epubview
4
45 import speech
56
67 from cStringIO import StringIO
1414 # along with this program; if not, write to the Free Software
1515 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1616
17 from gi.repository import GObject
18
19 GObject.threads_init()
20
2117 from epub import _Epub as Epub
2218 from epubview import _View as EpubView
2319 from jobs import _JobFind as JobFind
2727 from gi.repository import GObject
2828 from gi.repository import Gtk
2929 from gi.repository import Gdk
30
31 GObject.threads_init()
32
3033 import telepathy
3134
3235 from sugar3.activity import activity
5053 from readsidebar import Sidebar
5154 from readtopbar import TopBar
5255 from readdb import BookmarkManager
53 import epubadapter
54 import evinceadapter
55 import textadapter
5656 import speech
5757 from sugarmenuitem import SugarMenuItem
5858
787787 return
788788 mimetype = mime.get_for_file(filepath)
789789 if mimetype == 'application/epub+zip':
790 import epubadapter
790791 self._view = epubadapter.EpubViewer()
791792 elif mimetype == 'text/plain' or mimetype == 'application/zip':
793 import textadapter
792794 self._view = textadapter.TextViewer()
793795 else:
796 import evinceadapter
794797 self._view = evinceadapter.EvinceViewer()
795798
796799 self._view.setup(self)