]> www.fi.muni.cz Git - evince.git/blob - libview/ev-jobs.h
[libview] Get text and text_layout and store it in EvPageCache
[evince.git] / libview / ev-jobs.h
1 /* this file is part of evince, a gnome document viewer
2  *
3  *  Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
4  *  Copyright (C) 2005 Red Hat, Inc
5  *
6  * Evince is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * Evince is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #if !defined (__EV_EVINCE_VIEW_H_INSIDE__) && !defined (EVINCE_COMPILATION)
22 #error "Only <evince-view.h> can be included directly."
23 #endif
24
25 #ifndef __EV_JOBS_H__
26 #define __EV_JOBS_H__
27
28 #include <gio/gio.h>
29 #include <gtk/gtk.h>
30 #include <cairo.h>
31
32 #include <evince-document.h>
33
34 G_BEGIN_DECLS
35
36 typedef struct _EvJob EvJob;
37 typedef struct _EvJobClass EvJobClass;
38
39 typedef struct _EvJobRender EvJobRender;
40 typedef struct _EvJobRenderClass EvJobRenderClass;
41
42 typedef struct _EvJobPageData EvJobPageData;
43 typedef struct _EvJobPageDataClass EvJobPageDataClass;
44
45 typedef struct _EvJobThumbnail EvJobThumbnail;
46 typedef struct _EvJobThumbnailClass EvJobThumbnailClass;
47
48 typedef struct _EvJobLinks EvJobLinks;
49 typedef struct _EvJobLinksClass EvJobLinksClass;
50
51 typedef struct _EvJobAttachments EvJobAttachments;
52 typedef struct _EvJobAttachmentsClass EvJobAttachmentsClass;
53
54 typedef struct _EvJobFonts EvJobFonts;
55 typedef struct _EvJobFontsClass EvJobFontsClass;
56
57 typedef struct _EvJobLoad EvJobLoad;
58 typedef struct _EvJobLoadClass EvJobLoadClass;
59
60 typedef struct _EvJobSave EvJobSave;
61 typedef struct _EvJobSaveClass EvJobSaveClass;
62
63 typedef struct _EvJobFind EvJobFind;
64 typedef struct _EvJobFindClass EvJobFindClass;
65
66 typedef struct _EvJobLayers EvJobLayers;
67 typedef struct _EvJobLayersClass EvJobLayersClass;
68
69 typedef struct _EvJobExport EvJobExport;
70 typedef struct _EvJobExportClass EvJobExportClass;
71
72 typedef struct _EvJobPrint EvJobPrint;
73 typedef struct _EvJobPrintClass EvJobPrintClass;
74
75 #define EV_TYPE_JOB                          (ev_job_get_type())
76 #define EV_JOB(object)                       (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB, EvJob))
77 #define EV_JOB_CLASS(klass)                  (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB, EvJobClass))
78 #define EV_IS_JOB(object)                    (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB))
79 #define EV_JOB_GET_CLASS(object)             (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_JOB, EvJobClass))
80
81 #define EV_TYPE_JOB_LINKS                    (ev_job_links_get_type())
82 #define EV_JOB_LINKS(object)                 (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_LINKS, EvJobLinks))
83 #define EV_JOB_LINKS_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_LINKS, EvJobLinksClass))
84 #define EV_IS_JOB_LINKS(object)              (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_LINKS))
85
86 #define EV_TYPE_JOB_ATTACHMENTS              (ev_job_attachments_get_type())
87 #define EV_JOB_ATTACHMENTS(object)           (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_ATTACHMENTS, EvJobAttachments))
88 #define EV_JOB_ATTACHMENTS_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_ATTACHMENTS, EvJobAttachmentsClass))
89 #define EV_IS_JOB_ATTACHMENTS(object)        (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_ATTACHMENTS))
90
91 #define EV_TYPE_JOB_RENDER                   (ev_job_render_get_type())
92 #define EV_JOB_RENDER(object)                (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_RENDER, EvJobRender))
93 #define EV_JOB_RENDER_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_RENDER, EvJobRenderClass))
94 #define EV_IS_JOB_RENDER(object)             (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_RENDER))
95
96 #define EV_TYPE_JOB_PAGE_DATA                (ev_job_page_data_get_type())
97 #define EV_JOB_PAGE_DATA(object)             (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_PAGE_DATA, EvJobPageData))
98 #define EV_JOB_PAGE_DATA_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_PAGE_DATA, EvJobPageDataClass))
99 #define EV_IS_JOB_PAGE_DATA(object)          (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_PAGE_DATA))
100
101 #define EV_TYPE_JOB_THUMBNAIL                (ev_job_thumbnail_get_type())
102 #define EV_JOB_THUMBNAIL(object)             (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_THUMBNAIL, EvJobThumbnail))
103 #define EV_JOB_THUMBNAIL_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_THUMBNAIL, EvJobThumbnailClass))
104 #define EV_IS_JOB_THUMBNAIL(object)          (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_THUMBNAIL))
105
106 #define EV_TYPE_JOB_FONTS                    (ev_job_fonts_get_type())
107 #define EV_JOB_FONTS(object)                 (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_FONTS, EvJobFonts))
108 #define EV_JOB_FONTS_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_FONTS, EvJobFontsClass))
109 #define EV_IS_JOB_FONTS(object)              (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_FONTS))
110
111 #define EV_TYPE_JOB_LOAD                     (ev_job_load_get_type())
112 #define EV_JOB_LOAD(object)                  (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_LOAD, EvJobLoad))
113 #define EV_JOB_LOAD_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_LOAD, EvJobLoadClass))
114 #define EV_IS_JOB_LOAD(object)               (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_LOAD))
115
116 #define EV_TYPE_JOB_SAVE                     (ev_job_save_get_type())
117 #define EV_JOB_SAVE(object)                  (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_SAVE, EvJobSave))
118 #define EV_JOB_SAVE_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_SAVE, EvJobSaveClass))
119 #define EV_IS_JOB_SAVE(object)               (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_SAVE))
120
121 #define EV_TYPE_JOB_FIND                     (ev_job_find_get_type())
122 #define EV_JOB_FIND(object)                  (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_FIND, EvJobFind))
123 #define EV_JOB_FIND_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_FIND, EvJobFindClass))
124 #define EV_IS_JOB_FIND(object)               (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_FIND))
125
126 #define EV_TYPE_JOB_LAYERS                   (ev_job_layers_get_type())
127 #define EV_JOB_LAYERS(object)                (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_LAYERS, EvJobLayers))
128 #define EV_JOB_LAYERS_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_LAYERS, EvJobLayersClass))
129 #define EV_IS_JOB_LAYERS(object)             (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_LAYERS))
130
131 #define EV_TYPE_JOB_EXPORT                    (ev_job_export_get_type())
132 #define EV_JOB_EXPORT(object)                 (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_EXPORT, EvJobExport))
133 #define EV_JOB_EXPORT_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_EXPORT, EvJobExportClass))
134 #define EV_IS_JOB_EXPORT(object)              (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_EXPORT))
135
136 #define EV_TYPE_JOB_PRINT                    (ev_job_print_get_type())
137 #define EV_JOB_PRINT(object)                 (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_PRINT, EvJobPrint))
138 #define EV_JOB_PRINT_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_PRINT, EvJobPrintClass))
139 #define EV_IS_JOB_PRINT(object)              (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_PRINT))
140
141 typedef enum {
142         EV_JOB_RUN_THREAD,
143         EV_JOB_RUN_MAIN_LOOP
144 } EvJobRunMode;
145
146 struct _EvJob
147 {
148         GObject parent;
149         
150         EvDocument *document;
151
152         EvJobRunMode run_mode;
153
154         guint cancelled : 1;
155         guint finished : 1;
156         guint failed : 1;
157         
158         GError *error;
159         GCancellable *cancellable;
160
161         guint idle_finished_id;
162         guint idle_cancelled_id;
163 };
164
165 struct _EvJobClass
166 {
167         GObjectClass parent_class;
168
169         gboolean (*run)         (EvJob *job);
170         
171         /* Signals */
172         void     (* cancelled)  (EvJob *job);
173         void     (* finished)   (EvJob *job);
174 };
175
176 struct _EvJobLinks
177 {
178         EvJob parent;
179
180         GtkTreeModel *model;
181 };
182
183 struct _EvJobLinksClass
184 {
185         EvJobClass parent_class;
186 };
187
188 struct _EvJobAttachments
189 {
190         EvJob parent;
191
192         GList *attachments;
193 };
194
195 struct _EvJobAttachmentsClass
196 {
197         EvJobClass parent_class;
198 };
199
200 struct _EvJobRender
201 {
202         EvJob parent;
203
204         gint page;
205         gint rotation;
206         gdouble scale;
207
208         gboolean page_ready;
209         gint target_width;
210         gint target_height;
211         cairo_surface_t *surface;
212
213         gboolean include_selection;
214         cairo_surface_t *selection;
215         GdkRegion *selection_region;
216         EvRectangle selection_points;
217         EvSelectionStyle selection_style;
218         GdkColor base;
219         GdkColor text;
220 };
221
222 struct _EvJobRenderClass
223 {
224         EvJobClass parent_class;
225 };
226
227 typedef enum {
228         EV_PAGE_DATA_INCLUDE_NONE         = 0,
229         EV_PAGE_DATA_INCLUDE_LINKS        = 1 << 0,
230         EV_PAGE_DATA_INCLUDE_TEXT         = 1 << 1,
231         EV_PAGE_DATA_INCLUDE_TEXT_MAPPING = 1 << 2,
232         EV_PAGE_DATA_INCLUDE_TEXT_LAYOUT  = 1 << 3,
233         EV_PAGE_DATA_INCLUDE_IMAGES       = 1 << 4,
234         EV_PAGE_DATA_INCLUDE_FORMS        = 1 << 5,
235         EV_PAGE_DATA_INCLUDE_ANNOTS       = 1 << 6,
236         EV_PAGE_DATA_INCLUDE_ALL          = (1 << 7) - 1
237 } EvJobPageDataFlags;
238
239 struct _EvJobPageData
240 {
241         EvJob parent;
242
243         gint page;
244         EvJobPageDataFlags flags;
245
246         GList *link_mapping;
247         GList *image_mapping;
248         GList *form_field_mapping;
249         GList *annot_mapping;
250         GdkRegion *text_mapping;
251         gchar *text;
252         EvRectangle *text_layout;
253         guint text_layout_length;
254 };
255
256 struct _EvJobPageDataClass
257 {
258         EvJobClass parent_class;
259 };
260
261 struct _EvJobThumbnail
262 {
263         EvJob parent;
264
265         gint page;
266         gint rotation;
267         gdouble scale;
268         
269         GdkPixbuf *thumbnail;
270 };
271
272 struct _EvJobThumbnailClass
273 {
274         EvJobClass parent_class;
275 };
276
277 struct _EvJobFonts
278 {
279         EvJob parent;
280         gboolean scan_completed;
281 };
282
283 struct _EvJobFontsClass
284 {
285         EvJobClass parent_class;
286
287         /* Signals */
288         void (* updated)  (EvJobFonts *job,
289                            gdouble     progress);
290 };
291
292 struct _EvJobLoad
293 {
294         EvJob parent;
295
296         gchar *uri;
297         gchar *password;
298 };
299
300 struct _EvJobLoadClass
301 {
302         EvJobClass parent_class;
303 };
304
305 struct _EvJobSave
306 {
307         EvJob parent;
308
309         gchar *uri;
310         gchar *document_uri;
311 };
312
313 struct _EvJobSaveClass
314 {
315         EvJobClass parent_class;
316 };
317
318 struct _EvJobFind
319 {
320         EvJob parent;
321
322         gint start_page;
323         gint current_page;
324         gint n_pages;
325         GList **pages;
326         gchar *text;
327         gboolean case_sensitive;
328         gboolean has_results;
329 };
330
331 struct _EvJobFindClass
332 {
333         EvJobClass parent_class;
334
335         /* Signals */
336         void (* updated)  (EvJobFind *job,
337                            gint       page);
338 };
339
340 struct _EvJobLayers
341 {
342         EvJob parent;
343
344         GtkTreeModel *model;
345 };
346
347 struct _EvJobLayersClass
348 {
349         EvJobClass parent_class;
350 };
351
352 struct _EvJobExport
353 {
354         EvJob parent;
355
356         gint page;
357         EvRenderContext *rc;
358 };
359
360 struct _EvJobExportClass
361 {
362         EvJobClass parent_class;
363 };
364
365 struct _EvJobPrint
366 {
367         EvJob parent;
368
369         gint page;
370         cairo_t *cr;
371 };
372
373 struct _EvJobPrintClass
374 {
375         EvJobClass parent_class;
376 };
377
378 /* Base job class */
379 GType           ev_job_get_type           (void) G_GNUC_CONST;
380 gboolean        ev_job_run                (EvJob          *job);
381 void            ev_job_cancel             (EvJob          *job);
382 void            ev_job_failed             (EvJob          *job,
383                                            GQuark          domain,
384                                            gint            code,
385                                            const gchar    *format,
386                                            ...);
387 void            ev_job_failed_from_error  (EvJob          *job,
388                                            GError         *error);
389 void            ev_job_succeeded          (EvJob          *job);
390 gboolean        ev_job_is_finished        (EvJob          *job);
391 gboolean        ev_job_is_failed          (EvJob          *job);
392 EvJobRunMode    ev_job_get_run_mode       (EvJob          *job);
393 void            ev_job_set_run_mode       (EvJob          *job,
394                                            EvJobRunMode    run_mode);
395
396 /* EvJobLinks */
397 GType           ev_job_links_get_type     (void) G_GNUC_CONST;
398 EvJob          *ev_job_links_new          (EvDocument     *document);
399
400 /* EvJobAttachments */
401 GType           ev_job_attachments_get_type (void) G_GNUC_CONST;
402 EvJob          *ev_job_attachments_new      (EvDocument     *document);
403
404 /* EvJobRender */
405 GType           ev_job_render_get_type    (void) G_GNUC_CONST;
406 EvJob          *ev_job_render_new         (EvDocument      *document,
407                                            gint             page,
408                                            gint             rotation,
409                                            gdouble          scale,
410                                            gint             width,
411                                            gint             height);
412 void     ev_job_render_set_selection_info (EvJobRender     *job,
413                                            EvRectangle     *selection_points,
414                                            EvSelectionStyle selection_style,
415                                            GdkColor        *text,
416                                            GdkColor        *base);
417 /* EvJobPageData */
418 GType           ev_job_page_data_get_type (void) G_GNUC_CONST;
419 EvJob          *ev_job_page_data_new      (EvDocument      *document,
420                                            gint             page,
421                                            EvJobPageDataFlags flags);
422
423 /* EvJobThumbnail */
424 GType           ev_job_thumbnail_get_type (void) G_GNUC_CONST;
425 EvJob          *ev_job_thumbnail_new      (EvDocument      *document,
426                                            gint             page,
427                                            gint             rotation,
428                                            gdouble          scale);
429 /* EvJobFonts */
430 GType           ev_job_fonts_get_type     (void) G_GNUC_CONST;
431 EvJob          *ev_job_fonts_new          (EvDocument      *document);
432
433 /* EvJobLoad */
434 GType           ev_job_load_get_type      (void) G_GNUC_CONST;
435 EvJob          *ev_job_load_new           (const gchar     *uri);
436 void            ev_job_load_set_uri       (EvJobLoad       *load,
437                                            const gchar     *uri);
438 void            ev_job_load_set_password  (EvJobLoad       *job,
439                                            const gchar     *password);
440
441 /* EvJobSave */
442 GType           ev_job_save_get_type      (void) G_GNUC_CONST;
443 EvJob          *ev_job_save_new           (EvDocument      *document,
444                                            const gchar     *uri,
445                                            const gchar     *document_uri);
446 /* EvJobFind */
447 GType           ev_job_find_get_type      (void) G_GNUC_CONST;
448 EvJob          *ev_job_find_new           (EvDocument      *document,
449                                            gint             start_page,
450                                            gint             n_pages,
451                                            const gchar     *text,
452                                            gboolean         case_sensitive);
453 gint            ev_job_find_get_n_results (EvJobFind       *job,
454                                            gint             pages);
455 gdouble         ev_job_find_get_progress  (EvJobFind       *job);
456 gboolean        ev_job_find_has_results   (EvJobFind       *job);
457 GList         **ev_job_find_get_results   (EvJobFind       *job);
458
459 /* EvJobLayers */
460 GType           ev_job_layers_get_type    (void) G_GNUC_CONST;
461 EvJob          *ev_job_layers_new         (EvDocument     *document);
462
463 /* EvJobExport */
464 GType           ev_job_export_get_type    (void) G_GNUC_CONST;
465 EvJob          *ev_job_export_new         (EvDocument     *document);
466 void            ev_job_export_set_page    (EvJobExport    *job,
467                                            gint            page);
468 /* EvJobPrint */
469 GType           ev_job_print_get_type    (void) G_GNUC_CONST;
470 EvJob          *ev_job_print_new         (EvDocument     *document);
471 void            ev_job_print_set_page    (EvJobPrint     *job,
472                                           gint            page);
473 void            ev_job_print_set_cairo   (EvJobPrint     *job,
474                                           cairo_t        *cr);
475
476 G_END_DECLS
477
478 #endif /* __EV_JOBS_H__ */