After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703595 - Search sidebar is not updated after reloading a document
Search sidebar is not updated after reloading a document
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: PDF
3.9.x
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks: 724760
 
 
Reported: 2013-07-04 09:11 UTC by Germán Poo-Caamaño
Modified: 2014-02-23 14:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The patch is attached. (922 bytes, patch)
2014-02-18 19:56 UTC, Saurav Agarwalla
reviewed Details | Review
Updated the patch (1.54 KB, patch)
2014-02-22 19:23 UTC, Saurav Agarwalla
committed Details | Review

Description Germán Poo-Caamaño 2013-07-04 09:11:05 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).
Comment 1 Saurav Agarwalla 2014-02-18 19:56:04 UTC
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.
Comment 2 Carlos Garcia Campos 2014-02-19 17:49:45 UTC
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);
        }
Comment 3 Saurav Agarwalla 2014-02-22 13:30:32 UTC
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.
Comment 4 José Aliste 2014-02-22 15:36:45 UTC
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.
Comment 5 Saurav Agarwalla 2014-02-22 19:23:08 UTC
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.
Comment 6 Carlos Garcia Campos 2014-02-23 10:42:27 UTC
(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 7 Carlos Garcia Campos 2014-02-23 10:48:30 UTC
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.
Comment 8 Saurav Agarwalla 2014-02-23 14:09:58 UTC
Great. Thanks for bearing with me through this process. I am still trying to learn.