GNOME Bugzilla – Bug 703595
Search sidebar is not updated after reloading a document
Last modified: 2014-02-23 14:09:58 UTC
The scenario is working on a document in LaTeX, having the PDF loaded with evince and update it from time to time. 1. Search a word in the document (the words get highlighted) 2. Makes changes in the document (source) that involves the paragraph where is also the word searched. 3. Recompile and reload Results: The text has changed, but the selection is still in the same position. Depending of the changes, it could highlight an empty space, unrelated words or half-unrelated words. Expected results: The highlighted selections should update their positions or the search sidebar closed. The only workaround at this moment is to start the search all over again, otherwise the sidebar contains the older positions of each string matched (in the old document).
Created attachment 269608 [details] [review] The patch is attached. I have made the required changes i.e. adding a call to the find_bar_search_changed_cb in the document_changed callback. Please let me know if any further changes are needed.
Review of attachment 269608 [details] [review]: Thanks for the patch. ::: shell/ev-window.c @@ +4847,3 @@ ev_document_model_get_document (model)); + find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar), + NULL, ev_window); hmm, we are actually doing this already in ev_window_reload_job_cb(). When the document changes, it's reloaded, so maybe there's something wrong in our current approach. could you check why this is not working? /* Restart the search after reloading */ widget = gtk_window_get_focus (GTK_WINDOW (ev_window)); if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) { find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar), NULL, ev_window); }
Thanks for the review. I think I found something. For some reason, which I am unable to comprehend, there are 2 functions - ev_window_document_changed () and ev_window_document_changed_cb (). The signal for ev_window_document_changed is added in ev_window_load_job_cb() , and ev_window_open_document() while signal for ev_window_document_changed_cb is added in ev_window_init (). The ev_window_document_changed correctly calls ev_window_reload_document but there is no such call in ev_window_document_changed_cb (). Maybe that's the reason why there is no call to ev_window_reload_job_cb() as you have mentioned. If the ev_window_document_changed functions are duplicates, then maybe I can change those. Please let me know.
I realize that the names are quite similar, but look for which signals these methods are callbacks for. There are two different things. The EvFileMonitor will check for a change in the file, and then proceed to the reload, which will trigger a notify:change on the EvDocument object.
Created attachment 270004 [details] [review] Updated the patch Thanks José Aliste for the help. I have found the problem. The problem is in these lines of ev_window_reload_job_cb () - widget = gtk_window_get_focus (GTK_WINDOW (ev_window)) if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) If the user takes focus away from the Find sidebar and the document is changed, then the focused item will not be the sidebar and as a result the ancestor will not be a EGG_TYPE_FIND_BAR. This works only when the focus is in the Search box or in the sidebar but not when the user clicks somewhere on the document taking the focus away.
(In reply to comment #5) > Created an attachment (id=270004) [details] [review] > Updated the patch > > Thanks José Aliste for the help. > > I have found the problem. The problem is in these lines of > ev_window_reload_job_cb () - > > widget = gtk_window_get_focus (GTK_WINDOW (ev_window)) > if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) > > If the user takes focus away from the Find sidebar and the document is changed, > then the focused item will not be the sidebar and as a result the ancestor will > not be a EGG_TYPE_FIND_BAR. > This works only when the focus is in the Search box or in the sidebar but not > when the user clicks somewhere on the document taking the focus away. Yes, this is because in the past the fin bar was automatically closed when it lost the focus, now we should simply check that the find bar is visible
Comment on attachment 270004 [details] [review] Updated the patch Thanks. I've just pushed it, and I've also renamed ev_window_document_changed as ev_window_file_changed.
Great. Thanks for bearing with me through this process. I am still trying to learn.