[evince] [libview] Add a job to get the list of all annotations in document



commit 38af76937af5496e20ab4d5c8fad138d3a820f92
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Mon Jul 12 12:07:18 2010 +0200

    [libview] Add a job to get the list of all annotations in document

 libview/ev-jobs.c |   82 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 libview/ev-jobs.h |   24 +++++++++++++++
 2 files changed, 106 insertions(+), 0 deletions(-)
---
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index abb82fb..e152275 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -50,6 +50,8 @@ static void ev_job_links_init             (EvJobLinks            *job);
 static void ev_job_links_class_init       (EvJobLinksClass       *class);
 static void ev_job_attachments_init       (EvJobAttachments      *job);
 static void ev_job_attachments_class_init (EvJobAttachmentsClass *class);
+static void ev_job_annots_init            (EvJobAnnots           *job);
+static void ev_job_annots_class_init      (EvJobAnnotsClass      *class);
 static void ev_job_render_init            (EvJobRender           *job);
 static void ev_job_render_class_init      (EvJobRenderClass      *class);
 static void ev_job_page_data_init         (EvJobPageData         *job);
@@ -92,6 +94,7 @@ static guint job_find_signals[FIND_LAST_SIGNAL] = { 0 };
 G_DEFINE_ABSTRACT_TYPE (EvJob, ev_job, G_TYPE_OBJECT)
 G_DEFINE_TYPE (EvJobLinks, ev_job_links, EV_TYPE_JOB)
 G_DEFINE_TYPE (EvJobAttachments, ev_job_attachments, EV_TYPE_JOB)
+G_DEFINE_TYPE (EvJobAnnots, ev_job_annots, EV_TYPE_JOB)
 G_DEFINE_TYPE (EvJobRender, ev_job_render, EV_TYPE_JOB)
 G_DEFINE_TYPE (EvJobPageData, ev_job_page_data, EV_TYPE_JOB)
 G_DEFINE_TYPE (EvJobThumbnail, ev_job_thumbnail, EV_TYPE_JOB)
@@ -435,6 +438,85 @@ ev_job_attachments_new (EvDocument *document)
 	return job;
 }
 
+/* EvJobAnnots */
+static void
+ev_job_annots_init (EvJobAnnots *job)
+{
+	EV_JOB (job)->run_mode = EV_JOB_RUN_THREAD;
+}
+
+static void
+ev_job_annots_dispose (GObject *object)
+{
+	EvJobAnnots *job;
+
+	ev_debug_message (DEBUG_JOBS, NULL);
+
+	job = EV_JOB_ANNOTS (object);
+
+	if (job->annots) {
+		g_list_foreach (job->annots, (GFunc)ev_mapping_list_unref, NULL);
+		g_list_free (job->annots);
+		job->annots = NULL;
+	}
+
+	G_OBJECT_CLASS (ev_job_annots_parent_class)->dispose (object);
+}
+
+static gboolean
+ev_job_annots_run (EvJob *job)
+{
+	EvJobAnnots *job_annots = EV_JOB_ANNOTS (job);
+	gint         i;
+
+	ev_debug_message (DEBUG_JOBS, NULL);
+	ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job);
+
+	ev_document_doc_mutex_lock ();
+	for (i = 0; i < ev_document_get_n_pages (job->document); i++) {
+		EvMappingList *mapping_list;
+		EvPage        *page;
+
+		page = ev_document_get_page (job->document, i);
+		mapping_list = ev_document_annotations_get_annotations (EV_DOCUMENT_ANNOTATIONS (job->document),
+									page);
+		g_object_unref (page);
+
+		if (mapping_list)
+			job_annots->annots = g_list_prepend (job_annots->annots, mapping_list);
+	}
+	ev_document_doc_mutex_unlock ();
+
+	job_annots->annots = g_list_reverse (job_annots->annots);
+
+	ev_job_succeeded (job);
+
+	return FALSE;
+}
+
+static void
+ev_job_annots_class_init (EvJobAnnotsClass *class)
+{
+	GObjectClass *oclass = G_OBJECT_CLASS (class);
+	EvJobClass   *job_class = EV_JOB_CLASS (class);
+
+	oclass->dispose = ev_job_annots_dispose;
+	job_class->run = ev_job_annots_run;
+}
+
+EvJob *
+ev_job_annots_new (EvDocument *document)
+{
+	EvJob *job;
+
+	ev_debug_message (DEBUG_JOBS, NULL);
+
+	job = g_object_new (EV_TYPE_JOB_ANNOTS, NULL);
+	job->document = g_object_ref (document);
+
+	return job;
+}
+
 /* EvJobRender */
 static void
 ev_job_render_init (EvJobRender *job)
diff --git a/libview/ev-jobs.h b/libview/ev-jobs.h
index 7690731..7596d76 100644
--- a/libview/ev-jobs.h
+++ b/libview/ev-jobs.h
@@ -51,6 +51,9 @@ typedef struct _EvJobLinksClass EvJobLinksClass;
 typedef struct _EvJobAttachments EvJobAttachments;
 typedef struct _EvJobAttachmentsClass EvJobAttachmentsClass;
 
+typedef struct _EvJobAnnots EvJobAnnots;
+typedef struct _EvJobAnnotsClass EvJobAnnotsClass;
+
 typedef struct _EvJobFonts EvJobFonts;
 typedef struct _EvJobFontsClass EvJobFontsClass;
 
@@ -88,6 +91,11 @@ typedef struct _EvJobPrintClass EvJobPrintClass;
 #define EV_JOB_ATTACHMENTS_CLASS(klass)	     (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_ATTACHMENTS, EvJobAttachmentsClass))
 #define EV_IS_JOB_ATTACHMENTS(object)	     (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_ATTACHMENTS))
 
+#define EV_TYPE_JOB_ANNOTS                   (ev_job_annots_get_type())
+#define EV_JOB_ANNOTS(object)                (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_ANNOTS, EvJobAnnots))
+#define EV_JOB_ANNOTS_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_ANNOTS, EvJobAnnotsClass))
+#define EV_IS_JOB_ANNOTS(object)             (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_ANNOTS))
+
 #define EV_TYPE_JOB_RENDER		     (ev_job_render_get_type())
 #define EV_JOB_RENDER(object)		     (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_RENDER, EvJobRender))
 #define EV_JOB_RENDER_CLASS(klass)	     (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_RENDER, EvJobRenderClass))
@@ -197,6 +205,18 @@ struct _EvJobAttachmentsClass
 	EvJobClass parent_class;
 };
 
+struct _EvJobAnnots
+{
+	EvJob parent;
+
+	GList *annots;
+};
+
+struct _EvJobAnnotsClass
+{
+	EvJobClass parent_class;
+};
+
 struct _EvJobRender
 {
 	EvJob parent;
@@ -401,6 +421,10 @@ EvJob          *ev_job_links_new          (EvDocument     *document);
 GType           ev_job_attachments_get_type (void) G_GNUC_CONST;
 EvJob          *ev_job_attachments_new      (EvDocument     *document);
 
+/* EvJobAnnots */
+GType           ev_job_annots_get_type      (void) G_GNUC_CONST;
+EvJob          *ev_job_annots_new           (EvDocument     *document);
+
 /* EvJobRender */
 GType           ev_job_render_get_type    (void) G_GNUC_CONST;
 EvJob          *ev_job_render_new         (EvDocument      *document,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]