Hi Ajay,Look at the Read activity sources https://git.sugarlabs.org/read/mainline/blobs/master/evinceadapter.py#line248search is working ok.GonzaloOn Thu, Apr 25, 2013 at 12:29 PM, Ajay Garg <ajaygargnsit gmail com> wrote:
_______________________________________________When I run the above program, I get the output ::Following is the ported program ::However, neither do the words highlight, nor the scrolling takes place to the appropriate page/location.I have then ported the program to GTK3, and seem to be getting the results in the callback function associated to "updated" signal.It worked perfectly fine there - highlighting the words, and scrolling to the desired page/location (if and when necessary).Hi all.I had earlier written a program using GTK2-bindings, to load a PDF, and highlight all the searched-words.
################################################################################
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import EvinceView
from gi.repository import EvinceDocument
class EvinceViewer(Gtk.ScrolledWindow):
   def __init__(self):
       Gtk.ScrolledWindow.__init__(self)
       EvinceDocument.init()
       self._view = EvinceView.View()
       self._view.find_set_highlight_search(True)
       self.add(self._view)
       self._find_job = None
       self.load_document('file:///home/ajay/Downloads/Ajay_Garg_Resume.pdf')
       self.find_text_first('demoable')
   def load_document(self, file_path):
       try:
           self._document = EvinceDocument.Document.factory_get_document(file_path)
       except GObject.GError, e:
           print 'ERROR in loading'
           return
       else:
           self._model = EvinceView.DocumentModel()
           self._model.set_document(self._document)
           self._view.set_model(self._model)
   def find_text_first(self, text):
       if text == "":
           self._view.find_set_highlight_search(False)
           return
       self._view.find_set_highlight_search(True)
       if self._find_job is not None:
           self._find_job.cancel()
           self._find_job.disconnect(self._find_updated_handler)
           self._find_job = None
       if text != "":
           self._find_job = EvinceView.JobFind.new(self._document, 0,
                                                   self._document.get_n_pages(),
                                                   text, False)
           self._find_updated_handler = \
                   self._find_job.connect('updated', self.__find_updated_cb)
           EvinceView.Job.scheduler_push_job(self._find_job,
                                             EvinceView.JobPriority.PRIORITY_NONE)
   def __find_updated_cb(self, job, page=None):
       print page
       print job
       #####
       # This method no longer seems to be present in GTK3.
       #self._view.find_changed(job, page)
       #####
       self._view.find_next()
win = Gtk.Window()
win.add(EvinceViewer())
win.maximize()
win.show_all()
Gtk.main()
################################################################################
################################################################################
0
<JobFind object at 0x8489c0c (EvJobFind at 0x84b2218)>
1
<JobFind object at 0x8489c0c (EvJobFind at 0x84b2218)>
2
<JobFind object at 0x8489c0c (EvJobFind at 0x84b2218)>
3
<JobFind object at 0x8489c0c (EvJobFind at 0x84b2218)>
4
<JobFind object at 0x8489c0c (EvJobFind at 0x84b2218)>
################################################################################This shows that "__find_updated_cb" is being hit; however, as I said, neither of "text-highlighting" or "scrolling-to-desired-location" takes place :(
I am sure that I am missing something, as ::  * I have simply done the porting in the "textual sense". * "Search" is too major a feature to not work in GTK3.
I will be grateful for any pointers, that may help rectify my situation :)
Thanks and Regards,
Ajay
evince-list mailing list
evince-list gnome org
https://mail.gnome.org/mailman/listinfo/evince-list