diff options
author | Gonzalo Odiard <godiard@sugarlabs.org> | 2011-02-12 21:32:21 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@sugarlabs.org> | 2011-02-12 21:32:21 (GMT) |
commit | 5aa984020832ee87513570c5f5593b6f721c9eea (patch) | |
tree | ac4a41c10a47fba42fa20703a641cd5eb142ff8b /epubadapter.py | |
parent | 5832d4df2cfd4478463ec581e21ac4f2bc92ad21 (diff) |
Get back functionalities in EPUB framework
- TOC, zoom and find are working in epub
- All the code specific to a backend is moved outsude of readactivity.py, readtoolbar.py and readtopbar.py
- Rename adapter classes to avoid confusion
Diffstat (limited to 'epubadapter.py')
-rw-r--r-- | epubadapter.py | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/epubadapter.py b/epubadapter.py index a11cdd7..2d4a913 100644 --- a/epubadapter.py +++ b/epubadapter.py @@ -3,15 +3,52 @@ import logging import epubview - _logger = logging.getLogger('read-activity') -class View(epubview.EpubView): +class EpubViewer(epubview.EpubView): def __init__(self): epubview.EpubView.__init__(self) + def setup(self, activity): + self.set_screen_dpi(activity.dpi) + self.connect('selection-changed', + activity._view_selection_changed_cb) + + activity._hbox.pack_start(self, expand=True, fill=True) + self.show_all() + + def load_document(self, file_path): + self.set_document(EpubDocument(self, file_path.replace('file://', ''))) + + def load_metadata(self, activity): + pass + + def update_metadata(self, activity): + pass + + def zoom_to_width(self): + pass + + def zoom_to_best_fit(self): + pass + + def zoom_to_actual_size(self): + pass + + def can_zoom_to_width(self): + return False + + def connect_zoom_handler(self, handler): + self._zoom_handler = handler + self._view_notify_zoom_handler = \ + self.connect('notify::scale', handler) + return self._view_notify_zoom_handler + + def connect_page_changed_handler(self, handler): + self.connect('page-changed', handler) + def _try_load_page(self, n): if self._ready: self._load_page(n) @@ -23,6 +60,7 @@ class View(epubview.EpubView): return def find_set_highlight_search(self, set_highlight_search): + #TODO : what is this? return def set_current_page(self, n): @@ -38,12 +76,32 @@ class View(epubview.EpubView): def get_current_page(self): return int(self._loaded_page - 1) + def update_toc(self, activity): + if self._epub.has_document_links(): + activity._navigator_toolbar_button.show() + activity._navigator.show_all() + + activity._toc_model = self._epub.get_links_model() + activity._navigator.set_model(activity._toc_model) + activity._navigator.set_active(0) + return True + else: + return False + def find_changed(self, job, page=None): self._find_changed(job) def handle_link(self, link): self._load_file(link) + def setup_find_job(self, text, updated_cb): + self._find_job = JobFind(document=self._epub, + start_page=0, n_pages=self.get_pagecount(), + text=text, case_sensitive=False) + self._find_updated_handler = self._find_job.connect('updated', + updated_cb) + return self._find_job, self._find_updated_handler + class EpubDocument(epubview.Epub): @@ -63,5 +121,7 @@ class EpubDocument(epubview.Epub): class JobFind(epubview.JobFind): - def __init__(self, document, start_page, n_pages, text, case_sensitive=False): - epubview.JobFind.__init__(self, document, start_page, n_pages, text, case_sensitive=False) + def __init__(self, document, start_page, n_pages, text, + case_sensitive=False): + epubview.JobFind.__init__(self, document, start_page, n_pages, text, + case_sensitive=False) |