From 34c1affbbf214dfd835ff6f1de4c4a03e77678c4 Mon Sep 17 00:00:00 2001 From: Sayamindu Dasgupta Date: Sun, 28 Jun 2009 13:32:17 +0000 Subject: Implement initial find support in Epub --- diff --git a/epubadapter.py b/epubadapter.py index 1366ebf..130acd0 100644 --- a/epubadapter.py +++ b/epubadapter.py @@ -1,13 +1,13 @@ import gobject import logging -from epubview import EpubView, Epub, JobFind +import epubview _logger = logging.getLogger('read-activity') -class View(EpubView): +class View(epubview.EpubView): def __init__(self): - EpubView.__init__(self) + epubview.EpubView.__init__(self) def _try_load_page(self, n): if self._ready: @@ -44,9 +44,9 @@ class View(EpubView): self._load_file(link) -class EpubDocument(Epub): +class EpubDocument(epubview.Epub): def __init__(self, view, docpath): - Epub.__init__(self, docpath) + epubview.Epub.__init__(self, docpath) self._page_cache = view def get_page_cache(self): @@ -61,6 +61,6 @@ class EpubDocument(Epub): def get_links_model(self): return self.get_toc_model() -class JobFind(JobFind): +class JobFind(epubview.JobFind): def __init__(self, document, start_page, n_pages, text, case_sensitive=False): - JobFind.__init__(self, document, start_page, n_pages, text, case_sensitive=False) + epubview.JobFind.__init__(self, document, start_page, n_pages, text, case_sensitive=False) diff --git a/readtoolbar.py b/readtoolbar.py index 7240327..40bc168 100644 --- a/readtoolbar.py +++ b/readtoolbar.py @@ -23,6 +23,8 @@ import gobject import gtk import evince +import epubadapter + import md5 from sugar.graphics.toolbutton import ToolButton @@ -115,9 +117,13 @@ class EditToolbar(activity.EditToolbar): self._clear_find_job() text = self._search_entry.props.text if text != "": - self._find_job = evince.JobFind(document=self._document, start_page=0, n_pages=self._document.get_n_pages(), text=text, case_sensitive=False) - self._find_updated_handler = self._find_job.connect('updated', self._find_updated_cb) - evince.job_scheduler_push_job(self._find_job, evince.JOB_PRIORITY_NONE) + try: + self._find_job = evince.JobFind(document=self._document, start_page=0, n_pages=self._document.get_n_pages(), text=text, case_sensitive=False) + self._find_updated_handler = self._find_job.connect('updated', self._find_updated_cb) + evince.job_scheduler_push_job(self._find_job, evince.JOB_PRIORITY_NONE) + except TypeError: + self._find_job = epubadapter.JobFind(document=self._document, start_page=0, n_pages=self._document.get_n_pages(), text=text, case_sensitive=False) + self._find_updated_handler = self._find_job.connect('updated', self._find_updated_cb) else: # FIXME: highlight nothing pass @@ -151,7 +157,7 @@ class EditToolbar(activity.EditToolbar): def _find_changed_cb(self, page, spec): self._update_find_buttons() - def _find_updated_cb(self, job, page): + def _find_updated_cb(self, job, page = None): self._evince_view.find_changed(job, page) def _find_prev_cb(self, button): -- cgit v0.9.1