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 682875 - EvView.find_changed method is not introspectable
EvView.find_changed method is not introspectable
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
3.5.x
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-08-28 12:09 UTC by Gonzalo Odiard
Modified: 2012-09-09 08:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (1.99 KB, patch)
2012-08-30 14:16 UTC, Gonzalo Odiard
needs-work Details | Review
New patch, addressing comments (3.54 KB, patch)
2012-09-03 13:41 UTC, Gonzalo Odiard
none Details | Review
New patch, implementing proposal in comment 8 (3.57 KB, patch)
2012-09-06 18:45 UTC, Gonzalo Odiard
committed Details | Review

Description Gonzalo Odiard 2012-08-28 12:09:30 UTC
In the old bindings, we could use EvView.find_changed(), but the method is not available anymore because is marked as introspectable=0.

There are another option to search, or should be fixed in the binding?

I am using the python bindings, in the Read activity (Sugar environment)
Comment 1 Gonzalo Odiard 2012-08-30 13:14:45 UTC
I have tried the following (without success):


[sugar-build libview]$ git diff
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index 2fe62e1..99ea489 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -1659,6 +1659,12 @@ ev_job_find_has_results (EvJobFind *job)
        return job->has_results;
 }
 
+/**
+ * ev_job_find_get_results
+ * @job: #EvJobFind instance
+ * Return value: (element-type EvPage) (transfer none) : GList of results
+ * Get the results found by a JobFind
+ */
 GList **
 ev_job_find_get_results (EvJobFind *job)
 {
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 3c390bb..88c4494 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -5761,6 +5761,13 @@ jump_to_find_page (EvView *view, EvViewFindDirection direction, gint shift)
        }
 }
 
+/**
+ * ev_view_find_changed
+ * @view: #EvView instance
+ * @results: (element-type EvPage) (transfer none) : GList of results
+ * @page: current page number
+ * Set the results found by a JobFind
+ */
 void
 ev_view_find_changed (EvView *view, GList **results, gint page)
 {


In my python code:

    def find_changed(self, job, page=None):
        job_results = job.get_results()
        logging.error('job find results = %s', job_results)
        self._view.find_changed(job_results, page)

In the log, I get:

job find results = [None]

The code is very similar to the code in evince (shell/ev-window.c):

static void
ev_window_find_job_updated_cb (EvJobFind *job,
			       gint       page,
			       EvWindow  *ev_window)
{
	ev_window_update_actions (ev_window);
	
	ev_view_find_changed (EV_VIEW (ev_window->priv->view),
			      ev_job_find_get_results (job),
			      page);
	ev_window_update_find_status_message (ev_window);
}

I have tried different options in the transfer mode.
Comment 2 Gonzalo Odiard 2012-08-30 14:16:35 UTC
Created attachment 222945 [details] [review]
Proposed patch
Comment 3 Gonzalo Odiard 2012-08-31 03:47:28 UTC
Comment about the patch:

Asking in #introspection channel, Tomeu said, is not possible pass as a parameter a array of GList with the bindings.

The patch implements another method, passing the JobFind as parameter to be able to be used with introspection. This mean duplication of code, then if you agree, we can replace the old method, and modify the call in shell/ev-window.c
Comment 4 José Aliste 2012-08-31 15:17:16 UTC
Well... even if we are not guaranteeing api-stability, I think we could just "deprecate" old api that is not introspectable, but keeping it for the time being.
Comment 5 José Aliste 2012-08-31 15:19:43 UTC
(In reply to comment #3)
> Comment about the patch:
> 
> Asking in #introspection channel, Tomeu said, is not possible pass as a
> parameter a array of GList with the bindings.
> 
> The patch implements another method, passing the JobFind as parameter to be
> able to be used with introspection. This mean duplication of code, then if you
> agree, we can replace the old method, and modify the call in shell/ev-window.c

Also, could you provide an additional patch that uses the new API in shell/ev-window.c?
Comment 6 Carlos Garcia Campos 2012-08-31 15:22:23 UTC
Review of attachment 222945 [details] [review]:

The previous method should be marked as deprecated, and ev-window should be changed to use the new one.

::: libview/ev-view.c
@@ +5777,3 @@
 
+/**
+ * ev_view_find_changed_set_job

Trailing : missing here.

@@ +5780,3 @@
+ * @view: #EvView instance
+ * @job: #EvJobFind
+ * @page: current page number

Why current? This is the page where find has changed. The view already knows which page is the current one.

@@ +5784,3 @@
+ */
+void
+ev_view_find_changed_set_job (EvView *view, EvJobFind *job, gint page)

This name is very confusing, we are actually notifying that find job has changed, and find results are now available for the given page. Maybe we could merge ev_view_find_changed() and ev_view_find_search_changed() into something like ev_view_set_find_results() and handle NULL results as a special case. We still have the problem of what passing as find results. Another option would be to have a single method, ev_view_find_started(), for example, that receives the EvFindJob so that the view can connect to the "updated" signal of the job.

@@ +5791,3 @@
+		jump_to_find_page (view, EV_VIEW_FIND_NEXT, 0);
+		jump_to_find_result (view);
+	}

Instead of duplicating the code, move it to a helper function and call it from both, the new and the deprecated function.
Comment 7 Gonzalo Odiard 2012-09-03 13:41:31 UTC
Created attachment 223323 [details] [review]
New patch, addressing comments
Comment 8 Carlos Garcia Campos 2012-09-04 16:26:37 UTC
What do you think about my proposal of having a method like ev_view_find_started(), for example, that receives the EvFindJob so that the view can connect to the "updated" signal of the job and update the results internally?
Comment 9 Gonzalo Odiard 2012-09-05 12:41:04 UTC
(In reply to comment #8)
> What do you think about my proposal of having a method like
> ev_view_find_started(), for example, that receives the EvFindJob so that the
> view can connect to the "updated" signal of the job and update the results
> internally?

Honestly, I prefer keep the changes minimal. I don't program in c usually,
then the probabilities of breaking something increase with the patch size :)

And reading the code I have more doubts: In that case, should I connect "updated" or "finished" signal? What to do with the old method?

Of course, if you think is better change this, is ok with me.
Comment 10 Gonzalo Odiard 2012-09-06 18:45:55 UTC
Created attachment 223683 [details] [review]
New patch, implementing proposal in comment 8
Comment 11 Gonzalo Odiard 2012-09-06 18:47:01 UTC
(In reply to comment #8)
> What do you think about my proposal of having a method like
> ev_view_find_started(), for example, that receives the EvFindJob so that the
> view can connect to the "updated" signal of the job and update the results
> internally?

Today I feel more confident :)

I have implemented your proposal (I hope). Tested it in evince, and with python bindings.
Comment 12 Carlos Garcia Campos 2012-09-09 08:30:00 UTC
Review of attachment 223683 [details] [review]:

Pushed to git master, thanks!