Bug Summary

File:libview/ev-jobs.c
Warning:line 599, column 7
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ev-jobs.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/libview -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D LECTORDATADIR="/usr/share/lector" -D G_LOG_DOMAIN="LectorView" -D CAFELOCALEDIR="/usr/share/locale" -D LECTOR_COMPILATION -I .. -I ../libdocument -I .. -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cail-3.0 -I /usr/include/ctk-3.0/unix-print -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/libview -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-21-192604-54188-1 -x c ev-jobs.c
1/* this file is part of lector, a cafe document viewer
2 *
3 * Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
4 * Copyright (C) 2005 Red Hat, Inc
5 *
6 * Lector 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 * Lector 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#include <config.h>
22
23#include "ev-jobs.h"
24#include "ev-document-thumbnails.h"
25#include "ev-document-links.h"
26#include "ev-document-images.h"
27#include "ev-job-scheduler.h"
28#include "ev-document-forms.h"
29#include "ev-file-exporter.h"
30#include "ev-document-factory.h"
31#include "ev-document-misc.h"
32#include "ev-file-helpers.h"
33#include "ev-document-fonts.h"
34#include "ev-document-security.h"
35#include "ev-document-find.h"
36#include "ev-document-layers.h"
37#include "ev-document-print.h"
38#include "ev-document-annotations.h"
39#include "ev-document-attachments.h"
40#include "ev-document-text.h"
41#include "ev-debug.h"
42
43#include <ctk/ctk.h>
44#if ENABLE_EPUB
45#include <webkit2/webkit2.h>
46#endif
47#include <errno(*__errno_location ()).h>
48#include <glib/gstdio.h>
49#include <glib/gi18n-lib.h>
50#include <unistd.h>
51
52enum {
53 CANCELLED,
54 FINISHED,
55 LAST_SIGNAL
56};
57
58enum {
59 FONTS_UPDATED,
60 FONTS_LAST_SIGNAL
61};
62
63enum {
64 FIND_UPDATED,
65 FIND_LAST_SIGNAL
66};
67
68static guint job_signals[LAST_SIGNAL] = { 0 };
69static guint job_fonts_signals[FONTS_LAST_SIGNAL] = { 0 };
70static guint job_find_signals[FIND_LAST_SIGNAL] = { 0 };
71
72G_DEFINE_ABSTRACT_TYPE (EvJob, ev_job, G_TYPE_OBJECT)static void ev_job_init (EvJob *self); static void ev_job_class_init
(EvJobClass *klass); static GType ev_job_get_type_once (void
); static gpointer ev_job_parent_class = ((void*)0); static gint
EvJob_private_offset; static void ev_job_class_intern_init (
gpointer klass) { ev_job_parent_class = g_type_class_peek_parent
(klass); if (EvJob_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EvJob_private_offset); ev_job_class_init ((EvJobClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
ev_job_get_instance_private (EvJob *self) { return (((gpointer
) ((guint8*) (self) + (glong) (EvJob_private_offset)))); } GType
ev_job_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_get_type_once (); (
__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EvJob"
), sizeof (EvJobClass), (GClassInitFunc)(void (*)(void)) ev_job_class_intern_init
, sizeof (EvJob), (GInstanceInitFunc)(void (*)(void)) ev_job_init
, (GTypeFlags) G_TYPE_FLAG_ABSTRACT); { {{};} } return g_define_type_id
; }
73G_DEFINE_TYPE (EvJobLinks, ev_job_links, EV_TYPE_JOB)static void ev_job_links_init (EvJobLinks *self); static void
ev_job_links_class_init (EvJobLinksClass *klass); static GType
ev_job_links_get_type_once (void); static gpointer ev_job_links_parent_class
= ((void*)0); static gint EvJobLinks_private_offset; static void
ev_job_links_class_intern_init (gpointer klass) { ev_job_links_parent_class
= g_type_class_peek_parent (klass); if (EvJobLinks_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EvJobLinks_private_offset
); ev_job_links_class_init ((EvJobLinksClass*) klass); } __attribute__
((__unused__)) static inline gpointer ev_job_links_get_instance_private
(EvJobLinks *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EvJobLinks_private_offset)))); } GType ev_job_links_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_links_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_links_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobLinks"),
sizeof (EvJobLinksClass), (GClassInitFunc)(void (*)(void)) ev_job_links_class_intern_init
, sizeof (EvJobLinks), (GInstanceInitFunc)(void (*)(void)) ev_job_links_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
74G_DEFINE_TYPE (EvJobAttachments, ev_job_attachments, EV_TYPE_JOB)static void ev_job_attachments_init (EvJobAttachments *self);
static void ev_job_attachments_class_init (EvJobAttachmentsClass
*klass); static GType ev_job_attachments_get_type_once (void
); static gpointer ev_job_attachments_parent_class = ((void*)
0); static gint EvJobAttachments_private_offset; static void ev_job_attachments_class_intern_init
(gpointer klass) { ev_job_attachments_parent_class = g_type_class_peek_parent
(klass); if (EvJobAttachments_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EvJobAttachments_private_offset); ev_job_attachments_class_init
((EvJobAttachmentsClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer ev_job_attachments_get_instance_private
(EvJobAttachments *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EvJobAttachments_private_offset)))); } GType ev_job_attachments_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_attachments_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_attachments_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobAttachments"
), sizeof (EvJobAttachmentsClass), (GClassInitFunc)(void (*)(
void)) ev_job_attachments_class_intern_init, sizeof (EvJobAttachments
), (GInstanceInitFunc)(void (*)(void)) ev_job_attachments_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
75G_DEFINE_TYPE (EvJobAnnots, ev_job_annots, EV_TYPE_JOB)static void ev_job_annots_init (EvJobAnnots *self); static void
ev_job_annots_class_init (EvJobAnnotsClass *klass); static GType
ev_job_annots_get_type_once (void); static gpointer ev_job_annots_parent_class
= ((void*)0); static gint EvJobAnnots_private_offset; static
void ev_job_annots_class_intern_init (gpointer klass) { ev_job_annots_parent_class
= g_type_class_peek_parent (klass); if (EvJobAnnots_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EvJobAnnots_private_offset
); ev_job_annots_class_init ((EvJobAnnotsClass*) klass); } __attribute__
((__unused__)) static inline gpointer ev_job_annots_get_instance_private
(EvJobAnnots *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EvJobAnnots_private_offset)))); } GType ev_job_annots_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_annots_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_annots_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobAnnots")
, sizeof (EvJobAnnotsClass), (GClassInitFunc)(void (*)(void))
ev_job_annots_class_intern_init, sizeof (EvJobAnnots), (GInstanceInitFunc
)(void (*)(void)) ev_job_annots_init, (GTypeFlags) 0); { {{};
} } return g_define_type_id; }
76G_DEFINE_TYPE (EvJobRender, ev_job_render, EV_TYPE_JOB)static void ev_job_render_init (EvJobRender *self); static void
ev_job_render_class_init (EvJobRenderClass *klass); static GType
ev_job_render_get_type_once (void); static gpointer ev_job_render_parent_class
= ((void*)0); static gint EvJobRender_private_offset; static
void ev_job_render_class_intern_init (gpointer klass) { ev_job_render_parent_class
= g_type_class_peek_parent (klass); if (EvJobRender_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EvJobRender_private_offset
); ev_job_render_class_init ((EvJobRenderClass*) klass); } __attribute__
((__unused__)) static inline gpointer ev_job_render_get_instance_private
(EvJobRender *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EvJobRender_private_offset)))); } GType ev_job_render_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_render_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_render_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobRender")
, sizeof (EvJobRenderClass), (GClassInitFunc)(void (*)(void))
ev_job_render_class_intern_init, sizeof (EvJobRender), (GInstanceInitFunc
)(void (*)(void)) ev_job_render_init, (GTypeFlags) 0); { {{};
} } return g_define_type_id; }
77G_DEFINE_TYPE (EvJobPageData, ev_job_page_data, EV_TYPE_JOB)static void ev_job_page_data_init (EvJobPageData *self); static
void ev_job_page_data_class_init (EvJobPageDataClass *klass)
; static GType ev_job_page_data_get_type_once (void); static gpointer
ev_job_page_data_parent_class = ((void*)0); static gint EvJobPageData_private_offset
; static void ev_job_page_data_class_intern_init (gpointer klass
) { ev_job_page_data_parent_class = g_type_class_peek_parent (
klass); if (EvJobPageData_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EvJobPageData_private_offset); ev_job_page_data_class_init
((EvJobPageDataClass*) klass); } __attribute__ ((__unused__)
) static inline gpointer ev_job_page_data_get_instance_private
(EvJobPageData *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EvJobPageData_private_offset)))); } GType ev_job_page_data_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_page_data_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_page_data_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobPageData"
), sizeof (EvJobPageDataClass), (GClassInitFunc)(void (*)(void
)) ev_job_page_data_class_intern_init, sizeof (EvJobPageData)
, (GInstanceInitFunc)(void (*)(void)) ev_job_page_data_init, (
GTypeFlags) 0); { {{};} } return g_define_type_id; }
78G_DEFINE_TYPE (EvJobThumbnail, ev_job_thumbnail, EV_TYPE_JOB)static void ev_job_thumbnail_init (EvJobThumbnail *self); static
void ev_job_thumbnail_class_init (EvJobThumbnailClass *klass
); static GType ev_job_thumbnail_get_type_once (void); static
gpointer ev_job_thumbnail_parent_class = ((void*)0); static gint
EvJobThumbnail_private_offset; static void ev_job_thumbnail_class_intern_init
(gpointer klass) { ev_job_thumbnail_parent_class = g_type_class_peek_parent
(klass); if (EvJobThumbnail_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EvJobThumbnail_private_offset); ev_job_thumbnail_class_init
((EvJobThumbnailClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer ev_job_thumbnail_get_instance_private
(EvJobThumbnail *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EvJobThumbnail_private_offset)))); } GType ev_job_thumbnail_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_thumbnail_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_thumbnail_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobThumbnail"
), sizeof (EvJobThumbnailClass), (GClassInitFunc)(void (*)(void
)) ev_job_thumbnail_class_intern_init, sizeof (EvJobThumbnail
), (GInstanceInitFunc)(void (*)(void)) ev_job_thumbnail_init,
(GTypeFlags) 0); { {{};} } return g_define_type_id; }
79G_DEFINE_TYPE (EvJobFonts, ev_job_fonts, EV_TYPE_JOB)static void ev_job_fonts_init (EvJobFonts *self); static void
ev_job_fonts_class_init (EvJobFontsClass *klass); static GType
ev_job_fonts_get_type_once (void); static gpointer ev_job_fonts_parent_class
= ((void*)0); static gint EvJobFonts_private_offset; static void
ev_job_fonts_class_intern_init (gpointer klass) { ev_job_fonts_parent_class
= g_type_class_peek_parent (klass); if (EvJobFonts_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EvJobFonts_private_offset
); ev_job_fonts_class_init ((EvJobFontsClass*) klass); } __attribute__
((__unused__)) static inline gpointer ev_job_fonts_get_instance_private
(EvJobFonts *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EvJobFonts_private_offset)))); } GType ev_job_fonts_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_fonts_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_fonts_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobFonts"),
sizeof (EvJobFontsClass), (GClassInitFunc)(void (*)(void)) ev_job_fonts_class_intern_init
, sizeof (EvJobFonts), (GInstanceInitFunc)(void (*)(void)) ev_job_fonts_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
80G_DEFINE_TYPE (EvJobLoad, ev_job_load, EV_TYPE_JOB)static void ev_job_load_init (EvJobLoad *self); static void ev_job_load_class_init
(EvJobLoadClass *klass); static GType ev_job_load_get_type_once
(void); static gpointer ev_job_load_parent_class = ((void*)0
); static gint EvJobLoad_private_offset; static void ev_job_load_class_intern_init
(gpointer klass) { ev_job_load_parent_class = g_type_class_peek_parent
(klass); if (EvJobLoad_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EvJobLoad_private_offset); ev_job_load_class_init
((EvJobLoadClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ev_job_load_get_instance_private (EvJobLoad *
self) { return (((gpointer) ((guint8*) (self) + (glong) (EvJobLoad_private_offset
)))); } GType ev_job_load_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_load_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_load_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobLoad"), sizeof
(EvJobLoadClass), (GClassInitFunc)(void (*)(void)) ev_job_load_class_intern_init
, sizeof (EvJobLoad), (GInstanceInitFunc)(void (*)(void)) ev_job_load_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
81G_DEFINE_TYPE (EvJobSave, ev_job_save, EV_TYPE_JOB)static void ev_job_save_init (EvJobSave *self); static void ev_job_save_class_init
(EvJobSaveClass *klass); static GType ev_job_save_get_type_once
(void); static gpointer ev_job_save_parent_class = ((void*)0
); static gint EvJobSave_private_offset; static void ev_job_save_class_intern_init
(gpointer klass) { ev_job_save_parent_class = g_type_class_peek_parent
(klass); if (EvJobSave_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EvJobSave_private_offset); ev_job_save_class_init
((EvJobSaveClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ev_job_save_get_instance_private (EvJobSave *
self) { return (((gpointer) ((guint8*) (self) + (glong) (EvJobSave_private_offset
)))); } GType ev_job_save_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_save_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_save_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobSave"), sizeof
(EvJobSaveClass), (GClassInitFunc)(void (*)(void)) ev_job_save_class_intern_init
, sizeof (EvJobSave), (GInstanceInitFunc)(void (*)(void)) ev_job_save_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
82G_DEFINE_TYPE (EvJobFind, ev_job_find, EV_TYPE_JOB)static void ev_job_find_init (EvJobFind *self); static void ev_job_find_class_init
(EvJobFindClass *klass); static GType ev_job_find_get_type_once
(void); static gpointer ev_job_find_parent_class = ((void*)0
); static gint EvJobFind_private_offset; static void ev_job_find_class_intern_init
(gpointer klass) { ev_job_find_parent_class = g_type_class_peek_parent
(klass); if (EvJobFind_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EvJobFind_private_offset); ev_job_find_class_init
((EvJobFindClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ev_job_find_get_instance_private (EvJobFind *
self) { return (((gpointer) ((guint8*) (self) + (glong) (EvJobFind_private_offset
)))); } GType ev_job_find_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_find_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_find_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobFind"), sizeof
(EvJobFindClass), (GClassInitFunc)(void (*)(void)) ev_job_find_class_intern_init
, sizeof (EvJobFind), (GInstanceInitFunc)(void (*)(void)) ev_job_find_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
83G_DEFINE_TYPE (EvJobLayers, ev_job_layers, EV_TYPE_JOB)static void ev_job_layers_init (EvJobLayers *self); static void
ev_job_layers_class_init (EvJobLayersClass *klass); static GType
ev_job_layers_get_type_once (void); static gpointer ev_job_layers_parent_class
= ((void*)0); static gint EvJobLayers_private_offset; static
void ev_job_layers_class_intern_init (gpointer klass) { ev_job_layers_parent_class
= g_type_class_peek_parent (klass); if (EvJobLayers_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EvJobLayers_private_offset
); ev_job_layers_class_init ((EvJobLayersClass*) klass); } __attribute__
((__unused__)) static inline gpointer ev_job_layers_get_instance_private
(EvJobLayers *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EvJobLayers_private_offset)))); } GType ev_job_layers_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_layers_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_layers_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobLayers")
, sizeof (EvJobLayersClass), (GClassInitFunc)(void (*)(void))
ev_job_layers_class_intern_init, sizeof (EvJobLayers), (GInstanceInitFunc
)(void (*)(void)) ev_job_layers_init, (GTypeFlags) 0); { {{};
} } return g_define_type_id; }
84G_DEFINE_TYPE (EvJobExport, ev_job_export, EV_TYPE_JOB)static void ev_job_export_init (EvJobExport *self); static void
ev_job_export_class_init (EvJobExportClass *klass); static GType
ev_job_export_get_type_once (void); static gpointer ev_job_export_parent_class
= ((void*)0); static gint EvJobExport_private_offset; static
void ev_job_export_class_intern_init (gpointer klass) { ev_job_export_parent_class
= g_type_class_peek_parent (klass); if (EvJobExport_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EvJobExport_private_offset
); ev_job_export_class_init ((EvJobExportClass*) klass); } __attribute__
((__unused__)) static inline gpointer ev_job_export_get_instance_private
(EvJobExport *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EvJobExport_private_offset)))); } GType ev_job_export_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_export_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_export_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobExport")
, sizeof (EvJobExportClass), (GClassInitFunc)(void (*)(void))
ev_job_export_class_intern_init, sizeof (EvJobExport), (GInstanceInitFunc
)(void (*)(void)) ev_job_export_init, (GTypeFlags) 0); { {{};
} } return g_define_type_id; }
85G_DEFINE_TYPE (EvJobPrint, ev_job_print, EV_TYPE_JOB)static void ev_job_print_init (EvJobPrint *self); static void
ev_job_print_class_init (EvJobPrintClass *klass); static GType
ev_job_print_get_type_once (void); static gpointer ev_job_print_parent_class
= ((void*)0); static gint EvJobPrint_private_offset; static void
ev_job_print_class_intern_init (gpointer klass) { ev_job_print_parent_class
= g_type_class_peek_parent (klass); if (EvJobPrint_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EvJobPrint_private_offset
); ev_job_print_class_init ((EvJobPrintClass*) klass); } __attribute__
((__unused__)) static inline gpointer ev_job_print_get_instance_private
(EvJobPrint *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EvJobPrint_private_offset)))); } GType ev_job_print_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = ev_job_print_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ev_job_print_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ev_job_get_type()), g_intern_static_string ("EvJobPrint"),
sizeof (EvJobPrintClass), (GClassInitFunc)(void (*)(void)) ev_job_print_class_intern_init
, sizeof (EvJobPrint), (GInstanceInitFunc)(void (*)(void)) ev_job_print_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
86
87/* EvJob */
88static void
89ev_job_init (EvJob *job)
90{
91 job->cancellable = g_cancellable_new ();
92}
93
94static void
95ev_job_dispose (GObject *object)
96{
97 EvJob *job;
98
99 job = EV_JOB (object)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_get_type()))))))
;
100
101 if (job->document) {
102 g_object_unref (job->document);
103 job->document = NULL((void*)0);
104 }
105
106 if (job->cancellable) {
107 g_object_unref (job->cancellable);
108 job->cancellable = NULL((void*)0);
109 }
110
111 if (job->error) {
112 g_error_free (job->error);
113 job->error = NULL((void*)0);
114 }
115
116 (* G_OBJECT_CLASS (ev_job_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_parent_class)), (((GType) ((20) << (2))))))
))
->dispose) (object);
117}
118
119static void
120ev_job_class_init (EvJobClass *class)
121{
122 GObjectClass *oclass;
123
124 oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
125
126 oclass->dispose = ev_job_dispose;
127
128 job_signals[CANCELLED] =
129 g_signal_new ("cancelled",
130 EV_TYPE_JOB(ev_job_get_type()),
131 G_SIGNAL_RUN_LAST,
132 G_STRUCT_OFFSET (EvJobClass, cancelled)((glong) __builtin_offsetof(EvJobClass, cancelled)),
133 NULL((void*)0), NULL((void*)0),
134 g_cclosure_marshal_VOID__VOID,
135 G_TYPE_NONE((GType) ((1) << (2))), 0);
136 job_signals [FINISHED] =
137 g_signal_new ("finished",
138 EV_TYPE_JOB(ev_job_get_type()),
139 G_SIGNAL_RUN_FIRST,
140 G_STRUCT_OFFSET (EvJobClass, finished)((glong) __builtin_offsetof(EvJobClass, finished)),
141 NULL((void*)0), NULL((void*)0),
142 g_cclosure_marshal_VOID__VOID,
143 G_TYPE_NONE((GType) ((1) << (2))), 0);
144}
145
146static gboolean
147emit_finished (EvJob *job)
148{
149 ev_debug_message (DEBUG_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
150
151 job->idle_finished_id = 0;
152
153 if (job->cancelled) {
154 ev_debug_message (DEBUG_JOBS, "%s (%p) job was cancelled, do not emit finished", EV_GET_TYPE_NAME (job), job)do { } while (0);
155 } else {
156 ev_profiler_stop (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
157 g_signal_emit (job, job_signals[FINISHED], 0);
158 }
159
160 return FALSE(0);
161}
162
163static void
164ev_job_emit_finished (EvJob *job)
165{
166 ev_debug_message (DEBUG_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
167
168 if (g_cancellable_is_cancelled (job->cancellable)) {
169 ev_debug_message (DEBUG_JOBS, "%s (%p) job was cancelled, returning", EV_GET_TYPE_NAME (job), job)do { } while (0);
170 return;
171 }
172
173 job->finished = TRUE(!(0));
174
175 if (job->run_mode == EV_JOB_RUN_THREAD) {
176 job->idle_finished_id =
177 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200,
178 (GSourceFunc)emit_finished,
179 g_object_ref (job)((__typeof__ (job)) (g_object_ref) (job)),
180 (GDestroyNotify)g_object_unref);
181 } else {
182 ev_profiler_stop (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
183 g_signal_emit (job, job_signals[FINISHED], 0);
184 }
185}
186
187gboolean
188ev_job_run (EvJob *job)
189{
190 EvJobClass *class = EV_JOB_GET_CLASS (job)((((EvJobClass*) (((GTypeInstance*) ((job)))->g_class))));
191
192 return class-> run (job);
193}
194
195void
196ev_job_cancel (EvJob *job)
197{
198 if (job->cancelled)
199 return;
200
201 ev_debug_message (DEBUG_JOBS, "job %s (%p) cancelled", EV_GET_TYPE_NAME (job), job)do { } while (0);
202 ev_profiler_stop (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
203
204 /* This should never be called from a thread */
205 job->cancelled = TRUE(!(0));
206 g_cancellable_cancel (job->cancellable);
207
208 if (job->finished && job->idle_finished_id == 0)
209 return;
210
211 g_signal_emit (job, job_signals[CANCELLED], 0);
212}
213
214void
215ev_job_failed (EvJob *job,
216 GQuark domain,
217 gint code,
218 const gchar *format,
219 ...)
220{
221 va_list args;
222 gchar *message;
223
224 if (job->failed || job->finished)
225 return;
226
227 ev_debug_message (DEBUG_JOBS, "job %s (%p) failed", EV_GET_TYPE_NAME (job), job)do { } while (0);
228
229 job->failed = TRUE(!(0));
230
231 va_start (args, format)__builtin_va_start(args, format);
232 message = g_strdup_vprintf (format, args);
233 va_end (args)__builtin_va_end(args);
234
235 job->error = g_error_new_literal (domain, code, message);
236 g_free (message);
237
238 ev_job_emit_finished (job);
239}
240
241/**
242 * ev_job_failed_from_error:
243 * @job: an #EvJob
244 * @error: a #GError
245 *
246 * Rename to: ev_job_failed
247 */
248void
249ev_job_failed_from_error (EvJob *job,
250 GError *error)
251{
252 if (job->failed || job->finished)
253 return;
254
255 ev_debug_message (DEBUG_JOBS, "job %s (%p) failed", EV_GET_TYPE_NAME (job), job)do { } while (0);
256
257 job->failed = TRUE(!(0));
258 job->error = g_error_copy (error);
259
260 ev_job_emit_finished (job);
261}
262
263void
264ev_job_succeeded (EvJob *job)
265{
266 if (job->finished)
267 return;
268
269 ev_debug_message (DEBUG_JOBS, "job %s (%p) succeeded", EV_GET_TYPE_NAME (job), job)do { } while (0);
270
271 job->failed = FALSE(0);
272 ev_job_emit_finished (job);
273}
274
275gboolean
276ev_job_is_finished (EvJob *job)
277{
278 return job->finished;
279}
280
281gboolean
282ev_job_is_failed (EvJob *job)
283{
284 return job->failed;
285}
286
287EvJobRunMode
288ev_job_get_run_mode (EvJob *job)
289{
290 return job->run_mode;
291}
292
293void
294ev_job_set_run_mode (EvJob *job,
295 EvJobRunMode run_mode)
296{
297 job->run_mode = run_mode;
298}
299
300/* EvJobLinks */
301static void
302ev_job_links_init (EvJobLinks *job)
303{
304 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
305}
306
307static void
308ev_job_links_dispose (GObject *object)
309{
310 EvJobLinks *job;
311
312 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
313
314 job = EV_JOB_LINKS (object)((((EvJobLinks*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_links_get_type()))))))
;
315
316 if (job->model) {
317 g_object_unref (job->model);
318 job->model = NULL((void*)0);
319 }
320
321 (* G_OBJECT_CLASS (ev_job_links_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_links_parent_class)), (((GType) ((20) << (2
))))))))
->dispose) (object);
322}
323
324static gboolean
325fill_page_labels (CtkTreeModel *tree_model,
326 CtkTreePath *path,
327 CtkTreeIter *iter,
328 EvJob *job)
329{
330 EvDocumentLinks *document_links;
331 EvLink *link;
332 gchar *page_label;
333
334 ctk_tree_model_get (tree_model, iter,
335 EV_DOCUMENT_LINKS_COLUMN_LINK, &link,
336 -1);
337
338 if (!link)
339 return FALSE(0);
340
341 document_links = EV_DOCUMENT_LINKS (job->document)((((EvDocumentLinks*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_links_get_type ())))))
)
;
342 page_label = ev_document_links_get_link_page_label (document_links, link);
343 if (!page_label)
344 return FALSE(0);
345
346 ctk_tree_store_set (CTK_TREE_STORE (tree_model)((((CtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_model)), ((ctk_tree_store_get_type ()))))))
, iter,
347 EV_DOCUMENT_LINKS_COLUMN_PAGE_LABEL, page_label,
348 -1);
349
350 g_free (page_label);
351 g_object_unref (link);
352
353 return FALSE(0);
354}
355
356static gboolean
357ev_job_links_run (EvJob *job)
358{
359 EvJobLinks *job_links = EV_JOB_LINKS (job)((((EvJobLinks*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_links_get_type()))))))
;
360
361 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
362 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
363
364 ev_document_doc_mutex_lock ();
365 job_links->model = ev_document_links_get_links_model (EV_DOCUMENT_LINKS (job->document)((((EvDocumentLinks*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_links_get_type ())))))
)
);
366 ev_document_doc_mutex_unlock ();
367
368 ctk_tree_model_foreach (job_links->model, (CtkTreeModelForeachFunc)fill_page_labels, job);
369
370 ev_job_succeeded (job);
371
372 return FALSE(0);
373}
374
375static void
376ev_job_links_class_init (EvJobLinksClass *class)
377{
378 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
379 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
380
381 oclass->dispose = ev_job_links_dispose;
382 job_class->run = ev_job_links_run;
383}
384
385EvJob *
386ev_job_links_new (EvDocument *document)
387{
388 EvJob *job;
389
390 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
391
392 job = g_object_new (EV_TYPE_JOB_LINKS(ev_job_links_get_type()), NULL((void*)0));
393 job->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
394
395 return job;
396}
397
398/* EvJobAttachments */
399static void
400ev_job_attachments_init (EvJobAttachments *job)
401{
402 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
403}
404
405static void
406ev_job_attachments_dispose (GObject *object)
407{
408 EvJobAttachments *job;
409
410 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
411
412 job = EV_JOB_ATTACHMENTS (object)((((EvJobAttachments*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((object)), ((ev_job_attachments_get_type()))
))))
;
413
414 if (job->attachments) {
415 g_list_foreach (job->attachments, (GFunc)g_object_unref, NULL((void*)0));
416 g_list_free (job->attachments);
417 job->attachments = NULL((void*)0);
418 }
419
420 (* G_OBJECT_CLASS (ev_job_attachments_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_attachments_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose) (object);
421}
422
423static gboolean
424ev_job_attachments_run (EvJob *job)
425{
426 EvJobAttachments *job_attachments = EV_JOB_ATTACHMENTS (job)((((EvJobAttachments*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((job)), ((ev_job_attachments_get_type())))))
)
;
427
428 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
429 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
430
431 ev_document_doc_mutex_lock ();
432 job_attachments->attachments =
433 ev_document_attachments_get_attachments (EV_DOCUMENT_ATTACHMENTS (job->document)((((EvDocumentAttachments*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((job->document)), ((ev_document_attachments_get_type
()))))))
);
434 ev_document_doc_mutex_unlock ();
435
436 ev_job_succeeded (job);
437
438 return FALSE(0);
439}
440
441static void
442ev_job_attachments_class_init (EvJobAttachmentsClass *class)
443{
444 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
445 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
446
447 oclass->dispose = ev_job_attachments_dispose;
448 job_class->run = ev_job_attachments_run;
449}
450
451EvJob *
452ev_job_attachments_new (EvDocument *document)
453{
454 EvJob *job;
455
456 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
457
458 job = g_object_new (EV_TYPE_JOB_ATTACHMENTS(ev_job_attachments_get_type()), NULL((void*)0));
459 job->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
460
461 return job;
462}
463
464/* EvJobAnnots */
465static void
466ev_job_annots_init (EvJobAnnots *job)
467{
468 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
469}
470
471static void
472ev_job_annots_dispose (GObject *object)
473{
474 EvJobAnnots *job;
475
476 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
477
478 job = EV_JOB_ANNOTS (object)((((EvJobAnnots*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_annots_get_type()))))))
;
479
480 if (job->annots) {
481 g_list_foreach (job->annots, (GFunc)ev_mapping_list_unref, NULL((void*)0));
482 g_list_free (job->annots);
483 job->annots = NULL((void*)0);
484 }
485
486 G_OBJECT_CLASS (ev_job_annots_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_annots_parent_class)), (((GType) ((20) << (
2))))))))
->dispose (object);
487}
488
489static gboolean
490ev_job_annots_run (EvJob *job)
491{
492 EvJobAnnots *job_annots = EV_JOB_ANNOTS (job)((((EvJobAnnots*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_annots_get_type()))))))
;
493 gint i;
494
495 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
496 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
497
498 ev_document_doc_mutex_lock ();
499 for (i = 0; i < ev_document_get_n_pages (job->document); i++) {
500 EvMappingList *mapping_list;
501 EvPage *page;
502
503 page = ev_document_get_page (job->document, i);
504 mapping_list = ev_document_annotations_get_annotations (EV_DOCUMENT_ANNOTATIONS (job->document)((((EvDocumentAnnotations*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((job->document)), ((ev_document_annotations_get_type
()))))))
,
505 page);
506 g_object_unref (page);
507
508 if (mapping_list)
509 job_annots->annots = g_list_prepend (job_annots->annots, mapping_list);
510 }
511 ev_document_doc_mutex_unlock ();
512
513 job_annots->annots = g_list_reverse (job_annots->annots);
514
515 ev_job_succeeded (job);
516
517 return FALSE(0);
518}
519
520static void
521ev_job_annots_class_init (EvJobAnnotsClass *class)
522{
523 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
524 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
525
526 oclass->dispose = ev_job_annots_dispose;
527 job_class->run = ev_job_annots_run;
528}
529
530EvJob *
531ev_job_annots_new (EvDocument *document)
532{
533 EvJob *job;
534
535 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
536
537 job = g_object_new (EV_TYPE_JOB_ANNOTS(ev_job_annots_get_type()), NULL((void*)0));
538 job->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
539
540 return job;
541}
542
543/* EvJobRender */
544static void
545ev_job_render_init (EvJobRender *job)
546{
547 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
548}
549
550static void
551ev_job_render_dispose (GObject *object)
552{
553 EvJobRender *job;
554
555 job = EV_JOB_RENDER (object)((((EvJobRender*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_render_get_type()))))))
;
556
557 ev_debug_message (DEBUG_JOBS, "page: %d (%p)", job->page, job)do { } while (0);
558
559 if (job->surface) {
560 cairo_surface_destroy (job->surface);
561 job->surface = NULL((void*)0);
562 }
563
564 if (job->selection) {
565 cairo_surface_destroy (job->selection);
566 job->selection = NULL((void*)0);
567 }
568
569 if (job->selection_region) {
570 cairo_region_destroy (job->selection_region);
571 job->selection_region = NULL((void*)0);
572 }
573
574 (* G_OBJECT_CLASS (ev_job_render_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_render_parent_class)), (((GType) ((20) << (
2))))))))
->dispose) (object);
575}
576
577static gboolean
578ev_job_render_run (EvJob *job)
579{
580 EvJobRender *job_render = EV_JOB_RENDER (job)((((EvJobRender*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_render_get_type()))))))
;
581 EvPage *ev_page;
582 EvRenderContext *rc;
583
584 ev_debug_message (DEBUG_JOBS, "page: %d (%p)", job_render->page, job)do { } while (0);
585 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
586
587 ev_document_doc_mutex_lock ();
588
589 ev_profiler_start (EV_PROFILE_JOBS, "Rendering page %d", job_render->page)do { } while (0);
590
591 ev_document_fc_mutex_lock ();
592
593 ev_page = ev_document_get_page (job->document, job_render->page);
594
595 if ( job->document->iswebdocument == TRUE(!(0)) )
596 {
597 return TRUE(!(0));
598
599 if (g_cancellable_is_cancelled (job->cancellable)) {
This statement is never executed
600 ev_document_fc_mutex_unlock ();
601 ev_document_doc_mutex_unlock ();
602 g_object_unref (rc);
603
604 return FALSE(0);
605 }
606
607 ev_document_fc_mutex_unlock ();
608 ev_document_doc_mutex_unlock ();
609 ev_job_succeeded (job);
610 return FALSE(0);
611 }
612 rc = ev_render_context_new (ev_page, job_render->rotation, job_render->scale);
613 g_object_unref (ev_page);
614
615 job_render->surface = ev_document_render (job->document, rc);
616 /* If job was cancelled during the page rendering,
617 * we return now, so that the thread is finished ASAP
618 */
619 if (g_cancellable_is_cancelled (job->cancellable)) {
620 ev_document_fc_mutex_unlock ();
621 ev_document_doc_mutex_unlock ();
622 g_object_unref (rc);
623
624 return FALSE(0);
625 }
626
627 if (job_render->include_selection && EV_IS_SELECTION (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_selection_get_type ()))
; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))
) {
628 ev_selection_render_selection (EV_SELECTION (job->document)((((EvSelection*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_selection_get_type ()))))))
,
629 rc,
630 &(job_render->selection),
631 &(job_render->selection_points),
632 NULL((void*)0),
633 job_render->selection_style,
634 &(job_render->text), &(job_render->base));
635 job_render->selection_region =
636 ev_selection_get_selection_region (EV_SELECTION (job->document)((((EvSelection*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_selection_get_type ()))))))
,
637 rc,
638 job_render->selection_style,
639 &(job_render->selection_points));
640 }
641
642 g_object_unref (rc);
643
644 ev_document_fc_mutex_unlock ();
645 ev_document_doc_mutex_unlock ();
646
647 ev_job_succeeded (job);
648
649 return FALSE(0);
650}
651
652static void
653ev_job_render_class_init (EvJobRenderClass *class)
654{
655 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
656 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
657
658 oclass->dispose = ev_job_render_dispose;
659 job_class->run = ev_job_render_run;
660}
661
662EvJob *
663ev_job_render_new (EvDocument *document,
664 gint page,
665 gint rotation,
666 gdouble scale,
667 gint width,
668 gint height)
669{
670 EvJobRender *job;
671
672 ev_debug_message (DEBUG_JOBS, "page: %d", page)do { } while (0);
673
674 job = g_object_new (EV_TYPE_JOB_RENDER(ev_job_render_get_type()), NULL((void*)0));
675
676 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
677 job->page = page;
678 job->rotation = rotation;
679 job->scale = scale;
680 job->target_width = width;
681 job->target_height = height;
682
683 return EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
;
684}
685
686void
687ev_job_render_set_selection_info (EvJobRender *job,
688 EvRectangle *selection_points,
689 EvSelectionStyle selection_style,
690 CdkColor *text,
691 CdkColor *base)
692{
693 job->include_selection = TRUE(!(0));
694
695 job->selection_points = *selection_points;
696 job->selection_style = selection_style;
697 job->text = *text;
698 job->base = *base;
699}
700
701/* EvJobPageData */
702static void
703ev_job_page_data_init (EvJobPageData *job)
704{
705 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
706}
707
708static gboolean
709ev_job_page_data_run (EvJob *job)
710{
711 EvJobPageData *job_pd = EV_JOB_PAGE_DATA (job)((((EvJobPageData*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_page_data_get_type()))))))
;
712 EvPage *ev_page;
713
714 ev_debug_message (DEBUG_JOBS, "page: %d (%p)", job_pd->page, job)do { } while (0);
715 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
716
717 ev_document_doc_mutex_lock ();
718 ev_page = ev_document_get_page (job->document, job_pd->page);
719
720 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_TEXT_MAPPING) && EV_IS_DOCUMENT_TEXT (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_text_get_type (
))); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
721 job_pd->text_mapping =
722 ev_document_text_get_text_mapping (EV_DOCUMENT_TEXT (job->document)((((EvDocumentText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_text_get_type ()))))))
, ev_page);
723 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_TEXT) && EV_IS_DOCUMENT_TEXT (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_text_get_type (
))); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
724 job_pd->text =
725 ev_document_text_get_text (EV_DOCUMENT_TEXT (job->document)((((EvDocumentText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_text_get_type ()))))))
, ev_page);
726 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_TEXT_LAYOUT) && EV_IS_DOCUMENT_TEXT (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_text_get_type (
))); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
727 ev_document_text_get_text_layout (EV_DOCUMENT_TEXT (job->document)((((EvDocumentText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_text_get_type ()))))))
,
728 ev_page,
729 &(job_pd->text_layout),
730 &(job_pd->text_layout_length));
731 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_TEXT_ATTRS) && EV_IS_DOCUMENT_TEXT (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_text_get_type (
))); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
732 job_pd ->text_attrs =
733 ev_document_text_get_text_attrs (EV_DOCUMENT_TEXT (job->document)((((EvDocumentText*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_text_get_type ()))))))
,
734 ev_page);
735 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS) && job_pd->text) {
736 job_pd->text_log_attrs_length = g_utf8_strlen (job_pd->text, -1);
737 job_pd->text_log_attrs = g_new0 (PangoLogAttr, job_pd->text_log_attrs_length + 1)((PangoLogAttr *) g_malloc0_n ((job_pd->text_log_attrs_length
+ 1), sizeof (PangoLogAttr)))
;
738
739 /* FIXME: We need API to get the language of the document */
740 pango_get_log_attrs (job_pd->text, -1, -1, NULL((void*)0), job_pd->text_log_attrs, job_pd->text_log_attrs_length + 1);
741 }
742 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_LINKS) && EV_IS_DOCUMENT_LINKS (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_links_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
743 job_pd->link_mapping =
744 ev_document_links_get_links (EV_DOCUMENT_LINKS (job->document)((((EvDocumentLinks*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_links_get_type ())))))
)
, ev_page);
745 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_FORMS) && EV_IS_DOCUMENT_FORMS (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_forms_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
746 job_pd->form_field_mapping =
747 ev_document_forms_get_form_fields (EV_DOCUMENT_FORMS (job->document)((((EvDocumentForms*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_forms_get_type ())))))
)
,
748 ev_page);
749 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_IMAGES) && EV_IS_DOCUMENT_IMAGES (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_images_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
750 job_pd->image_mapping =
751 ev_document_images_get_image_mapping (EV_DOCUMENT_IMAGES (job->document)((((EvDocumentImages*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((job->document)), ((ev_document_images_get_type
()))))))
,
752 ev_page);
753 if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_ANNOTS) && EV_IS_DOCUMENT_ANNOTATIONS (job->document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(job->document)); GType __t = ((ev_document_annotations_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
754 job_pd->annot_mapping =
755 ev_document_annotations_get_annotations (EV_DOCUMENT_ANNOTATIONS (job->document)((((EvDocumentAnnotations*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((job->document)), ((ev_document_annotations_get_type
()))))))
,
756 ev_page);
757 g_object_unref (ev_page);
758 ev_document_doc_mutex_unlock ();
759
760 ev_job_succeeded (job);
761
762 return FALSE(0);
763}
764
765static void
766ev_job_page_data_class_init (EvJobPageDataClass *class)
767{
768 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
769
770 job_class->run = ev_job_page_data_run;
771}
772
773EvJob *
774ev_job_page_data_new (EvDocument *document,
775 gint page,
776 EvJobPageDataFlags flags)
777{
778 EvJobPageData *job;
779
780 ev_debug_message (DEBUG_JOBS, "%d", page)do { } while (0);
781
782 job = g_object_new (EV_TYPE_JOB_PAGE_DATA(ev_job_page_data_get_type()), NULL((void*)0));
783
784 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
785 job->page = page;
786 job->flags = flags;
787
788 return EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
;
789}
790
791/* EvJobThumbnail */
792static void
793ev_job_thumbnail_init (EvJobThumbnail *job)
794{
795 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
796}
797
798static void
799ev_job_thumbnail_dispose (GObject *object)
800{
801 EvJobThumbnail *job;
802
803 job = EV_JOB_THUMBNAIL (object)((((EvJobThumbnail*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_thumbnail_get_type()))))))
;
804
805 ev_debug_message (DEBUG_JOBS, "%d (%p)", job->page, job)do { } while (0);
806
807 if (job->thumbnail) {
808 g_object_unref (job->thumbnail);
809 job->thumbnail = NULL((void*)0);
810 }
811
812 (* G_OBJECT_CLASS (ev_job_thumbnail_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_thumbnail_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose) (object);
813}
814
815#if ENABLE_EPUB
816static void
817snapshot_callback(WebKitWebView *webview,
818 GAsyncResult *results,
819 EvJobThumbnail *job_thumb)
820{
821 GError *error = NULL((void*)0);
822
823 ev_document_doc_mutex_lock ();
824
825 EvPage *page = ev_document_get_page (EV_JOB(job_thumb)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job_thumb)), ((ev_job_get_type()))))))
->document, job_thumb->page);
826 job_thumb->surface = webkit_web_view_get_snapshot_finish (webview,
827 results,
828 &error);
829
830 if (error) {
831 g_warning ("Error retrieving a snapshot: %s", error->message);
832 }
833
834 EvRenderContext *rc = ev_render_context_new (page, job_thumb->rotation, job_thumb->scale);
835 EvPage *screenshotpage;
836 screenshotpage = ev_page_new(job_thumb->page);
837 screenshotpage->backend_page = (EvBackendPage)job_thumb->surface;
838 screenshotpage->backend_destroy_func = (EvBackendPageDestroyFunc)cairo_surface_destroy;
839 ev_render_context_set_page(rc,screenshotpage);
840
841 job_thumb->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (EV_JOB(job_thumb)->document)((((EvDocumentThumbnails*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((((((EvJob*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((job_thumb)), ((ev_job_get_type()))))))->
document)), ((ev_document_thumbnails_get_type ()))))))
,
842 rc, TRUE(!(0)));
843 g_object_unref(screenshotpage);
844 g_object_unref(rc);
845
846 ev_document_doc_mutex_unlock ();
847 ev_job_succeeded (EV_JOB(job_thumb)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job_thumb)), ((ev_job_get_type()))))))
);
848
849 ctk_widget_destroy (ctk_widget_get_toplevel (CTK_WIDGET (webview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((webview)), ((ctk_widget_get_type ()))))))
));
850}
851
852static void
853web_thumbnail_get_screenshot_cb (WebKitWebView *webview,
854 WebKitLoadEvent event,
855 EvJobThumbnail *job_thumb)
856{
857 if (event != WEBKIT_LOAD_FINISHED || ev_job_is_failed (EV_JOB(job_thumb)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job_thumb)), ((ev_job_get_type()))))))
)) {
858 return;
859 }
860
861 webkit_web_view_get_snapshot (webview,
862 WEBKIT_SNAPSHOT_REGION_VISIBLE,
863 WEBKIT_SNAPSHOT_OPTIONS_NONE,
864 NULL((void*)0),
865 (GAsyncReadyCallback)snapshot_callback,
866 g_object_ref (job_thumb)((__typeof__ (job_thumb)) (g_object_ref) (job_thumb)));
867}
868
869static gboolean
870webview_load_failed_cb (WebKitWebView *webview,
871 WebKitLoadEvent event,
872 gchar *failing_uri,
873 gpointer error,
874 EvJobThumbnail *job_thumb)
875{
876 GError *e = (GError *) error;
877 g_warning ("Error loading data from %s: %s", failing_uri, e->message);
878 ev_job_failed_from_error (EV_JOB(job_thumb)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job_thumb)), ((ev_job_get_type()))))))
, e);
879
880 ctk_widget_destroy (ctk_widget_get_toplevel (CTK_WIDGET (webview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((webview)), ((ctk_widget_get_type ()))))))
));
881 return TRUE(!(0));
882}
883
884#endif /* ENABLE_EPUB */
885
886static gboolean
887ev_job_thumbnail_run (EvJob *job)
888{
889 EvJobThumbnail *job_thumb = EV_JOB_THUMBNAIL (job)((((EvJobThumbnail*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_thumbnail_get_type()))))))
;
890 EvRenderContext *rc;
891 EvPage *page;
892 ev_debug_message (DEBUG_JOBS, "%d (%p)", job_thumb->page, job)do { } while (0);
893 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
894
895 if (job->document->iswebdocument) {
896 /* Do not block the main loop */
897 if (!ev_document_doc_mutex_trylock ())
898 return TRUE(!(0));
899 } else {
900 ev_document_doc_mutex_lock ();
901 }
902
903 page = ev_document_get_page (job->document, job_thumb->page);
904 ev_document_doc_mutex_unlock ();
905
906 if (job->document->iswebdocument == TRUE(!(0)) ) {
907 rc = ev_render_context_new (page, 0, job_thumb->scale);
908 } else {
909 rc = ev_render_context_new (page, job_thumb->rotation, job_thumb->scale);
910 }
911 g_object_unref (page);
912
913#if ENABLE_EPUB
914 if (job->document->iswebdocument == TRUE(!(0))) {
915 CtkWidget *webview;
916 CtkWidget *offscreenwindow;
917
918 webview = webkit_web_view_new ();
919 offscreenwindow = ctk_offscreen_window_new ();
920
921 ctk_container_add (CTK_CONTAINER(offscreenwindow)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((offscreenwindow)), ((ctk_container_get_type ()))))))
, CTK_WIDGET (webview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((webview)), ((ctk_widget_get_type ()))))))
);
922 ctk_window_set_default_size (CTK_WINDOW(offscreenwindow)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((offscreenwindow)), ((ctk_window_get_type ()))))))
, 800, 1080);
923 ctk_widget_show_all (offscreenwindow);
924
925 g_signal_connect (WEBKIT_WEB_VIEW (webview), "load-changed",g_signal_connect_data ((WEBKIT_WEB_VIEW (webview)), ("load-changed"
), (((GCallback) (web_thumbnail_get_screenshot_cb))), (((__typeof__
(job_thumb)) (g_object_ref) (job_thumb))), ((void*)0), (GConnectFlags
) 0)
926 G_CALLBACK (web_thumbnail_get_screenshot_cb),g_signal_connect_data ((WEBKIT_WEB_VIEW (webview)), ("load-changed"
), (((GCallback) (web_thumbnail_get_screenshot_cb))), (((__typeof__
(job_thumb)) (g_object_ref) (job_thumb))), ((void*)0), (GConnectFlags
) 0)
927 g_object_ref (job_thumb))g_signal_connect_data ((WEBKIT_WEB_VIEW (webview)), ("load-changed"
), (((GCallback) (web_thumbnail_get_screenshot_cb))), (((__typeof__
(job_thumb)) (g_object_ref) (job_thumb))), ((void*)0), (GConnectFlags
) 0)
;
928 g_signal_connect (WEBKIT_WEB_VIEW(webview), "load-failed",g_signal_connect_data ((WEBKIT_WEB_VIEW(webview)), ("load-failed"
), (((GCallback) (webview_load_failed_cb))), (((__typeof__ (job_thumb
)) (g_object_ref) (job_thumb))), ((void*)0), (GConnectFlags) 0
)
929 G_CALLBACK(webview_load_failed_cb),g_signal_connect_data ((WEBKIT_WEB_VIEW(webview)), ("load-failed"
), (((GCallback) (webview_load_failed_cb))), (((__typeof__ (job_thumb
)) (g_object_ref) (job_thumb))), ((void*)0), (GConnectFlags) 0
)
930 g_object_ref (job_thumb))g_signal_connect_data ((WEBKIT_WEB_VIEW(webview)), ("load-failed"
), (((GCallback) (webview_load_failed_cb))), (((__typeof__ (job_thumb
)) (g_object_ref) (job_thumb))), ((void*)0), (GConnectFlags) 0
)
;
931 webkit_web_view_load_uri (WEBKIT_WEB_VIEW (webview), (gchar*) rc->page->backend_page);
932 }
933 else
934#endif /* ENABLE_EPUB */
935 {
936 ev_document_doc_mutex_lock ();
937 job_thumb->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (job->document)((((EvDocumentThumbnails*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((job->document)), ((ev_document_thumbnails_get_type
()))))))
,
938 rc, TRUE(!(0)));
939 ev_document_doc_mutex_unlock ();
940 ev_job_succeeded (job);
941 }
942 g_object_unref (rc);
943
944 return FALSE(0);
945}
946
947static void
948ev_job_thumbnail_class_init (EvJobThumbnailClass *class)
949{
950 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
951 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
952
953 oclass->dispose = ev_job_thumbnail_dispose;
954 job_class->run = ev_job_thumbnail_run;
955}
956
957EvJob *
958ev_job_thumbnail_new (EvDocument *document,
959 gint page,
960 gint rotation,
961 gdouble scale)
962{
963 EvJobThumbnail *job;
964
965 ev_debug_message (DEBUG_JOBS, "%d", page)do { } while (0);
966
967 job = g_object_new (EV_TYPE_JOB_THUMBNAIL(ev_job_thumbnail_get_type()), NULL((void*)0));
968
969 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
970 job->page = page;
971 job->rotation = rotation;
972 job->scale = scale;
973
974 return EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
;
975}
976
977/* EvJobFonts */
978static void
979ev_job_fonts_init (EvJobFonts *job)
980{
981 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_MAIN_LOOP;
982}
983
984static gboolean
985ev_job_fonts_run (EvJob *job)
986{
987 EvJobFonts *job_fonts = EV_JOB_FONTS (job)((((EvJobFonts*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_fonts_get_type()))))))
;
988 EvDocumentFonts *fonts = EV_DOCUMENT_FONTS (job->document)((((EvDocumentFonts*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_fonts_get_type ())))))
)
;
989
990 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
991
992 /* Do not block the main loop */
993 if (!ev_document_doc_mutex_trylock ())
994 return TRUE(!(0));
995
996 if (!ev_document_fc_mutex_trylock ()) {
997 ev_document_doc_mutex_unlock ();
998 return TRUE(!(0));
999 }
1000
1001#ifdef EV_ENABLE_DEBUG
1002 /* We use the #ifdef in this case because of the if */
1003 if (ev_document_fonts_get_progress (fonts) == 0)
1004 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
1005#endif
1006
1007 job_fonts->scan_completed = !ev_document_fonts_scan (fonts, 20);
1008 g_signal_emit (job_fonts, job_fonts_signals[FONTS_UPDATED], 0,
1009 ev_document_fonts_get_progress (fonts));
1010
1011 ev_document_fc_mutex_unlock ();
1012 ev_document_doc_mutex_unlock ();
1013
1014 if (job_fonts->scan_completed)
1015 ev_job_succeeded (job);
1016
1017 return !job_fonts->scan_completed;
1018}
1019
1020static void
1021ev_job_fonts_class_init (EvJobFontsClass *class)
1022{
1023 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
1024
1025 job_class->run = ev_job_fonts_run;
1026
1027 job_fonts_signals[FONTS_UPDATED] =
1028 g_signal_new ("updated",
1029 EV_TYPE_JOB_FONTS(ev_job_fonts_get_type()),
1030 G_SIGNAL_RUN_LAST,
1031 G_STRUCT_OFFSET (EvJobFontsClass, updated)((glong) __builtin_offsetof(EvJobFontsClass, updated)),
1032 NULL((void*)0), NULL((void*)0),
1033 g_cclosure_marshal_VOID__DOUBLE,
1034 G_TYPE_NONE((GType) ((1) << (2))),
1035 1, G_TYPE_DOUBLE((GType) ((15) << (2))));
1036}
1037
1038EvJob *
1039ev_job_fonts_new (EvDocument *document)
1040{
1041 EvJobFonts *job;
1042
1043 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1044
1045 job = g_object_new (EV_TYPE_JOB_FONTS(ev_job_fonts_get_type()), NULL((void*)0));
1046
1047 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
1048
1049 return EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
;
1050}
1051
1052/* EvJobLoad */
1053static void
1054ev_job_load_init (EvJobLoad *job)
1055{
1056 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
1057}
1058
1059static void
1060ev_job_load_dispose (GObject *object)
1061{
1062 EvJobLoad *job = EV_JOB_LOAD (object)((((EvJobLoad*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_load_get_type()))))))
;
1063
1064 ev_debug_message (DEBUG_JOBS, "%s", job->uri)do { } while (0);
1065
1066 if (job->uri) {
1067 g_free (job->uri);
1068 job->uri = NULL((void*)0);
1069 }
1070
1071 if (job->password) {
1072 g_free (job->password);
1073 job->password = NULL((void*)0);
1074 }
1075
1076 (* G_OBJECT_CLASS (ev_job_load_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_load_parent_class)), (((GType) ((20) << (2)
)))))))
->dispose) (object);
1077}
1078
1079static gboolean
1080ev_job_load_run (EvJob *job)
1081{
1082 EvJobLoad *job_load = EV_JOB_LOAD (job)((((EvJobLoad*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_load_get_type()))))))
;
1083 GError *error = NULL((void*)0);
1084
1085 ev_debug_message (DEBUG_JOBS, "%s", job_load->uri)do { } while (0);
1086 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
1087
1088 ev_document_fc_mutex_lock ();
1089
1090 /* This job may already have a document even if the job didn't complete
1091 because, e.g., a password is required - if so, just reload rather than
1092 creating a new instance */
1093 if (job->document) {
1094 const gchar *uncompressed_uri;
1095
1096 if (job_load->password) {
1097 ev_document_security_set_password (EV_DOCUMENT_SECURITY (job->document)((((EvDocumentSecurity*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((job->document)), ((ev_document_security_get_type
()))))))
,
1098 job_load->password);
1099 }
1100
1101 job->failed = FALSE(0);
1102 job->finished = FALSE(0);
1103 g_clear_error (&job->error);
1104
1105 uncompressed_uri = g_object_get_data (G_OBJECT (job->document)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), (((GType) ((20) << (2))))))))
,
1106 "uri-uncompressed");
1107 ev_document_load (job->document,
1108 uncompressed_uri ? uncompressed_uri : job_load->uri,
1109 &error);
1110 } else {
1111 job->document = ev_document_factory_get_document (job_load->uri,
1112 &error);
1113 }
1114
1115 ev_document_fc_mutex_unlock ();
1116
1117 if (error) {
1118 ev_job_failed_from_error (job, error);
1119 g_error_free (error);
1120 } else {
1121 ev_job_succeeded (job);
1122 }
1123
1124 return FALSE(0);
1125}
1126
1127static void
1128ev_job_load_class_init (EvJobLoadClass *class)
1129{
1130 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
1131 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
1132
1133 oclass->dispose = ev_job_load_dispose;
1134 job_class->run = ev_job_load_run;
1135}
1136
1137EvJob *
1138ev_job_load_new (const gchar *uri)
1139{
1140 EvJobLoad *job;
1141
1142 ev_debug_message (DEBUG_JOBS, "%s", uri)do { } while (0);
1143
1144 job = g_object_new (EV_TYPE_JOB_LOAD(ev_job_load_get_type()), NULL((void*)0));
1145 job->uri = g_strdup (uri)g_strdup_inline (uri);
1146
1147 return EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
;
1148}
1149
1150void
1151ev_job_load_set_uri (EvJobLoad *job, const gchar *uri)
1152{
1153 ev_debug_message (DEBUG_JOBS, "%s", uri)do { } while (0);
1154
1155 if (job->uri)
1156 g_free (job->uri);
1157 job->uri = g_strdup (uri)g_strdup_inline (uri);
1158}
1159
1160void
1161ev_job_load_set_password (EvJobLoad *job, const gchar *password)
1162{
1163 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1164
1165 if (job->password)
1166 g_free (job->password);
1167 job->password = password ? g_strdup (password)g_strdup_inline (password) : NULL((void*)0);
1168}
1169
1170/* EvJobSave */
1171static void
1172ev_job_save_init (EvJobSave *job)
1173{
1174 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
1175}
1176
1177static void
1178ev_job_save_dispose (GObject *object)
1179{
1180 EvJobSave *job = EV_JOB_SAVE (object)((((EvJobSave*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_save_get_type()))))))
;
1181
1182 ev_debug_message (DEBUG_JOBS, "%s", job->uri)do { } while (0);
1183
1184 if (job->uri) {
1185 g_free (job->uri);
1186 job->uri = NULL((void*)0);
1187 }
1188
1189 if (job->document_uri) {
1190 g_free (job->document_uri);
1191 job->document_uri = NULL((void*)0);
1192 }
1193
1194 (* G_OBJECT_CLASS (ev_job_save_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_save_parent_class)), (((GType) ((20) << (2)
)))))))
->dispose) (object);
1195}
1196
1197static gboolean
1198ev_job_save_run (EvJob *job)
1199{
1200 EvJobSave *job_save = EV_JOB_SAVE (job)((((EvJobSave*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_save_get_type()))))))
;
1201 gint fd;
1202 gchar *tmp_filename = NULL((void*)0);
1203 gchar *local_uri;
1204 GError *error = NULL((void*)0);
1205
1206 ev_debug_message (DEBUG_JOBS, "uri: %s, document_uri: %s", job_save->uri, job_save->document_uri)do { } while (0);
1207 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
1208
1209 fd = ev_mkstemp ("saveacopy.XXXXXX", &tmp_filename, &error);
1210 if (fd == -1) {
1211 ev_job_failed_from_error (job, error);
1212 g_error_free (error);
1213
1214 return FALSE(0);
1215 }
1216
1217 ev_document_doc_mutex_lock ();
1218
1219 /* Save document to temp filename */
1220 local_uri = g_filename_to_uri (tmp_filename, NULL((void*)0), &error);
1221 if (local_uri != NULL((void*)0)) {
1222 ev_document_save (job->document, local_uri, &error);
1223 }
1224
1225 close (fd);
1226
1227 ev_document_doc_mutex_unlock ();
1228
1229 if (error) {
1230 g_free (local_uri);
1231 ev_job_failed_from_error (job, error);
1232 g_error_free (error);
1233
1234 return FALSE(0);
1235 }
1236
1237 /* If original document was compressed,
1238 * compress it again before saving
1239 */
1240 if (g_object_get_data (G_OBJECT (job->document)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), (((GType) ((20) << (2))))))))
, "uri-uncompressed")) {
1241 EvCompressionType ctype = EV_COMPRESSION_NONE;
1242 const gchar *ext;
1243 gchar *uri_comp;
1244
1245 ext = g_strrstr (job_save->document_uri, ".gz");
1246 if (ext && g_ascii_strcasecmp (ext, ".gz") == 0)
1247 ctype = EV_COMPRESSION_GZIP;
1248
1249 ext = g_strrstr (job_save->document_uri, ".bz2");
1250 if (ext && g_ascii_strcasecmp (ext, ".bz2") == 0)
1251 ctype = EV_COMPRESSION_BZIP2;
1252
1253 uri_comp = ev_file_compress (local_uri, ctype, &error);
1254 g_free (local_uri);
1255 g_unlink (tmp_filename);
1256
1257 if (!uri_comp || error) {
1258 local_uri = NULL((void*)0);
1259 } else {
1260 local_uri = uri_comp;
1261 }
1262 }
1263
1264 g_free (tmp_filename);
1265
1266 if (error) {
1267 g_free (local_uri);
1268 ev_job_failed_from_error (job, error);
1269 g_error_free (error);
1270
1271 return FALSE(0);
1272 }
1273
1274 if (!local_uri)
1275 return FALSE(0);
1276
1277 ev_xfer_uri_simple (local_uri, job_save->uri, &error);
1278 ev_tmp_uri_unlink (local_uri);
1279
1280 if (error) {
1281 ev_job_failed_from_error (job, error);
1282 g_error_free (error);
1283 } else {
1284 ev_job_succeeded (job);
1285 }
1286
1287 return FALSE(0);
1288}
1289
1290static void
1291ev_job_save_class_init (EvJobSaveClass *class)
1292{
1293 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
1294 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
1295
1296 oclass->dispose = ev_job_save_dispose;
1297 job_class->run = ev_job_save_run;
1298}
1299
1300EvJob *
1301ev_job_save_new (EvDocument *document,
1302 const gchar *uri,
1303 const gchar *document_uri)
1304{
1305 EvJobSave *job;
1306
1307 ev_debug_message (DEBUG_JOBS, "uri: %s, document_uri: %s", uri, document_uri)do { } while (0);
1308
1309 job = g_object_new (EV_TYPE_JOB_SAVE(ev_job_save_get_type()), NULL((void*)0));
1310
1311 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
1312 job->uri = g_strdup (uri)g_strdup_inline (uri);
1313 job->document_uri = g_strdup (document_uri)g_strdup_inline (document_uri);
1314
1315 return EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
;
1316}
1317
1318/* EvJobFind */
1319static void
1320ev_job_find_init (EvJobFind *job)
1321{
1322 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_MAIN_LOOP;
1323}
1324
1325static void
1326ev_job_find_dispose (GObject *object)
1327{
1328 EvJobFind *job = EV_JOB_FIND (object)((((EvJobFind*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_find_get_type()))))))
;
1329
1330 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1331
1332 if (job->text) {
1333 g_free (job->text);
1334 job->text = NULL((void*)0);
1335 }
1336
1337 if (job->pages) {
1338 gint i;
1339
1340 for (i = 0; i < job->n_pages; i++) {
1341 g_list_foreach (job->pages[i], (GFunc)ev_rectangle_free, NULL((void*)0));
1342 g_list_free (job->pages[i]);
1343 }
1344
1345 g_free (job->pages);
1346 job->pages = NULL((void*)0);
1347 }
1348
1349 if (job->results) {
1350 g_free(job->results);
1351 }
1352
1353 (* G_OBJECT_CLASS (ev_job_find_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_find_parent_class)), (((GType) ((20) << (2)
)))))))
->dispose) (object);
1354}
1355
1356static gboolean
1357ev_job_find_run (EvJob *job)
1358{
1359 EvJobFind *job_find = EV_JOB_FIND (job)((((EvJobFind*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_find_get_type()))))))
;
1360 EvDocumentFind *find = EV_DOCUMENT_FIND (job->document)((((EvDocumentFind*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_find_get_type ()))))))
;
1361 EvPage *ev_page;
1362 GList *matches;
1363 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1364
1365 /* Do not block the main loop */
1366 if (!ev_document_doc_mutex_trylock ())
1367 return TRUE(!(0));
1368
1369#ifdef EV_ENABLE_DEBUG
1370 /* We use the #ifdef in this case because of the if */
1371 if (job_find->current_page == job_find->start_page)
1372 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
1373#endif
1374
1375 ev_page = ev_document_get_page (job->document, job_find->current_page);
1376
1377 if (job->document->iswebdocument) {
1378 job_find->results[job_find->current_page] = ev_document_find_check_for_hits(find, ev_page, job_find->text,
1379 job_find->case_sensitive);
1380 }else {
1381 matches = ev_document_find_find_text (find, ev_page, job_find->text,
1382 job_find->case_sensitive);
1383 }
1384
1385 g_object_unref (ev_page);
1386
1387 ev_document_doc_mutex_unlock ();
1388
1389 if (!job_find->has_results && !job->document->iswebdocument) {
1390 job_find->has_results = (matches != NULL((void*)0));
1391 }
1392 else if (!job_find->has_results && job->document->iswebdocument){
1393 job_find->has_results = (job_find->results[job_find->current_page] > 0);
1394 }
1395
1396 if (job->document->iswebdocument == FALSE(0)) {
1397 job_find->pages[job_find->current_page] = matches;
1398 }
1399
1400 g_signal_emit (job_find, job_find_signals[FIND_UPDATED], 0, job_find->current_page);
1401
1402 job_find->current_page = (job_find->current_page + 1) % job_find->n_pages;
1403 if (job_find->current_page == job_find->start_page) {
1404 ev_job_succeeded (job);
1405
1406 return FALSE(0);
1407 }
1408
1409 return TRUE(!(0));
1410}
1411
1412static void
1413ev_job_find_class_init (EvJobFindClass *class)
1414{
1415 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
1416 GObjectClass *gobject_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
1417
1418 job_class->run = ev_job_find_run;
1419 gobject_class->dispose = ev_job_find_dispose;
1420
1421 job_find_signals[FIND_UPDATED] =
1422 g_signal_new ("updated",
1423 EV_TYPE_JOB_FIND(ev_job_find_get_type()),
1424 G_SIGNAL_RUN_LAST,
1425 G_STRUCT_OFFSET (EvJobFindClass, updated)((glong) __builtin_offsetof(EvJobFindClass, updated)),
1426 NULL((void*)0), NULL((void*)0),
1427 g_cclosure_marshal_VOID__INT,
1428 G_TYPE_NONE((GType) ((1) << (2))),
1429 1, G_TYPE_INT((GType) ((6) << (2))));
1430}
1431
1432EvJob *
1433ev_job_find_new (EvDocument *document,
1434 gint start_page,
1435 gint n_pages,
1436 const gchar *text,
1437 gboolean case_sensitive)
1438{
1439 EvJobFind *job;
1440
1441 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1442
1443 job = g_object_new (EV_TYPE_JOB_FIND(ev_job_find_get_type()), NULL((void*)0));
1444
1445 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
1446 job->start_page = start_page;
1447 job->current_page = start_page;
1448 job->n_pages = n_pages;
1449
1450 if (document->iswebdocument) {
1451 job->results = g_malloc0 (sizeof(guint) *n_pages);
1452 }
1453 else {
1454 job->pages = g_new0 (GList *, n_pages)((GList * *) g_malloc0_n ((n_pages), sizeof (GList *)));
1455 }
1456 job->text = g_strdup (text)g_strdup_inline (text);
1457 job->case_sensitive = case_sensitive;
1458 job->has_results = FALSE(0);
1459
1460 return EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
;
1461}
1462
1463gint
1464ev_job_find_get_n_results (EvJobFind *job,
1465 gint page)
1466{
1467 if (EV_JOB(job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->document->iswebdocument) {
1468 return job->results[page];
1469 }
1470 else {
1471 return g_list_length (job->pages[page]);
1472 }
1473}
1474
1475gdouble
1476ev_job_find_get_progress (EvJobFind *job)
1477{
1478 gint pages_done;
1479
1480 if (ev_job_is_finished (EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
))
1481 return 1.0;
1482
1483 if (job->current_page > job->start_page) {
1484 pages_done = job->current_page - job->start_page + 1;
1485 } else if (job->current_page == job->start_page) {
1486 pages_done = job->n_pages;
1487 } else {
1488 pages_done = job->n_pages - job->start_page + job->current_page;
1489 }
1490
1491 return pages_done / (gdouble) job->n_pages;
1492}
1493
1494gboolean
1495ev_job_find_has_results (EvJobFind *job)
1496{
1497 return job->has_results;
1498}
1499
1500/**
1501 * ev_job_find_get_results: (skip)
1502 * @job: an #EvJobFind
1503 *
1504 * Returns: a #GList of #GList<!-- -->s containing #EvRectangle<!-- -->s
1505 */
1506GList **
1507ev_job_find_get_results (EvJobFind *job)
1508{
1509 return job->pages;
1510}
1511
1512/* EvJobLayers */
1513static void
1514ev_job_layers_init (EvJobLayers *job)
1515{
1516 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
1517}
1518
1519static void
1520ev_job_layers_dispose (GObject *object)
1521{
1522 EvJobLayers *job;
1523
1524 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1525
1526 job = EV_JOB_LAYERS (object)((((EvJobLayers*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_layers_get_type()))))))
;
1527
1528 if (job->model) {
1529 g_object_unref (job->model);
1530 job->model = NULL((void*)0);
1531 }
1532
1533 (* G_OBJECT_CLASS (ev_job_layers_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_layers_parent_class)), (((GType) ((20) << (
2))))))))
->dispose) (object);
1534}
1535
1536static gboolean
1537ev_job_layers_run (EvJob *job)
1538{
1539 EvJobLayers *job_layers = EV_JOB_LAYERS (job)((((EvJobLayers*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_layers_get_type()))))))
;
1540
1541 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1542 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
1543
1544 ev_document_doc_mutex_lock ();
1545 job_layers->model = ev_document_layers_get_layers (EV_DOCUMENT_LAYERS (job->document)((((EvDocumentLayers*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((job->document)), ((ev_document_layers_get_type
()))))))
);
1546 ev_document_doc_mutex_unlock ();
1547
1548 ev_job_succeeded (job);
1549
1550 return FALSE(0);
1551}
1552
1553static void
1554ev_job_layers_class_init (EvJobLayersClass *class)
1555{
1556 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
1557 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
1558
1559 oclass->dispose = ev_job_layers_dispose;
1560 job_class->run = ev_job_layers_run;
1561}
1562
1563EvJob *
1564ev_job_layers_new (EvDocument *document)
1565{
1566 EvJob *job;
1567
1568 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1569
1570 job = g_object_new (EV_TYPE_JOB_LAYERS(ev_job_layers_get_type()), NULL((void*)0));
1571 job->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
1572
1573 return job;
1574}
1575
1576/* EvJobExport */
1577static void
1578ev_job_export_init (EvJobExport *job)
1579{
1580 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
1581 job->page = -1;
1582}
1583
1584static void
1585ev_job_export_dispose (GObject *object)
1586{
1587 EvJobExport *job;
1588
1589 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1590
1591 job = EV_JOB_EXPORT (object)((((EvJobExport*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_export_get_type()))))))
;
1592
1593 if (job->rc) {
1594 g_object_unref (job->rc);
1595 job->rc = NULL((void*)0);
1596 }
1597
1598 (* G_OBJECT_CLASS (ev_job_export_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_export_parent_class)), (((GType) ((20) << (
2))))))))
->dispose) (object);
1599}
1600
1601static gboolean
1602ev_job_export_run (EvJob *job)
1603{
1604 EvJobExport *job_export = EV_JOB_EXPORT (job)((((EvJobExport*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_export_get_type()))))))
;
1605 EvPage *ev_page;
1606
1607 g_assert (job_export->page != -1)do { if (job_export->page != -1) ; else g_assertion_message_expr
("LectorView", "ev-jobs.c", 1607, ((const char*) (__func__))
, "job_export->page != -1"); } while (0)
;
1608
1609 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1610 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
1611
1612 ev_document_doc_mutex_lock ();
1613
1614 ev_page = ev_document_get_page (job->document, job_export->page);
1615 if (job_export->rc) {
1616 job->failed = FALSE(0);
1617 job->finished = FALSE(0);
1618 g_clear_error (&job->error);
1619
1620 ev_render_context_set_page (job_export->rc, ev_page);
1621 } else {
1622 job_export->rc = ev_render_context_new (ev_page, 0, 1.0);
1623 }
1624 g_object_unref (ev_page);
1625
1626 ev_file_exporter_do_page (EV_FILE_EXPORTER (job->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_file_exporter_get_type ()))))))
, job_export->rc);
1627
1628 ev_document_doc_mutex_unlock ();
1629
1630 ev_job_succeeded (job);
1631
1632 return FALSE(0);
1633}
1634
1635static void
1636ev_job_export_class_init (EvJobExportClass *class)
1637{
1638 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
1639 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
1640
1641 oclass->dispose = ev_job_export_dispose;
1642 job_class->run = ev_job_export_run;
1643}
1644
1645EvJob *
1646ev_job_export_new (EvDocument *document)
1647{
1648 EvJob *job;
1649
1650 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1651
1652 job = g_object_new (EV_TYPE_JOB_EXPORT(ev_job_export_get_type()), NULL((void*)0));
1653 job->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
1654
1655 return job;
1656}
1657
1658void
1659ev_job_export_set_page (EvJobExport *job,
1660 gint page)
1661{
1662 job->page = page;
1663}
1664
1665/* EvJobPrint */
1666static void
1667ev_job_print_init (EvJobPrint *job)
1668{
1669 EV_JOB (job)((((EvJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_get_type()))))))
->run_mode = EV_JOB_RUN_THREAD;
1670 job->page = -1;
1671}
1672
1673static void
1674ev_job_print_dispose (GObject *object)
1675{
1676 EvJobPrint *job;
1677
1678 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1679
1680 job = EV_JOB_PRINT (object)((((EvJobPrint*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ev_job_print_get_type()))))))
;
1681
1682 if (job->cr) {
1683 cairo_destroy (job->cr);
1684 job->cr = NULL((void*)0);
1685 }
1686
1687 (* G_OBJECT_CLASS (ev_job_print_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ev_job_print_parent_class)), (((GType) ((20) << (2
))))))))
->dispose) (object);
1688}
1689
1690static gboolean
1691ev_job_print_run (EvJob *job)
1692{
1693 EvJobPrint *job_print = EV_JOB_PRINT (job)((((EvJobPrint*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((ev_job_print_get_type()))))))
;
1694 EvPage *ev_page;
1695 cairo_status_t cr_status;
1696
1697 g_assert (job_print->page != -1)do { if (job_print->page != -1) ; else g_assertion_message_expr
("LectorView", "ev-jobs.c", 1697, ((const char*) (__func__))
, "job_print->page != -1"); } while (0)
;
1698 g_assert (job_print->cr != NULL)do { if (job_print->cr != ((void*)0)) ; else g_assertion_message_expr
("LectorView", "ev-jobs.c", 1698, ((const char*) (__func__))
, "job_print->cr != NULL"); } while (0)
;
1699
1700 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1701 ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job)do { } while (0);
1702
1703 job->failed = FALSE(0);
1704 job->finished = FALSE(0);
1705 g_clear_error (&job->error);
1706
1707 ev_document_doc_mutex_lock ();
1708
1709 ev_page = ev_document_get_page (job->document, job_print->page);
1710 ev_document_print_print_page (EV_DOCUMENT_PRINT (job->document)((((EvDocumentPrint*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->document)), ((ev_document_print_get_type ())))))
)
,
1711 ev_page, job_print->cr);
1712 g_object_unref (ev_page);
1713
1714 ev_document_doc_mutex_unlock ();
1715
1716 if (g_cancellable_is_cancelled (job->cancellable))
1717 return FALSE(0);
1718
1719 cr_status = cairo_status (job_print->cr);
1720 if (cr_status == CAIRO_STATUS_SUCCESS) {
1721 ev_job_succeeded (job);
1722 } else {
1723 ev_job_failed (job,
1724 CTK_PRINT_ERRORctk_print_error_quark (),
1725 CTK_PRINT_ERROR_GENERAL,
1726 _("Failed to print page %d: %s")((char *) g_dgettext ("lector", "Failed to print page %d: %s"
))
,
1727 job_print->page,
1728 cairo_status_to_string (cr_status));
1729 }
1730
1731 return FALSE(0);
1732}
1733
1734static void
1735ev_job_print_class_init (EvJobPrintClass *class)
1736{
1737 GObjectClass *oclass = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
1738 EvJobClass *job_class = EV_JOB_CLASS (class)((((EvJobClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ev_job_get_type()))))))
;
1739
1740 oclass->dispose = ev_job_print_dispose;
1741 job_class->run = ev_job_print_run;
1742}
1743
1744EvJob *
1745ev_job_print_new (EvDocument *document)
1746{
1747 EvJob *job;
1748
1749 ev_debug_message (DEBUG_JOBS, NULL)do { } while (0);
1750
1751 job = g_object_new (EV_TYPE_JOB_PRINT(ev_job_print_get_type()), NULL((void*)0));
1752 job->document = g_object_ref (document)((__typeof__ (document)) (g_object_ref) (document));
1753
1754 return job;
1755}
1756
1757void
1758ev_job_print_set_page (EvJobPrint *job,
1759 gint page)
1760{
1761 job->page = page;
1762}
1763
1764void
1765ev_job_print_set_cairo (EvJobPrint *job,
1766 cairo_t *cr)
1767{
1768 if (job->cr == cr)
1769 return;
1770
1771 if (job->cr)
1772 cairo_destroy (job->cr);
1773 job->cr = cr ? cairo_reference (cr) : NULL((void*)0);
1774}