| File: | libview/ev-print-operation.c |
| Warning: | line 601, column 11 Access of the field 'one_range' at negative byte offset -8 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* this file is part of lector, a cafe document viewer | |||
| 2 | * | |||
| 3 | * Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org> | |||
| 4 | * | |||
| 5 | * Lector is free software; you can redistribute it and/or modify it | |||
| 6 | * under the terms of the GNU General Public License as published by | |||
| 7 | * the Free Software Foundation; either version 2 of the License, or | |||
| 8 | * (at your option) any later version. | |||
| 9 | * | |||
| 10 | * Lector is distributed in the hope that it will be useful, but | |||
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
| 13 | * General Public License for more details. | |||
| 14 | * | |||
| 15 | * You should have received a copy of the GNU General Public License | |||
| 16 | * along with this program; if not, write to the Free Software | |||
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 18 | */ | |||
| 19 | ||||
| 20 | #include <config.h> | |||
| 21 | ||||
| 22 | #include "ev-print-operation.h" | |||
| 23 | ||||
| 24 | #if CTKUNIXPRINT_ENABLED1 | |||
| 25 | #include <ctk/ctkunixprint.h> | |||
| 26 | #endif | |||
| 27 | #include <glib/gi18n.h> | |||
| 28 | #include <glib/gstdio.h> | |||
| 29 | #include <unistd.h> | |||
| 30 | ||||
| 31 | #include "ev-jobs.h" | |||
| 32 | #include "ev-job-scheduler.h" | |||
| 33 | ||||
| 34 | enum { | |||
| 35 | PROP_0, | |||
| 36 | PROP_DOCUMENT | |||
| 37 | }; | |||
| 38 | ||||
| 39 | enum { | |||
| 40 | DONE, | |||
| 41 | BEGIN_PRINT, | |||
| 42 | STATUS_CHANGED, | |||
| 43 | LAST_SIGNAL | |||
| 44 | }; | |||
| 45 | ||||
| 46 | static guint signals[LAST_SIGNAL] = { 0 }; | |||
| 47 | ||||
| 48 | struct _EvPrintOperation { | |||
| 49 | GObject parent; | |||
| 50 | ||||
| 51 | EvDocument *document; | |||
| 52 | ||||
| 53 | /* Progress */ | |||
| 54 | gchar *status; | |||
| 55 | gdouble progress; | |||
| 56 | }; | |||
| 57 | ||||
| 58 | struct _EvPrintOperationClass { | |||
| 59 | GObjectClass parent_class; | |||
| 60 | ||||
| 61 | void (* set_current_page) (EvPrintOperation *op, | |||
| 62 | gint current_page); | |||
| 63 | void (* set_print_settings) (EvPrintOperation *op, | |||
| 64 | CtkPrintSettings *print_settings); | |||
| 65 | CtkPrintSettings *(* get_print_settings) (EvPrintOperation *op); | |||
| 66 | void (* set_default_page_setup) (EvPrintOperation *op, | |||
| 67 | CtkPageSetup *page_setup); | |||
| 68 | CtkPageSetup *(* get_default_page_setup) (EvPrintOperation *op); | |||
| 69 | void (* set_job_name) (EvPrintOperation *op, | |||
| 70 | const gchar *job_name); | |||
| 71 | const gchar *(* get_job_name) (EvPrintOperation *op); | |||
| 72 | void (* run) (EvPrintOperation *op, | |||
| 73 | CtkWindow *parent); | |||
| 74 | void (* cancel) (EvPrintOperation *op); | |||
| 75 | void (* get_error) (EvPrintOperation *op, | |||
| 76 | GError **error); | |||
| 77 | void (* set_embed_page_setup) (EvPrintOperation *op, | |||
| 78 | gboolean embed); | |||
| 79 | gboolean (* get_embed_page_setup) (EvPrintOperation *op); | |||
| 80 | ||||
| 81 | /* signals */ | |||
| 82 | void (* done) (EvPrintOperation *op, | |||
| 83 | CtkPrintOperationResult result); | |||
| 84 | void (* begin_print) (EvPrintOperation *op); | |||
| 85 | void (* status_changed) (EvPrintOperation *op); | |||
| 86 | }; | |||
| 87 | ||||
| 88 | G_DEFINE_ABSTRACT_TYPE (EvPrintOperation, ev_print_operation, G_TYPE_OBJECT)static void ev_print_operation_init (EvPrintOperation *self); static void ev_print_operation_class_init (EvPrintOperationClass *klass); static GType ev_print_operation_get_type_once (void ); static gpointer ev_print_operation_parent_class = ((void*) 0); static gint EvPrintOperation_private_offset; static void ev_print_operation_class_intern_init (gpointer klass) { ev_print_operation_parent_class = g_type_class_peek_parent (klass); if (EvPrintOperation_private_offset != 0) g_type_class_adjust_private_offset (klass, &EvPrintOperation_private_offset); ev_print_operation_class_init ((EvPrintOperationClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ev_print_operation_get_instance_private (EvPrintOperation *self) { return (((gpointer) ((guint8*) (self ) + (glong) (EvPrintOperation_private_offset)))); } GType ev_print_operation_get_type (void) { static GType 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_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ev_print_operation_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_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ev_print_operation_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple (((GType) ((20) << (2))), g_intern_static_string ("EvPrintOperation" ), sizeof (EvPrintOperationClass), (GClassInitFunc)(void (*)( void)) ev_print_operation_class_intern_init, sizeof (EvPrintOperation ), (GInstanceInitFunc)(void (*)(void)) ev_print_operation_init , (GTypeFlags) G_TYPE_FLAG_ABSTRACT); { {{};} } return g_define_type_id ; } | |||
| 89 | ||||
| 90 | static void | |||
| 91 | ev_print_operation_finalize (GObject *object) | |||
| 92 | { | |||
| 93 | EvPrintOperation *op = EV_PRINT_OPERATION (object)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((object)), ((ev_print_operation_get_type())) )))); | |||
| 94 | ||||
| 95 | if (op->document) { | |||
| 96 | g_object_unref (op->document); | |||
| 97 | op->document = NULL((void*)0); | |||
| 98 | } | |||
| 99 | ||||
| 100 | if (op->status) { | |||
| 101 | g_free (op->status); | |||
| 102 | op->status = NULL((void*)0); | |||
| 103 | } | |||
| 104 | ||||
| 105 | (* G_OBJECT_CLASS (ev_print_operation_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ev_print_operation_parent_class)), (((GType) ((20) << (2))))))))->finalize) (object); | |||
| 106 | } | |||
| 107 | ||||
| 108 | static void | |||
| 109 | ev_print_operation_set_property (GObject *object, | |||
| 110 | guint prop_id, | |||
| 111 | const GValue *value, | |||
| 112 | GParamSpec *pspec) | |||
| 113 | { | |||
| 114 | EvPrintOperation *op = EV_PRINT_OPERATION (object)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((object)), ((ev_print_operation_get_type())) )))); | |||
| 115 | ||||
| 116 | switch (prop_id) { | |||
| 117 | case PROP_DOCUMENT: | |||
| 118 | op->document = g_value_dup_object (value); | |||
| 119 | break; | |||
| 120 | default: | |||
| 121 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ev-print-operation.c", 121, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
| 122 | } | |||
| 123 | } | |||
| 124 | ||||
| 125 | static void | |||
| 126 | ev_print_operation_init (EvPrintOperation *op) | |||
| 127 | { | |||
| 128 | } | |||
| 129 | ||||
| 130 | static void | |||
| 131 | ev_print_operation_class_init (EvPrintOperationClass *klass) | |||
| 132 | { | |||
| 133 | GObjectClass *g_object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); | |||
| 134 | ||||
| 135 | g_object_class->set_property = ev_print_operation_set_property; | |||
| 136 | g_object_class->finalize = ev_print_operation_finalize; | |||
| 137 | ||||
| 138 | g_object_class_install_property (g_object_class, | |||
| 139 | PROP_DOCUMENT, | |||
| 140 | g_param_spec_object ("document", | |||
| 141 | "Document", | |||
| 142 | "The document to print", | |||
| 143 | EV_TYPE_DOCUMENT(ev_document_get_type ()), | |||
| 144 | G_PARAM_WRITABLE | | |||
| 145 | G_PARAM_CONSTRUCT_ONLY)); | |||
| 146 | signals[DONE] = | |||
| 147 | g_signal_new ("done", | |||
| 148 | G_TYPE_FROM_CLASS (g_object_class)(((GTypeClass*) (g_object_class))->g_type), | |||
| 149 | G_SIGNAL_RUN_LAST, | |||
| 150 | G_STRUCT_OFFSET (EvPrintOperationClass, done)((glong) __builtin_offsetof(EvPrintOperationClass, done)), | |||
| 151 | NULL((void*)0), NULL((void*)0), | |||
| 152 | g_cclosure_marshal_VOID__ENUM, | |||
| 153 | G_TYPE_NONE((GType) ((1) << (2))), 1, | |||
| 154 | CTK_TYPE_PRINT_OPERATION_RESULT(ctk_print_operation_result_get_type ())); | |||
| 155 | signals[BEGIN_PRINT] = | |||
| 156 | g_signal_new ("begin_print", | |||
| 157 | G_TYPE_FROM_CLASS (g_object_class)(((GTypeClass*) (g_object_class))->g_type), | |||
| 158 | G_SIGNAL_RUN_LAST, | |||
| 159 | G_STRUCT_OFFSET (EvPrintOperationClass, begin_print)((glong) __builtin_offsetof(EvPrintOperationClass, begin_print )), | |||
| 160 | NULL((void*)0), NULL((void*)0), | |||
| 161 | g_cclosure_marshal_VOID__VOID, | |||
| 162 | G_TYPE_NONE((GType) ((1) << (2))), 0); | |||
| 163 | signals[STATUS_CHANGED] = | |||
| 164 | g_signal_new ("status_changed", | |||
| 165 | G_TYPE_FROM_CLASS (g_object_class)(((GTypeClass*) (g_object_class))->g_type), | |||
| 166 | G_SIGNAL_RUN_LAST, | |||
| 167 | G_STRUCT_OFFSET (EvPrintOperationClass, status_changed)((glong) __builtin_offsetof(EvPrintOperationClass, status_changed )), | |||
| 168 | NULL((void*)0), NULL((void*)0), | |||
| 169 | g_cclosure_marshal_VOID__VOID, | |||
| 170 | G_TYPE_NONE((GType) ((1) << (2))), 0); | |||
| 171 | } | |||
| 172 | ||||
| 173 | /* Public methods */ | |||
| 174 | void | |||
| 175 | ev_print_operation_set_current_page (EvPrintOperation *op, | |||
| 176 | gint current_page) | |||
| 177 | { | |||
| 178 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 179 | ||||
| 180 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 181 | g_return_if_fail (current_page >= 0)do { if ((current_page >= 0)) { } else { g_return_if_fail_warning ("LectorView", ((const char*) (__func__)), "current_page >= 0" ); return; } } while (0); | |||
| 182 | ||||
| 183 | class->set_current_page (op, current_page); | |||
| 184 | } | |||
| 185 | ||||
| 186 | void | |||
| 187 | ev_print_operation_set_print_settings (EvPrintOperation *op, | |||
| 188 | CtkPrintSettings *print_settings) | |||
| 189 | { | |||
| 190 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 191 | ||||
| 192 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 193 | g_return_if_fail (CTK_IS_PRINT_SETTINGS (print_settings))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((print_settings)); GType __t = ((ctk_print_settings_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; })))))) { } else { g_return_if_fail_warning ("LectorView" , ((const char*) (__func__)), "CTK_IS_PRINT_SETTINGS (print_settings)" ); return; } } while (0); | |||
| 194 | ||||
| 195 | class->set_print_settings (op, print_settings); | |||
| 196 | } | |||
| 197 | ||||
| 198 | /** | |||
| 199 | * ev_print_operation_get_print_settings: | |||
| 200 | * @op: an #EvPrintOperation | |||
| 201 | * | |||
| 202 | * Returns: (transfer none): a #CtkPrintSettings | |||
| 203 | */ | |||
| 204 | CtkPrintSettings * | |||
| 205 | ev_print_operation_get_print_settings (EvPrintOperation *op) | |||
| 206 | { | |||
| 207 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 208 | ||||
| 209 | g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return (((void* )0)); } } while (0); | |||
| 210 | ||||
| 211 | return class->get_print_settings (op); | |||
| 212 | } | |||
| 213 | ||||
| 214 | void | |||
| 215 | ev_print_operation_set_default_page_setup (EvPrintOperation *op, | |||
| 216 | CtkPageSetup *page_setup) | |||
| 217 | { | |||
| 218 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 219 | ||||
| 220 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 221 | g_return_if_fail (CTK_IS_PAGE_SETUP (page_setup))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((page_setup)); GType __t = ((ctk_page_setup_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; } )))))) { } else { g_return_if_fail_warning ("LectorView", ((const char*) (__func__)), "CTK_IS_PAGE_SETUP (page_setup)"); return ; } } while (0); | |||
| 222 | ||||
| 223 | class->set_default_page_setup (op, page_setup); | |||
| 224 | } | |||
| 225 | ||||
| 226 | /** | |||
| 227 | * ev_print_operation_get_default_page_setup: | |||
| 228 | * @op: an #EvPrintOperation | |||
| 229 | * | |||
| 230 | * Returns: (transfer none): a #CtkPageSetup | |||
| 231 | */ | |||
| 232 | CtkPageSetup * | |||
| 233 | ev_print_operation_get_default_page_setup (EvPrintOperation *op) | |||
| 234 | { | |||
| 235 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 236 | ||||
| 237 | g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return (((void* )0)); } } while (0); | |||
| 238 | ||||
| 239 | return class->get_default_page_setup (op); | |||
| 240 | } | |||
| 241 | ||||
| 242 | void | |||
| 243 | ev_print_operation_set_job_name (EvPrintOperation *op, | |||
| 244 | const gchar *job_name) | |||
| 245 | { | |||
| 246 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 247 | ||||
| 248 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 249 | g_return_if_fail (job_name != NULL)do { if ((job_name != ((void*)0))) { } else { g_return_if_fail_warning ("LectorView", ((const char*) (__func__)), "job_name != NULL" ); return; } } while (0); | |||
| 250 | ||||
| 251 | class->set_job_name (op, job_name); | |||
| 252 | } | |||
| 253 | ||||
| 254 | const gchar * | |||
| 255 | ev_print_operation_get_job_name (EvPrintOperation *op) | |||
| 256 | { | |||
| 257 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 258 | ||||
| 259 | g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return (((void* )0)); } } while (0); | |||
| 260 | ||||
| 261 | return class->get_job_name (op); | |||
| 262 | } | |||
| 263 | ||||
| 264 | void | |||
| 265 | ev_print_operation_run (EvPrintOperation *op, | |||
| 266 | CtkWindow *parent) | |||
| 267 | { | |||
| 268 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 269 | ||||
| 270 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 271 | ||||
| 272 | class->run (op, parent); | |||
| 273 | } | |||
| 274 | ||||
| 275 | void | |||
| 276 | ev_print_operation_cancel (EvPrintOperation *op) | |||
| 277 | { | |||
| 278 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 279 | ||||
| 280 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 281 | ||||
| 282 | class->cancel (op); | |||
| 283 | } | |||
| 284 | ||||
| 285 | void | |||
| 286 | ev_print_operation_get_error (EvPrintOperation *op, | |||
| 287 | GError **error) | |||
| 288 | { | |||
| 289 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 290 | ||||
| 291 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 292 | ||||
| 293 | class->get_error (op, error); | |||
| 294 | } | |||
| 295 | ||||
| 296 | void | |||
| 297 | ev_print_operation_set_embed_page_setup (EvPrintOperation *op, | |||
| 298 | gboolean embed) | |||
| 299 | { | |||
| 300 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 301 | ||||
| 302 | g_return_if_fail (EV_IS_PRINT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return; } } while (0); | |||
| 303 | ||||
| 304 | class->set_embed_page_setup (op, embed); | |||
| 305 | } | |||
| 306 | ||||
| 307 | gboolean | |||
| 308 | ev_print_operation_get_embed_page_setup (EvPrintOperation *op) | |||
| 309 | { | |||
| 310 | EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op)((((EvPrintOperationClass*) (((GTypeInstance*) ((op)))->g_class )))); | |||
| 311 | ||||
| 312 | g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return ((0)); } } while (0); | |||
| 313 | ||||
| 314 | return class->get_embed_page_setup (op); | |||
| 315 | } | |||
| 316 | ||||
| 317 | const gchar * | |||
| 318 | ev_print_operation_get_status (EvPrintOperation *op) | |||
| 319 | { | |||
| 320 | g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return (((void* )0)); } } while (0); | |||
| 321 | ||||
| 322 | return op->status ? op->status : ""; | |||
| 323 | } | |||
| 324 | ||||
| 325 | gdouble | |||
| 326 | ev_print_operation_get_progress (EvPrintOperation *op) | |||
| 327 | { | |||
| 328 | g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), 0.0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ev_print_operation_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; })))))) { } else { g_return_if_fail_warning ("LectorView", ((const char* ) (__func__)), "EV_IS_PRINT_OPERATION (op)"); return (0.0); } } while (0); | |||
| 329 | ||||
| 330 | return op->progress; | |||
| 331 | } | |||
| 332 | ||||
| 333 | static void | |||
| 334 | ev_print_operation_update_status (EvPrintOperation *op, | |||
| 335 | gint page, | |||
| 336 | gint n_pages, | |||
| 337 | gdouble progress) | |||
| 338 | { | |||
| 339 | if (op->status && op->progress == progress) | |||
| 340 | return; | |||
| 341 | ||||
| 342 | g_free (op->status); | |||
| 343 | ||||
| 344 | if (page == -1) { | |||
| 345 | /* Initial state */ | |||
| 346 | op->status = g_strdup (_("Preparing to print…"))g_strdup_inline (gettext ("Preparing to print…")); | |||
| 347 | } else if (page > n_pages) { | |||
| 348 | op->status = g_strdup (_("Finishing…"))g_strdup_inline (gettext ("Finishing…")); | |||
| 349 | } else { | |||
| 350 | op->status = g_strdup_printf (_("Printing page %d of %d…")gettext ("Printing page %d of %d…"), | |||
| 351 | page, n_pages); | |||
| 352 | } | |||
| 353 | ||||
| 354 | op->progress = MIN (1.0, progress)(((1.0) < (progress)) ? (1.0) : (progress)); | |||
| 355 | ||||
| 356 | g_signal_emit (op, signals[STATUS_CHANGED], 0); | |||
| 357 | } | |||
| 358 | ||||
| 359 | #if CTKUNIXPRINT_ENABLED1 | |||
| 360 | ||||
| 361 | /* Export interface */ | |||
| 362 | #define EV_TYPE_PRINT_OPERATION_EXPORT(ev_print_operation_export_get_type()) (ev_print_operation_export_get_type()) | |||
| 363 | #define EV_PRINT_OPERATION_EXPORT(object)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ev_print_operation_export_get_type ())))))) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PRINT_OPERATION_EXPORT, EvPrintOperationExport)(((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ev_print_operation_export_get_type ())))))) | |||
| 364 | #define EV_PRINT_OPERATION_EXPORT_CLASS(klass)((((EvPrintOperationExportClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ev_print_operation_export_get_type ())))))) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_PRINT_OPERATION_EXPORT, EvPrintOperationExportClass)(((EvPrintOperationExportClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ev_print_operation_export_get_type ())))))) | |||
| 365 | #define EV_IS_PRINT_OPERATION_EXPORT(object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ev_print_operation_export_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; })))) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PRINT_OPERATION_EXPORT)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ev_print_operation_export_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; })))) | |||
| 366 | ||||
| 367 | typedef struct _EvPrintOperationExport EvPrintOperationExport; | |||
| 368 | typedef struct _EvPrintOperationExportClass EvPrintOperationExportClass; | |||
| 369 | ||||
| 370 | static GType ev_print_operation_export_get_type (void) G_GNUC_CONST__attribute__ ((__const__)); | |||
| 371 | ||||
| 372 | static void ev_print_operation_export_begin (EvPrintOperationExport *export); | |||
| 373 | static gboolean export_print_page (EvPrintOperationExport *export); | |||
| 374 | static void export_cancel (EvPrintOperationExport *export); | |||
| 375 | ||||
| 376 | struct _EvPrintOperationExport { | |||
| 377 | EvPrintOperation parent; | |||
| 378 | ||||
| 379 | CtkWindow *parent_window; | |||
| 380 | EvJob *job_export; | |||
| 381 | GError *error; | |||
| 382 | ||||
| 383 | gboolean print_preview; | |||
| 384 | gint n_pages; | |||
| 385 | gint current_page; | |||
| 386 | CtkPrinter *printer; | |||
| 387 | CtkPageSetup *page_setup; | |||
| 388 | CtkPrintSettings *print_settings; | |||
| 389 | CtkPageSet page_set; | |||
| 390 | gint copies; | |||
| 391 | guint collate : 1; | |||
| 392 | guint reverse : 1; | |||
| 393 | gint pages_per_sheet; | |||
| 394 | gint fd; | |||
| 395 | gchar *temp_file; | |||
| 396 | gchar *job_name; | |||
| 397 | gboolean embed_page_setup; | |||
| 398 | ||||
| 399 | guint idle_id; | |||
| 400 | ||||
| 401 | /* Context */ | |||
| 402 | EvFileExporterContext fc; | |||
| 403 | gint n_pages_to_print; | |||
| 404 | gint uncollated_copies; | |||
| 405 | gint collated_copies; | |||
| 406 | gint uncollated, collated, total; | |||
| 407 | ||||
| 408 | gint sheet, page_count; | |||
| 409 | ||||
| 410 | gint range, n_ranges; | |||
| 411 | CtkPageRange *ranges; | |||
| 412 | CtkPageRange one_range; | |||
| 413 | ||||
| 414 | gint page, start, end, inc; | |||
| 415 | }; | |||
| 416 | ||||
| 417 | struct _EvPrintOperationExportClass { | |||
| 418 | EvPrintOperationClass parent_class; | |||
| 419 | }; | |||
| 420 | ||||
| 421 | G_DEFINE_TYPE (EvPrintOperationExport, ev_print_operation_export, EV_TYPE_PRINT_OPERATION)static void ev_print_operation_export_init (EvPrintOperationExport *self); static void ev_print_operation_export_class_init (EvPrintOperationExportClass *klass); static GType ev_print_operation_export_get_type_once (void); static gpointer ev_print_operation_export_parent_class = ((void*)0); static gint EvPrintOperationExport_private_offset ; static void ev_print_operation_export_class_intern_init (gpointer klass) { ev_print_operation_export_parent_class = g_type_class_peek_parent (klass); if (EvPrintOperationExport_private_offset != 0) g_type_class_adjust_private_offset (klass, &EvPrintOperationExport_private_offset); ev_print_operation_export_class_init ((EvPrintOperationExportClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ev_print_operation_export_get_instance_private (EvPrintOperationExport *self) { return (((gpointer) ((guint8 *) (self) + (glong) (EvPrintOperationExport_private_offset))) ); } GType ev_print_operation_export_get_type (void) { static GType 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_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ev_print_operation_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_pointer ((&static_g_define_type_id ), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType ev_print_operation_export_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ev_print_operation_get_type()), g_intern_static_string ("EvPrintOperationExport" ), sizeof (EvPrintOperationExportClass), (GClassInitFunc)(void (*)(void)) ev_print_operation_export_class_intern_init, sizeof (EvPrintOperationExport), (GInstanceInitFunc)(void (*)(void) ) ev_print_operation_export_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; } | |||
| 422 | ||||
| 423 | /* Internal print queue */ | |||
| 424 | static GHashTable *print_queue = NULL((void*)0); | |||
| 425 | ||||
| 426 | static void | |||
| 427 | queue_free (GQueue *queue) | |||
| 428 | { | |||
| 429 | g_queue_foreach (queue, (GFunc)g_object_unref, NULL((void*)0)); | |||
| 430 | g_queue_free (queue); | |||
| 431 | } | |||
| 432 | ||||
| 433 | static void | |||
| 434 | ev_print_queue_init (void) | |||
| 435 | { | |||
| 436 | if (G_UNLIKELY (print_queue == NULL)(print_queue == ((void*)0))) { | |||
| 437 | print_queue = g_hash_table_new_full (g_direct_hash, | |||
| 438 | g_direct_equal, | |||
| 439 | NULL((void*)0), | |||
| 440 | (GDestroyNotify)queue_free); | |||
| 441 | } | |||
| 442 | } | |||
| 443 | ||||
| 444 | static void | |||
| 445 | remove_document_queue (gpointer data, | |||
| 446 | GObject *document) | |||
| 447 | { | |||
| 448 | if (print_queue) | |||
| 449 | g_hash_table_remove (print_queue, document); | |||
| 450 | } | |||
| 451 | ||||
| 452 | static gboolean | |||
| 453 | ev_print_queue_is_empty (EvDocument *document) | |||
| 454 | { | |||
| 455 | GQueue *queue; | |||
| 456 | ||||
| 457 | queue = g_hash_table_lookup (print_queue, document); | |||
| 458 | return (!queue || g_queue_is_empty (queue)); | |||
| 459 | } | |||
| 460 | ||||
| 461 | static void | |||
| 462 | ev_print_queue_push (EvPrintOperation *op) | |||
| 463 | { | |||
| 464 | GQueue *queue; | |||
| 465 | ||||
| 466 | queue = g_hash_table_lookup (print_queue, op->document); | |||
| 467 | if (!queue) { | |||
| 468 | queue = g_queue_new (); | |||
| 469 | g_hash_table_insert (print_queue, | |||
| 470 | op->document, | |||
| 471 | queue); | |||
| 472 | g_object_weak_ref (G_OBJECT (op->document)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), (((GType) ((20) << (2)))))))), | |||
| 473 | (GWeakNotify)remove_document_queue, | |||
| 474 | NULL((void*)0)); | |||
| 475 | } | |||
| 476 | ||||
| 477 | g_queue_push_head (queue, g_object_ref (op)((__typeof__ (op)) (g_object_ref) (op))); | |||
| 478 | } | |||
| 479 | ||||
| 480 | static EvPrintOperation * | |||
| 481 | ev_print_queue_pop (EvDocument *document) | |||
| 482 | { | |||
| 483 | EvPrintOperation *op; | |||
| 484 | GQueue *queue; | |||
| 485 | ||||
| 486 | queue = g_hash_table_lookup (print_queue, document); | |||
| 487 | if (!queue || g_queue_is_empty (queue)) | |||
| 488 | return NULL((void*)0); | |||
| 489 | ||||
| 490 | op = g_queue_pop_tail (queue); | |||
| 491 | g_object_unref (op); | |||
| 492 | ||||
| 493 | return op; | |||
| 494 | } | |||
| 495 | ||||
| 496 | static EvPrintOperation * | |||
| 497 | ev_print_queue_peek (EvDocument *document) | |||
| 498 | { | |||
| 499 | GQueue *queue; | |||
| 500 | ||||
| 501 | queue = g_hash_table_lookup (print_queue, document); | |||
| 502 | if (!queue || g_queue_is_empty (queue)) | |||
| 503 | return NULL((void*)0); | |||
| 504 | ||||
| 505 | return g_queue_peek_tail (queue); | |||
| 506 | } | |||
| 507 | ||||
| 508 | static void | |||
| 509 | ev_print_operation_export_set_current_page (EvPrintOperation *op, | |||
| 510 | gint current_page) | |||
| 511 | { | |||
| 512 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 513 | ||||
| 514 | g_return_if_fail (current_page < export->n_pages)do { if ((current_page < export->n_pages)) { } else { g_return_if_fail_warning ("LectorView", ((const char*) (__func__)), "current_page < export->n_pages" ); return; } } while (0); | |||
| 515 | ||||
| 516 | export->current_page = current_page; | |||
| 517 | } | |||
| 518 | ||||
| 519 | static void | |||
| 520 | ev_print_operation_export_set_print_settings (EvPrintOperation *op, | |||
| 521 | CtkPrintSettings *print_settings) | |||
| 522 | { | |||
| 523 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 524 | ||||
| 525 | if (print_settings == export->print_settings) | |||
| 526 | return; | |||
| 527 | ||||
| 528 | g_object_ref (print_settings)((__typeof__ (print_settings)) (g_object_ref) (print_settings )); | |||
| 529 | if (export->print_settings) | |||
| 530 | g_object_unref (export->print_settings); | |||
| 531 | export->print_settings = print_settings; | |||
| 532 | } | |||
| 533 | ||||
| 534 | static CtkPrintSettings * | |||
| 535 | ev_print_operation_export_get_print_settings (EvPrintOperation *op) | |||
| 536 | { | |||
| 537 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 538 | ||||
| 539 | return export->print_settings; | |||
| 540 | } | |||
| 541 | ||||
| 542 | static void | |||
| 543 | ev_print_operation_export_set_default_page_setup (EvPrintOperation *op, | |||
| 544 | CtkPageSetup *page_setup) | |||
| 545 | { | |||
| 546 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 547 | ||||
| 548 | if (page_setup == export->page_setup) | |||
| 549 | return; | |||
| 550 | ||||
| 551 | g_object_ref (page_setup)((__typeof__ (page_setup)) (g_object_ref) (page_setup)); | |||
| 552 | if (export->page_setup) | |||
| 553 | g_object_unref (export->page_setup); | |||
| 554 | export->page_setup = page_setup; | |||
| 555 | } | |||
| 556 | ||||
| 557 | static CtkPageSetup * | |||
| 558 | ev_print_operation_export_get_default_page_setup (EvPrintOperation *op) | |||
| 559 | { | |||
| 560 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 561 | ||||
| 562 | return export->page_setup; | |||
| 563 | } | |||
| 564 | ||||
| 565 | static void | |||
| 566 | ev_print_operation_export_set_job_name (EvPrintOperation *op, | |||
| 567 | const gchar *job_name) | |||
| 568 | { | |||
| 569 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 570 | ||||
| 571 | g_free (export->job_name); | |||
| 572 | export->job_name = g_strdup (job_name)g_strdup_inline (job_name); | |||
| 573 | } | |||
| 574 | ||||
| 575 | static const gchar * | |||
| 576 | ev_print_operation_export_get_job_name (EvPrintOperation *op) | |||
| 577 | { | |||
| 578 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 579 | ||||
| 580 | return export->job_name; | |||
| 581 | } | |||
| 582 | ||||
| 583 | static void | |||
| 584 | ev_print_operation_export_set_printer (EvPrintOperationExport *export, | |||
| 585 | CtkPrinter *printer) | |||
| 586 | { | |||
| 587 | if (printer == export->printer) | |||
| 588 | return; | |||
| 589 | ||||
| 590 | g_object_ref (printer)((__typeof__ (printer)) (g_object_ref) (printer)); | |||
| 591 | if (export->printer) | |||
| 592 | g_object_unref (export->printer); | |||
| 593 | export->printer = printer; | |||
| 594 | } | |||
| 595 | ||||
| 596 | static void | |||
| 597 | find_range (EvPrintOperationExport *export) | |||
| 598 | { | |||
| 599 | CtkPageRange *range; | |||
| 600 | ||||
| 601 | range = &export->ranges[export->range]; | |||
| ||||
| 602 | ||||
| 603 | if (export->inc < 0) { | |||
| 604 | export->start = range->end; | |||
| 605 | export->end = range->start - 1; | |||
| 606 | } else { | |||
| 607 | export->start = range->start; | |||
| 608 | export->end = range->end + 1; | |||
| 609 | } | |||
| 610 | } | |||
| 611 | ||||
| 612 | static gboolean | |||
| 613 | clamp_ranges (EvPrintOperationExport *export) | |||
| 614 | { | |||
| 615 | gint num_of_correct_ranges = 0; | |||
| 616 | gint n_pages_to_print = 0; | |||
| 617 | gint i; | |||
| 618 | gboolean null_flag = FALSE(0); | |||
| 619 | ||||
| 620 | for (i = 0; i < export->n_ranges; i++) { | |||
| 621 | gint n_pages; | |||
| 622 | ||||
| 623 | if ((export->ranges[i].start >= 0) && | |||
| 624 | (export->ranges[i].start < export->n_pages) && | |||
| 625 | (export->ranges[i].end >= 0) && | |||
| 626 | (export->ranges[i].end < export->n_pages)) { | |||
| 627 | export->ranges[num_of_correct_ranges] = export->ranges[i]; | |||
| 628 | num_of_correct_ranges++; | |||
| 629 | } else if ((export->ranges[i].start >= 0) && | |||
| 630 | (export->ranges[i].start < export->n_pages) && | |||
| 631 | (export->ranges[i].end >= export->n_pages)) { | |||
| 632 | export->ranges[i].end = export->n_pages - 1; | |||
| 633 | export->ranges[num_of_correct_ranges] = export->ranges[i]; | |||
| 634 | num_of_correct_ranges++; | |||
| 635 | } else if ((export->ranges[i].end >= 0) && | |||
| 636 | (export->ranges[i].end < export->n_pages) && | |||
| 637 | (export->ranges[i].start < 0)) { | |||
| 638 | export->ranges[i].start = 0; | |||
| 639 | export->ranges[num_of_correct_ranges] = export->ranges[i]; | |||
| 640 | num_of_correct_ranges++; | |||
| 641 | } | |||
| 642 | ||||
| 643 | n_pages = export->ranges[i].end - export->ranges[i].start + 1; | |||
| 644 | if (export->page_set == CTK_PAGE_SET_ALL) { | |||
| 645 | n_pages_to_print += n_pages; | |||
| 646 | } else if (n_pages % 2 == 0) { | |||
| 647 | n_pages_to_print += n_pages / 2; | |||
| 648 | } else if (export->page_set == CTK_PAGE_SET_EVEN) { | |||
| 649 | if (n_pages==1 && export->ranges[i].start % 2 == 0) | |||
| 650 | null_flag = TRUE(!(0)); | |||
| 651 | else | |||
| 652 | n_pages_to_print += export->ranges[i].start % 2 == 0 ? | |||
| 653 | n_pages / 2 : (n_pages / 2) + 1; | |||
| 654 | } else if (export->page_set == CTK_PAGE_SET_ODD) { | |||
| 655 | if (n_pages==1 && export->ranges[i].start % 2 != 0) | |||
| 656 | null_flag = TRUE(!(0)); | |||
| 657 | else | |||
| 658 | n_pages_to_print += export->ranges[i].start % 2 == 0 ? | |||
| 659 | (n_pages / 2) + 1 : n_pages / 2; | |||
| 660 | } | |||
| 661 | } | |||
| 662 | ||||
| 663 | if (null_flag && !n_pages_to_print) { | |||
| 664 | return FALSE(0); | |||
| 665 | } else { | |||
| 666 | export->n_ranges = num_of_correct_ranges; | |||
| 667 | export->n_pages_to_print = n_pages_to_print; | |||
| 668 | return TRUE(!(0)); | |||
| 669 | } | |||
| 670 | } | |||
| 671 | ||||
| 672 | static void | |||
| 673 | get_first_and_last_page (EvPrintOperationExport *export, | |||
| 674 | gint *first, | |||
| 675 | gint *last) | |||
| 676 | { | |||
| 677 | gint i; | |||
| 678 | gint first_page = G_MAXINT2147483647; | |||
| 679 | gint last_page = G_MININT(-2147483647 -1); | |||
| 680 | gint max_page = export->n_pages - 1; | |||
| 681 | ||||
| 682 | if (export->n_ranges == 0) { | |||
| 683 | *first = 0; | |||
| 684 | *last = max_page; | |||
| 685 | ||||
| 686 | return; | |||
| 687 | } | |||
| 688 | ||||
| 689 | for (i = 0; i < export->n_ranges; i++) { | |||
| 690 | if (export->ranges[i].start < first_page) | |||
| 691 | first_page = export->ranges[i].start; | |||
| 692 | if (export->ranges[i].end > last_page) | |||
| 693 | last_page = export->ranges[i].end; | |||
| 694 | } | |||
| 695 | ||||
| 696 | *first = MAX (0, first_page)(((0) > (first_page)) ? (0) : (first_page)); | |||
| 697 | *last = MIN (max_page, last_page)(((max_page) < (last_page)) ? (max_page) : (last_page)); | |||
| 698 | } | |||
| 699 | ||||
| 700 | static gboolean | |||
| 701 | export_print_inc_page (EvPrintOperationExport *export) | |||
| 702 | { | |||
| 703 | do { | |||
| 704 | export->page += export->inc; | |||
| 705 | ||||
| 706 | /* note: when NOT collating, page_count is increased in export_print_page */ | |||
| 707 | if (export->collate) { | |||
| 708 | export->page_count++; | |||
| 709 | export->sheet = 1 + (export->page_count - 1) / export->pages_per_sheet; | |||
| 710 | } | |||
| 711 | ||||
| 712 | if (export->page == export->end) { | |||
| 713 | export->range += export->inc; | |||
| 714 | if (export->range == -1 || export->range == export->n_ranges) { | |||
| 715 | export->uncollated++; | |||
| 716 | ||||
| 717 | /* when printing multiple collated copies & multiple pages per sheet we want to | |||
| 718 | * prevent the next copy bleeding into the last sheet of the previous one | |||
| 719 | * we've reached the last range to be printed now, so this is the time to do it */ | |||
| 720 | if (export->pages_per_sheet > 1 && export->collate == 1 && | |||
| 721 | (export->page_count - 1) % export->pages_per_sheet != 0) { | |||
| 722 | ||||
| 723 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 724 | ev_document_doc_mutex_lock (); | |||
| 725 | ||||
| 726 | /* keep track of all blanks but only actualise those | |||
| 727 | * which are in the current odd / even sheet set */ | |||
| 728 | ||||
| 729 | export->page_count += export->pages_per_sheet - (export->page_count - 1) % export->pages_per_sheet; | |||
| 730 | if (export->page_set == CTK_PAGE_SET_ALL || | |||
| 731 | (export->page_set == CTK_PAGE_SET_EVEN && export->sheet % 2 == 0) || | |||
| 732 | (export->page_set == CTK_PAGE_SET_ODD && export->sheet % 2 == 1) ) { | |||
| 733 | ev_file_exporter_end_page (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ()))))))); | |||
| 734 | } | |||
| 735 | ev_document_doc_mutex_unlock (); | |||
| 736 | export->sheet = 1 + (export->page_count - 1) / export->pages_per_sheet; | |||
| 737 | } | |||
| 738 | ||||
| 739 | if (export->uncollated == export->uncollated_copies) | |||
| 740 | return FALSE(0); | |||
| 741 | ||||
| 742 | export->range = export->inc < 0 ? export->n_ranges - 1 : 0; | |||
| 743 | } | |||
| 744 | find_range (export); | |||
| 745 | export->page = export->start; | |||
| 746 | } | |||
| 747 | ||||
| 748 | /* in/decrement the page number until we reach the first page on the next EVEN or ODD sheet | |||
| 749 | * if we're not collating, we have to make sure that this is done only once! */ | |||
| 750 | } while ( export->collate == 1 && | |||
| 751 | ((export->page_set == CTK_PAGE_SET_EVEN && export->sheet % 2 == 1) || | |||
| 752 | (export->page_set == CTK_PAGE_SET_ODD && export->sheet % 2 == 0))); | |||
| 753 | ||||
| 754 | return TRUE(!(0)); | |||
| 755 | } | |||
| 756 | ||||
| 757 | static void | |||
| 758 | ev_print_operation_export_clear_temp_file (EvPrintOperationExport *export) | |||
| 759 | { | |||
| 760 | if (!export->temp_file) | |||
| 761 | return; | |||
| 762 | ||||
| 763 | g_unlink (export->temp_file); | |||
| 764 | g_free (export->temp_file); | |||
| 765 | export->temp_file = NULL((void*)0); | |||
| 766 | } | |||
| 767 | ||||
| 768 | static void | |||
| 769 | ev_print_operation_export_run_next (EvPrintOperationExport *export) | |||
| 770 | { | |||
| 771 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 772 | EvPrintOperation *next; | |||
| 773 | EvDocument *document; | |||
| 774 | ||||
| 775 | /* First pop the current job */ | |||
| 776 | document = op->document; | |||
| 777 | ev_print_queue_pop (document); | |||
| 778 | ||||
| 779 | next = ev_print_queue_peek (document); | |||
| 780 | if (next) | |||
| 781 | ev_print_operation_export_begin (EV_PRINT_OPERATION_EXPORT (next)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((next)), ((ev_print_operation_export_get_type ()))))))); | |||
| 782 | } | |||
| 783 | ||||
| 784 | static void | |||
| 785 | ctk_print_job_finished (CtkPrintJob *print_job, | |||
| 786 | EvPrintOperationExport *export, | |||
| 787 | GError *error) | |||
| 788 | { | |||
| 789 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 790 | ||||
| 791 | if (error) { | |||
| 792 | g_set_error_literal (&export->error, | |||
| 793 | CTK_PRINT_ERRORctk_print_error_quark (), | |||
| 794 | CTK_PRINT_ERROR_GENERAL, | |||
| 795 | error->message); | |||
| 796 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_ERROR); | |||
| 797 | } else { | |||
| 798 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_APPLY); | |||
| 799 | } | |||
| 800 | ||||
| 801 | ev_print_operation_export_clear_temp_file (export); | |||
| 802 | g_object_unref (print_job); | |||
| 803 | ||||
| 804 | ev_print_operation_export_run_next (export); | |||
| 805 | } | |||
| 806 | ||||
| 807 | static void | |||
| 808 | export_print_done (EvPrintOperationExport *export) | |||
| 809 | { | |||
| 810 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 811 | CtkPrintSettings *settings; | |||
| 812 | EvFileExporterCapabilities capabilities; | |||
| 813 | GError *error = NULL((void*)0); | |||
| 814 | ||||
| 815 | g_assert (export->temp_file != NULL)do { if (export->temp_file != ((void*)0)) ; else g_assertion_message_expr ("LectorView", "ev-print-operation.c", 815, ((const char*) ( __func__)), "export->temp_file != NULL"); } while (0); | |||
| 816 | ||||
| 817 | /* Some printers take into account some print settings, | |||
| 818 | * and others don't. However we have exported the document | |||
| 819 | * to a ps or pdf file according to such print settings. So, | |||
| 820 | * we want to send the exported file to printer with those | |||
| 821 | * settings set to default values. | |||
| 822 | */ | |||
| 823 | settings = ctk_print_settings_copy (export->print_settings); | |||
| 824 | capabilities = ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ()))))))); | |||
| 825 | ||||
| 826 | ctk_print_settings_set_page_ranges (settings, NULL((void*)0), 0); | |||
| 827 | ctk_print_settings_set_print_pages (settings, CTK_PRINT_PAGES_ALL); | |||
| 828 | if (capabilities & EV_FILE_EXPORTER_CAN_COPIES) | |||
| 829 | ctk_print_settings_set_n_copies (settings, 1); | |||
| 830 | if (capabilities & EV_FILE_EXPORTER_CAN_PAGE_SET) | |||
| 831 | ctk_print_settings_set_page_set (settings, CTK_PAGE_SET_ALL); | |||
| 832 | if (capabilities & EV_FILE_EXPORTER_CAN_SCALE) | |||
| 833 | ctk_print_settings_set_scale (settings, 1.0); | |||
| 834 | if (capabilities & EV_FILE_EXPORTER_CAN_COLLATE) | |||
| 835 | ctk_print_settings_set_collate (settings, FALSE(0)); | |||
| 836 | if (capabilities & EV_FILE_EXPORTER_CAN_REVERSE) | |||
| 837 | ctk_print_settings_set_reverse (settings, FALSE(0)); | |||
| 838 | if (capabilities & EV_FILE_EXPORTER_CAN_NUMBER_UP) { | |||
| 839 | ctk_print_settings_set_number_up (settings, 1); | |||
| 840 | ctk_print_settings_set_int (settings, "cups-"CTK_PRINT_SETTINGS_NUMBER_UP"number-up", 1); | |||
| 841 | } | |||
| 842 | ||||
| 843 | if (export->print_preview) { | |||
| 844 | GKeyFile *key_file; | |||
| 845 | gchar *data = NULL((void*)0); | |||
| 846 | gsize data_len; | |||
| 847 | gchar *print_settings_file = NULL((void*)0); | |||
| 848 | ||||
| 849 | key_file = g_key_file_new (); | |||
| 850 | ||||
| 851 | ctk_print_settings_to_key_file (settings, key_file, NULL((void*)0)); | |||
| 852 | ctk_page_setup_to_key_file (export->page_setup, key_file, NULL((void*)0)); | |||
| 853 | g_key_file_set_string (key_file, "Print Job", "title", export->job_name); | |||
| 854 | ||||
| 855 | data = g_key_file_to_data (key_file, &data_len, &error); | |||
| 856 | if (data) { | |||
| 857 | gint fd; | |||
| 858 | ||||
| 859 | fd = g_file_open_tmp ("print-settingsXXXXXX", &print_settings_file, &error); | |||
| 860 | if (!error) | |||
| 861 | g_file_set_contents (print_settings_file, data, data_len, &error); | |||
| 862 | close (fd); | |||
| 863 | ||||
| 864 | g_free (data); | |||
| 865 | } | |||
| 866 | ||||
| 867 | g_key_file_free (key_file); | |||
| 868 | ||||
| 869 | if (!error) { | |||
| 870 | GAppInfo *app; | |||
| 871 | CdkAppLaunchContext *ctx; | |||
| 872 | gchar *cmd; | |||
| 873 | gchar *quoted_filename; | |||
| 874 | gchar *quoted_settings_filename; | |||
| 875 | ||||
| 876 | quoted_filename = g_shell_quote (export->temp_file); | |||
| 877 | quoted_settings_filename = g_shell_quote (print_settings_file); | |||
| 878 | cmd = g_strdup_printf ("lector-previewer --unlink-tempfile --print-settings %s %s", | |||
| 879 | quoted_settings_filename, quoted_filename); | |||
| 880 | ||||
| 881 | g_free (quoted_filename); | |||
| 882 | g_free (quoted_settings_filename); | |||
| 883 | ||||
| 884 | app = g_app_info_create_from_commandline (cmd, NULL((void*)0), 0, &error); | |||
| 885 | ||||
| 886 | if (app != NULL((void*)0)) { | |||
| 887 | ctx = cdk_display_get_app_launch_context (ctk_widget_get_display (CTK_WIDGET (export->parent_window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((export->parent_window)), ((ctk_widget_get_type ())))) )))); | |||
| 888 | cdk_app_launch_context_set_screen (ctx, ctk_window_get_screen (export->parent_window)); | |||
| 889 | ||||
| 890 | g_app_info_launch (app, NULL((void*)0), G_APP_LAUNCH_CONTEXT (ctx)((((GAppLaunchContext*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((ctx)), ((g_app_launch_context_get_type ()) ))))), &error); | |||
| 891 | ||||
| 892 | g_object_unref (app); | |||
| 893 | g_object_unref (ctx); | |||
| 894 | } | |||
| 895 | ||||
| 896 | g_free (cmd); | |||
| 897 | } | |||
| 898 | ||||
| 899 | if (error) { | |||
| 900 | if (print_settings_file) | |||
| 901 | g_unlink (print_settings_file); | |||
| 902 | g_free (print_settings_file); | |||
| 903 | } else { | |||
| 904 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_APPLY); | |||
| 905 | /* temp_file will be deleted by the previewer */ | |||
| 906 | ||||
| 907 | ev_print_operation_export_run_next (export); | |||
| 908 | } | |||
| 909 | } else { | |||
| 910 | CtkPrintJob *job; | |||
| 911 | ||||
| 912 | job = ctk_print_job_new (export->job_name, | |||
| 913 | export->printer, | |||
| 914 | settings, | |||
| 915 | export->page_setup); | |||
| 916 | ctk_print_job_set_source_file (job, export->temp_file, &error); | |||
| 917 | if (!error){ | |||
| 918 | ctk_print_job_send (job, | |||
| 919 | (CtkPrintJobCompleteFunc)ctk_print_job_finished, | |||
| 920 | g_object_ref (export)((__typeof__ (export)) (g_object_ref) (export)), | |||
| 921 | (GDestroyNotify)g_object_unref); | |||
| 922 | } | |||
| 923 | } | |||
| 924 | g_object_unref (settings); | |||
| 925 | ||||
| 926 | if (error) { | |||
| 927 | g_set_error_literal (&export->error, | |||
| 928 | CTK_PRINT_ERRORctk_print_error_quark (), | |||
| 929 | CTK_PRINT_ERROR_GENERAL, | |||
| 930 | error->message); | |||
| 931 | g_error_free (error); | |||
| 932 | ev_print_operation_export_clear_temp_file (export); | |||
| 933 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_ERROR); | |||
| 934 | ||||
| 935 | ev_print_operation_export_run_next (export); | |||
| 936 | } | |||
| 937 | } | |||
| 938 | ||||
| 939 | static void | |||
| 940 | export_print_page_idle_finished (EvPrintOperationExport *export) | |||
| 941 | { | |||
| 942 | export->idle_id = 0; | |||
| 943 | } | |||
| 944 | ||||
| 945 | static void | |||
| 946 | export_job_finished (EvJobExport *job, | |||
| 947 | EvPrintOperationExport *export) | |||
| 948 | { | |||
| 949 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 950 | ||||
| 951 | if (export->pages_per_sheet == 1 || | |||
| 952 | ( export->page_count % export->pages_per_sheet == 0 && | |||
| 953 | ( export->page_set == CTK_PAGE_SET_ALL || | |||
| 954 | ( export->page_set == CTK_PAGE_SET_EVEN && export->sheet % 2 == 0 ) || | |||
| 955 | ( export->page_set == CTK_PAGE_SET_ODD && export->sheet % 2 == 1 ) ) ) ) { | |||
| 956 | ||||
| 957 | ev_document_doc_mutex_lock (); | |||
| 958 | ev_file_exporter_end_page (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ()))))))); | |||
| 959 | ev_document_doc_mutex_unlock (); | |||
| 960 | } | |||
| 961 | ||||
| 962 | /* Reschedule */ | |||
| 963 | export->idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200, | |||
| 964 | (GSourceFunc)export_print_page, | |||
| 965 | export, | |||
| 966 | (GDestroyNotify)export_print_page_idle_finished); | |||
| 967 | } | |||
| 968 | ||||
| 969 | static void | |||
| 970 | export_job_cancelled (EvJobExport *job, | |||
| 971 | EvPrintOperationExport *export) | |||
| 972 | { | |||
| 973 | export_cancel (export); | |||
| 974 | } | |||
| 975 | ||||
| 976 | static void | |||
| 977 | export_cancel (EvPrintOperationExport *export) | |||
| 978 | { | |||
| 979 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 980 | ||||
| 981 | if (export->idle_id > 0) | |||
| 982 | g_source_remove (export->idle_id); | |||
| 983 | export->idle_id = 0; | |||
| 984 | ||||
| 985 | if (export->job_export) { | |||
| 986 | g_signal_handlers_disconnect_by_func (export->job_export,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_finished), (export)) | |||
| 987 | export_job_finished,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_finished), (export)) | |||
| 988 | export)g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_finished), (export)); | |||
| 989 | g_signal_handlers_disconnect_by_func (export->job_export,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_cancelled), (export)) | |||
| 990 | export_job_cancelled,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_cancelled), (export)) | |||
| 991 | export)g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_cancelled), (export)); | |||
| 992 | g_object_unref (export->job_export); | |||
| 993 | export->job_export = NULL((void*)0); | |||
| 994 | } | |||
| 995 | ||||
| 996 | if (export->fd != -1) { | |||
| 997 | close (export->fd); | |||
| 998 | export->fd = -1; | |||
| 999 | } | |||
| 1000 | ||||
| 1001 | ev_print_operation_export_clear_temp_file (export); | |||
| 1002 | ||||
| 1003 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_CANCEL); | |||
| 1004 | ||||
| 1005 | ev_print_operation_export_run_next (export); | |||
| 1006 | } | |||
| 1007 | ||||
| 1008 | static void | |||
| 1009 | update_progress (EvPrintOperationExport *export) | |||
| 1010 | { | |||
| 1011 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 1012 | ||||
| 1013 | ev_print_operation_update_status (op, export->total, | |||
| 1014 | export->n_pages_to_print, | |||
| 1015 | export->total / (gdouble)export->n_pages_to_print); | |||
| 1016 | } | |||
| 1017 | ||||
| 1018 | static gboolean | |||
| 1019 | export_print_page (EvPrintOperationExport *export) | |||
| 1020 | { | |||
| 1021 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 1022 | ||||
| 1023 | if (!export->temp_file) | |||
| 1024 | return FALSE(0); /* cancelled */ | |||
| 1025 | ||||
| 1026 | export->total++; | |||
| 1027 | export->collated++; | |||
| 1028 | ||||
| 1029 | /* note: when collating, page_count is increased in export_print_inc_page */ | |||
| 1030 | if (!export->collate) { | |||
| 1031 | export->page_count++; | |||
| 1032 | export->sheet = 1 + (export->page_count - 1) / export->pages_per_sheet; | |||
| 1033 | } | |||
| 1034 | ||||
| 1035 | if (export->collated == export->collated_copies) { | |||
| 1036 | export->collated = 0; | |||
| 1037 | if (!export_print_inc_page (export)) { | |||
| 1038 | ev_document_doc_mutex_lock (); | |||
| 1039 | ev_file_exporter_end (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ()))))))); | |||
| 1040 | ev_document_doc_mutex_unlock (); | |||
| 1041 | ||||
| 1042 | close (export->fd); | |||
| 1043 | export->fd = -1; | |||
| 1044 | update_progress (export); | |||
| 1045 | export_print_done (export); | |||
| 1046 | ||||
| 1047 | return FALSE(0); | |||
| 1048 | } | |||
| 1049 | } | |||
| 1050 | ||||
| 1051 | /* we're not collating and we've reached a sheet from the wrong sheet set */ | |||
| 1052 | if (!export->collate && | |||
| 1053 | ((export->page_set == CTK_PAGE_SET_EVEN && export->sheet % 2 != 0) || | |||
| 1054 | (export->page_set == CTK_PAGE_SET_ODD && export->sheet % 2 != 1))) { | |||
| 1055 | ||||
| 1056 | do { | |||
| 1057 | export->page_count++; | |||
| 1058 | export->collated++; | |||
| 1059 | export->sheet = 1 + (export->page_count - 1) / export->pages_per_sheet; | |||
| 1060 | ||||
| 1061 | if (export->collated == export->collated_copies) { | |||
| 1062 | export->collated = 0; | |||
| 1063 | ||||
| 1064 | if (!export_print_inc_page (export)) { | |||
| 1065 | ev_document_doc_mutex_lock (); | |||
| 1066 | ev_file_exporter_end (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ()))))))); | |||
| 1067 | ev_document_doc_mutex_unlock (); | |||
| 1068 | ||||
| 1069 | close (export->fd); | |||
| 1070 | export->fd = -1; | |||
| 1071 | ||||
| 1072 | update_progress (export); | |||
| 1073 | ||||
| 1074 | export_print_done (export); | |||
| 1075 | return FALSE(0); | |||
| 1076 | } | |||
| 1077 | } | |||
| 1078 | ||||
| 1079 | } while ((export->page_set == CTK_PAGE_SET_EVEN && export->sheet % 2 != 0) || | |||
| 1080 | (export->page_set == CTK_PAGE_SET_ODD && export->sheet % 2 != 1)); | |||
| 1081 | ||||
| 1082 | } | |||
| 1083 | ||||
| 1084 | if (export->pages_per_sheet == 1 || | |||
| 1085 | (export->page_count % export->pages_per_sheet == 1 && | |||
| 1086 | (export->page_set == CTK_PAGE_SET_ALL || | |||
| 1087 | (export->page_set == CTK_PAGE_SET_EVEN && export->sheet % 2 == 0) || | |||
| 1088 | (export->page_set == CTK_PAGE_SET_ODD && export->sheet % 2 == 1)))) { | |||
| 1089 | ev_document_doc_mutex_lock (); | |||
| 1090 | ev_file_exporter_begin_page (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ()))))))); | |||
| 1091 | ev_document_doc_mutex_unlock (); | |||
| 1092 | } | |||
| 1093 | ||||
| 1094 | if (!export->job_export) { | |||
| 1095 | export->job_export = ev_job_export_new (op->document); | |||
| 1096 | g_signal_connect (export->job_export, "finished",g_signal_connect_data ((export->job_export), ("finished"), (((GCallback) (export_job_finished))), ((gpointer)export), ( (void*)0), (GConnectFlags) 0) | |||
| 1097 | G_CALLBACK (export_job_finished),g_signal_connect_data ((export->job_export), ("finished"), (((GCallback) (export_job_finished))), ((gpointer)export), ( (void*)0), (GConnectFlags) 0) | |||
| 1098 | (gpointer)export)g_signal_connect_data ((export->job_export), ("finished"), (((GCallback) (export_job_finished))), ((gpointer)export), ( (void*)0), (GConnectFlags) 0); | |||
| 1099 | g_signal_connect (export->job_export, "cancelled",g_signal_connect_data ((export->job_export), ("cancelled") , (((GCallback) (export_job_cancelled))), ((gpointer)export), ((void*)0), (GConnectFlags) 0) | |||
| 1100 | G_CALLBACK (export_job_cancelled),g_signal_connect_data ((export->job_export), ("cancelled") , (((GCallback) (export_job_cancelled))), ((gpointer)export), ((void*)0), (GConnectFlags) 0) | |||
| 1101 | (gpointer)export)g_signal_connect_data ((export->job_export), ("cancelled") , (((GCallback) (export_job_cancelled))), ((gpointer)export), ((void*)0), (GConnectFlags) 0); | |||
| 1102 | } | |||
| 1103 | ||||
| 1104 | ev_job_export_set_page (EV_JOB_EXPORT (export->job_export)((((EvJobExport*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((export->job_export)), ((ev_job_export_get_type()))))) ), export->page); | |||
| 1105 | ev_job_scheduler_push_job (export->job_export, EV_JOB_PRIORITY_NONE); | |||
| 1106 | ||||
| 1107 | update_progress (export); | |||
| 1108 | ||||
| 1109 | return FALSE(0); | |||
| 1110 | } | |||
| 1111 | ||||
| 1112 | static void | |||
| 1113 | ev_print_operation_export_begin (EvPrintOperationExport *export) | |||
| 1114 | { | |||
| 1115 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 1116 | ||||
| 1117 | if (!export->temp_file) | |||
| 1118 | return; /* cancelled */ | |||
| 1119 | ||||
| 1120 | ev_document_doc_mutex_lock (); | |||
| 1121 | ev_file_exporter_begin (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ())))))), &export->fc); | |||
| 1122 | ev_document_doc_mutex_unlock (); | |||
| 1123 | ||||
| 1124 | export->idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200, | |||
| 1125 | (GSourceFunc)export_print_page, | |||
| 1126 | export, | |||
| 1127 | (GDestroyNotify)export_print_page_idle_finished); | |||
| 1128 | } | |||
| 1129 | ||||
| 1130 | static void | |||
| 1131 | ev_print_operation_export_print_dialog_response_cb (CtkDialog *dialog, | |||
| 1132 | gint response, | |||
| 1133 | EvPrintOperationExport *export) | |||
| 1134 | { | |||
| 1135 | CtkPrintPages print_pages; | |||
| 1136 | CtkPrintSettings *print_settings; | |||
| 1137 | CtkPageSetup *page_setup; | |||
| 1138 | CtkPrinter *printer; | |||
| 1139 | gdouble scale; | |||
| 1140 | gdouble width; | |||
| 1141 | gdouble height; | |||
| 1142 | gint first_page; | |||
| 1143 | gint last_page; | |||
| 1144 | const gchar *file_format; | |||
| 1145 | gchar *filename; | |||
| 1146 | GError *error = NULL((void*)0); | |||
| 1147 | EvPrintOperation *op = EV_PRINT_OPERATION (export)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((export)), ((ev_print_operation_get_type())) )))); | |||
| 1148 | ||||
| 1149 | if (response != CTK_RESPONSE_OK && | |||
| ||||
| 1150 | response != CTK_RESPONSE_APPLY) { | |||
| 1151 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
| 1152 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_CANCEL); | |||
| 1153 | ||||
| 1154 | return; | |||
| 1155 | } | |||
| 1156 | ||||
| 1157 | export->print_preview = (response == CTK_RESPONSE_APPLY); | |||
| 1158 | ||||
| 1159 | printer = ctk_print_unix_dialog_get_selected_printer (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ()))))))); | |||
| 1160 | ev_print_operation_export_set_printer (export, printer); | |||
| 1161 | ||||
| 1162 | print_settings = ctk_print_unix_dialog_get_settings (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ()))))))); | |||
| 1163 | ev_print_operation_export_set_print_settings (op, print_settings); | |||
| 1164 | ||||
| 1165 | page_setup = ctk_print_unix_dialog_get_page_setup (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ()))))))); | |||
| 1166 | ev_print_operation_export_set_default_page_setup (op, page_setup); | |||
| 1167 | ||||
| 1168 | if (!ctk_printer_accepts_ps (export->printer)) { | |||
| 1169 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
| 1170 | ||||
| 1171 | g_set_error_literal (&export->error, | |||
| 1172 | CTK_PRINT_ERRORctk_print_error_quark (), | |||
| 1173 | CTK_PRINT_ERROR_GENERAL, | |||
| 1174 | _("Printing is not supported on this printer.")gettext ("Printing is not supported on this printer.")); | |||
| 1175 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_ERROR); | |||
| 1176 | ||||
| 1177 | return; | |||
| 1178 | } | |||
| 1179 | ||||
| 1180 | file_format = ctk_print_settings_get (print_settings, CTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT"output-file-format"); | |||
| 1181 | ||||
| 1182 | filename = g_strdup_printf ("lector_print.%s.XXXXXX", file_format != NULL((void*)0) ? file_format : ""); | |||
| 1183 | export->fd = g_file_open_tmp (filename, &export->temp_file, &error); | |||
| 1184 | g_free (filename); | |||
| 1185 | if (export->fd <= -1) { | |||
| 1186 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
| 1187 | ||||
| 1188 | g_set_error_literal (&export->error, | |||
| 1189 | CTK_PRINT_ERRORctk_print_error_quark (), | |||
| 1190 | CTK_PRINT_ERROR_GENERAL, | |||
| 1191 | error->message); | |||
| 1192 | g_error_free (error); | |||
| 1193 | g_signal_emit (op, signals[DONE], 0, CTK_PRINT_OPERATION_RESULT_ERROR); | |||
| 1194 | ||||
| 1195 | return; | |||
| 1196 | } | |||
| 1197 | ||||
| 1198 | export->current_page = ctk_print_unix_dialog_get_current_page (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ()))))))); | |||
| 1199 | export->page_set = ctk_print_settings_get_page_set (print_settings); | |||
| 1200 | print_pages = ctk_print_settings_get_print_pages (print_settings); | |||
| 1201 | ||||
| 1202 | switch (print_pages) { | |||
| 1203 | case CTK_PRINT_PAGES_CURRENT: | |||
| 1204 | export->ranges = &export->one_range; | |||
| 1205 | ||||
| 1206 | export->ranges[0].start = export->current_page; | |||
| 1207 | export->ranges[0].end = export->current_page; | |||
| 1208 | export->n_ranges = 1; | |||
| 1209 | ||||
| 1210 | break; | |||
| 1211 | case CTK_PRINT_PAGES_RANGES: { | |||
| 1212 | gint i; | |||
| 1213 | ||||
| 1214 | export->ranges = ctk_print_settings_get_page_ranges (print_settings, &export->n_ranges); | |||
| 1215 | for (i = 0; i < export->n_ranges; i++) | |||
| 1216 | if (export->ranges[i].end == -1 || export->ranges[i].end >= export->n_pages) | |||
| 1217 | export->ranges[i].end = export->n_pages - 1; | |||
| 1218 | } | |||
| 1219 | break; | |||
| 1220 | default: | |||
| 1221 | g_warning ("Unsupported print pages setting\n"); | |||
| 1222 | case CTK_PRINT_PAGES_ALL: | |||
| 1223 | export->ranges = &export->one_range; | |||
| 1224 | ||||
| 1225 | export->ranges[0].start = 0; | |||
| 1226 | export->ranges[0].end = export->n_pages - 1; | |||
| 1227 | export->n_ranges = 1; | |||
| 1228 | ||||
| 1229 | break; | |||
| 1230 | } | |||
| 1231 | ||||
| 1232 | if (export->n_ranges
| |||
| 1233 | CtkWidget *message_dialog; | |||
| 1234 | ||||
| 1235 | message_dialog = ctk_message_dialog_new (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), | |||
| 1236 | CTK_DIALOG_MODAL, | |||
| 1237 | CTK_MESSAGE_WARNING, | |||
| 1238 | CTK_BUTTONS_CLOSE, | |||
| 1239 | "%s", _("Invalid page selection")gettext ("Invalid page selection")); | |||
| 1240 | ctk_window_set_title (CTK_WINDOW (message_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((message_dialog)), ((ctk_window_get_type ())))))), _("Warning")gettext ("Warning")); | |||
| 1241 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (message_dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((message_dialog)), ((ctk_message_dialog_get_type ())))))), | |||
| 1242 | "%s", _("Your print range selection does not include any pages")gettext ("Your print range selection does not include any pages" )); | |||
| 1243 | g_signal_connect (message_dialog, "response",g_signal_connect_data ((message_dialog), ("response"), (((GCallback ) (ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
| 1244 | G_CALLBACK (ctk_widget_destroy),g_signal_connect_data ((message_dialog), ("response"), (((GCallback ) (ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
| 1245 | NULL)g_signal_connect_data ((message_dialog), ("response"), (((GCallback ) (ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | |||
| 1246 | ctk_widget_show (message_dialog); | |||
| 1247 | ||||
| 1248 | return; | |||
| 1249 | } else ev_print_operation_update_status (op, -1, -1, 0.0); | |||
| 1250 | ||||
| 1251 | width = ctk_page_setup_get_paper_width (page_setup, CTK_UNIT_POINTS); | |||
| 1252 | height = ctk_page_setup_get_paper_height (page_setup, CTK_UNIT_POINTS); | |||
| 1253 | scale = ctk_print_settings_get_scale (print_settings) * 0.01; | |||
| 1254 | if (scale != 1.0) { | |||
| 1255 | width *= scale; | |||
| 1256 | height *= scale; | |||
| 1257 | } | |||
| 1258 | ||||
| 1259 | export->pages_per_sheet = MAX (1, ctk_print_settings_get_number_up (print_settings))(((1) > (ctk_print_settings_get_number_up (print_settings) )) ? (1) : (ctk_print_settings_get_number_up (print_settings) )); | |||
| 1260 | ||||
| 1261 | export->copies = ctk_print_settings_get_n_copies (print_settings); | |||
| 1262 | export->collate = ctk_print_settings_get_collate (print_settings); | |||
| 1263 | export->reverse = ctk_print_settings_get_reverse (print_settings); | |||
| 1264 | ||||
| 1265 | if (export->collate) { | |||
| 1266 | export->uncollated_copies = export->copies; | |||
| 1267 | export->collated_copies = 1; | |||
| 1268 | } else { | |||
| 1269 | export->uncollated_copies = 1; | |||
| 1270 | export->collated_copies = export->copies; | |||
| 1271 | } | |||
| 1272 | ||||
| 1273 | if (export->reverse) { | |||
| 1274 | export->range = export->n_ranges - 1; | |||
| 1275 | export->inc = -1; | |||
| 1276 | } else { | |||
| 1277 | export->range = 0; | |||
| 1278 | export->inc = 1; | |||
| 1279 | } | |||
| 1280 | find_range (export); | |||
| 1281 | ||||
| 1282 | export->page = export->start - export->inc; | |||
| 1283 | export->collated = export->collated_copies - 1; | |||
| 1284 | ||||
| 1285 | get_first_and_last_page (export, &first_page, &last_page); | |||
| 1286 | ||||
| 1287 | export->fc.format = file_format && g_ascii_strcasecmp (file_format, "pdf") == 0 ? | |||
| 1288 | EV_FILE_FORMAT_PDF : EV_FILE_FORMAT_PS; | |||
| 1289 | export->fc.filename = export->temp_file; | |||
| 1290 | export->fc.first_page = MIN (first_page, last_page)(((first_page) < (last_page)) ? (first_page) : (last_page) ); | |||
| 1291 | export->fc.last_page = MAX (first_page, last_page)(((first_page) > (last_page)) ? (first_page) : (last_page) ); | |||
| 1292 | export->fc.paper_width = width; | |||
| 1293 | export->fc.paper_height = height; | |||
| 1294 | export->fc.duplex = FALSE(0); | |||
| 1295 | export->fc.pages_per_sheet = export->pages_per_sheet; | |||
| 1296 | ||||
| 1297 | if (ev_print_queue_is_empty (op->document)) | |||
| 1298 | ev_print_operation_export_begin (export); | |||
| 1299 | ||||
| 1300 | ev_print_queue_push (op); | |||
| 1301 | ||||
| 1302 | g_signal_emit (op, signals[BEGIN_PRINT], 0); | |||
| 1303 | ||||
| 1304 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
| 1305 | } | |||
| 1306 | ||||
| 1307 | static void | |||
| 1308 | ev_print_operation_export_run (EvPrintOperation *op, | |||
| 1309 | CtkWindow *parent) | |||
| 1310 | { | |||
| 1311 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 1312 | CtkWidget *dialog; | |||
| 1313 | CtkPrintCapabilities capabilities; | |||
| 1314 | ||||
| 1315 | ev_print_queue_init (); | |||
| 1316 | ||||
| 1317 | export->parent_window = parent; | |||
| 1318 | export->error = NULL((void*)0); | |||
| 1319 | ||||
| 1320 | /* translators: Title of the print dialog */ | |||
| 1321 | dialog = ctk_print_unix_dialog_new (_("Print")gettext ("Print"), parent); | |||
| 1322 | ctk_window_set_modal (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); | |||
| 1323 | ||||
| 1324 | capabilities = CTK_PRINT_CAPABILITY_PREVIEW | | |||
| 1325 | ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (op->document)((((EvFileExporter*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->document)), ((ev_file_exporter_get_type ()))))))); | |||
| 1326 | ctk_print_unix_dialog_set_manual_capabilities (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ())))))), | |||
| 1327 | capabilities); | |||
| 1328 | ||||
| 1329 | ctk_print_unix_dialog_set_embed_page_setup (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ())))))), | |||
| 1330 | export->embed_page_setup); | |||
| 1331 | ||||
| 1332 | ctk_print_unix_dialog_set_current_page (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ())))))), | |||
| 1333 | export->current_page); | |||
| 1334 | ||||
| 1335 | ctk_print_unix_dialog_set_settings (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ())))))), | |||
| 1336 | export->print_settings); | |||
| 1337 | ||||
| 1338 | if (export->page_setup) | |||
| 1339 | ctk_print_unix_dialog_set_page_setup (CTK_PRINT_UNIX_DIALOG (dialog)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((dialog)), ((ctk_print_unix_dialog_get_type ())))))), | |||
| 1340 | export->page_setup); | |||
| 1341 | ||||
| 1342 | g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) ( ev_print_operation_export_print_dialog_response_cb))), (export ), ((void*)0), (GConnectFlags) 0) | |||
| 1343 | G_CALLBACK (ev_print_operation_export_print_dialog_response_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) ( ev_print_operation_export_print_dialog_response_cb))), (export ), ((void*)0), (GConnectFlags) 0) | |||
| 1344 | export)g_signal_connect_data ((dialog), ("response"), (((GCallback) ( ev_print_operation_export_print_dialog_response_cb))), (export ), ((void*)0), (GConnectFlags) 0); | |||
| 1345 | ||||
| 1346 | ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ()))))))); | |||
| 1347 | } | |||
| 1348 | ||||
| 1349 | static void | |||
| 1350 | ev_print_operation_export_cancel (EvPrintOperation *op) | |||
| 1351 | { | |||
| 1352 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 1353 | ||||
| 1354 | if (export->job_export && | |||
| 1355 | !ev_job_is_finished (export->job_export)) { | |||
| 1356 | ev_job_cancel (export->job_export); | |||
| 1357 | } else { | |||
| 1358 | export_cancel (export); | |||
| 1359 | } | |||
| 1360 | } | |||
| 1361 | ||||
| 1362 | static void | |||
| 1363 | ev_print_operation_export_get_error (EvPrintOperation *op, | |||
| 1364 | GError **error) | |||
| 1365 | { | |||
| 1366 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 1367 | ||||
| 1368 | g_propagate_error (error, export->error); | |||
| 1369 | export->error = NULL((void*)0); | |||
| 1370 | } | |||
| 1371 | ||||
| 1372 | static void | |||
| 1373 | ev_print_operation_export_set_embed_page_setup (EvPrintOperation *op, | |||
| 1374 | gboolean embed) | |||
| 1375 | { | |||
| 1376 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 1377 | ||||
| 1378 | export->embed_page_setup = embed; | |||
| 1379 | } | |||
| 1380 | ||||
| 1381 | static gboolean | |||
| 1382 | ev_print_operation_export_get_embed_page_setup (EvPrintOperation *op) | |||
| 1383 | { | |||
| 1384 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_export_get_type ())))))); | |||
| 1385 | ||||
| 1386 | return export->embed_page_setup; | |||
| 1387 | } | |||
| 1388 | ||||
| 1389 | static void | |||
| 1390 | ev_print_operation_export_finalize (GObject *object) | |||
| 1391 | { | |||
| 1392 | EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (object)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ev_print_operation_export_get_type ())))))); | |||
| 1393 | ||||
| 1394 | if (export->idle_id > 0) { | |||
| 1395 | g_source_remove (export->idle_id); | |||
| 1396 | export->idle_id = 0; | |||
| 1397 | } | |||
| 1398 | ||||
| 1399 | if (export->fd != -1) { | |||
| 1400 | close (export->fd); | |||
| 1401 | export->fd = -1; | |||
| 1402 | } | |||
| 1403 | ||||
| 1404 | if (export->ranges) { | |||
| 1405 | if (export->ranges != &export->one_range) | |||
| 1406 | g_free (export->ranges); | |||
| 1407 | export->ranges = NULL((void*)0); | |||
| 1408 | export->n_ranges = 0; | |||
| 1409 | } | |||
| 1410 | ||||
| 1411 | if (export->temp_file) { | |||
| 1412 | g_free (export->temp_file); | |||
| 1413 | export->temp_file = NULL((void*)0); | |||
| 1414 | } | |||
| 1415 | ||||
| 1416 | if (export->job_name) { | |||
| 1417 | g_free (export->job_name); | |||
| 1418 | export->job_name = NULL((void*)0); | |||
| 1419 | } | |||
| 1420 | ||||
| 1421 | if (export->job_export) { | |||
| 1422 | if (!ev_job_is_finished (export->job_export)) | |||
| 1423 | ev_job_cancel (export->job_export); | |||
| 1424 | g_signal_handlers_disconnect_by_func (export->job_export,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_finished), (export)) | |||
| 1425 | export_job_finished,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_finished), (export)) | |||
| 1426 | export)g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_finished), (export)); | |||
| 1427 | g_signal_handlers_disconnect_by_func (export->job_export,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_cancelled), (export)) | |||
| 1428 | export_job_cancelled,g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_cancelled), (export)) | |||
| 1429 | export)g_signal_handlers_disconnect_matched ((export->job_export) , (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (export_job_cancelled), (export)); | |||
| 1430 | g_object_unref (export->job_export); | |||
| 1431 | export->job_export = NULL((void*)0); | |||
| 1432 | } | |||
| 1433 | ||||
| 1434 | if (export->error) { | |||
| 1435 | g_error_free (export->error); | |||
| 1436 | export->error = NULL((void*)0); | |||
| 1437 | } | |||
| 1438 | ||||
| 1439 | if (export->print_settings) { | |||
| 1440 | g_object_unref (export->print_settings); | |||
| 1441 | export->print_settings = NULL((void*)0); | |||
| 1442 | } | |||
| 1443 | ||||
| 1444 | if (export->page_setup) { | |||
| 1445 | g_object_unref (export->page_setup); | |||
| 1446 | export->page_setup = NULL((void*)0); | |||
| 1447 | } | |||
| 1448 | ||||
| 1449 | if (export->printer) { | |||
| 1450 | g_object_unref (export->printer); | |||
| 1451 | export->printer = NULL((void*)0); | |||
| 1452 | } | |||
| 1453 | ||||
| 1454 | (* G_OBJECT_CLASS (ev_print_operation_export_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ev_print_operation_export_parent_class)), (((GType) ((20 ) << (2))))))))->finalize) (object); | |||
| 1455 | } | |||
| 1456 | ||||
| 1457 | static void | |||
| 1458 | ev_print_operation_export_init (EvPrintOperationExport *export) | |||
| 1459 | { | |||
| 1460 | /* sheets are counted from 1 to be physical */ | |||
| 1461 | export->sheet = 1; | |||
| 1462 | } | |||
| 1463 | ||||
| 1464 | static GObject * | |||
| 1465 | ev_print_operation_export_constructor (GType type, | |||
| 1466 | guint n_construct_properties, | |||
| 1467 | GObjectConstructParam *construct_params) | |||
| 1468 | { | |||
| 1469 | GObject *object; | |||
| 1470 | EvPrintOperationExport *export; | |||
| 1471 | EvPrintOperation *op; | |||
| 1472 | ||||
| 1473 | object = G_OBJECT_CLASS (ev_print_operation_export_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ev_print_operation_export_parent_class)), (((GType) ((20 ) << (2))))))))->constructor (type, | |||
| 1474 | n_construct_properties, | |||
| 1475 | construct_params); | |||
| 1476 | export = EV_PRINT_OPERATION_EXPORT (object)((((EvPrintOperationExport*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ev_print_operation_export_get_type ())))))); | |||
| 1477 | op = EV_PRINT_OPERATION (object)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((object)), ((ev_print_operation_get_type())) )))); | |||
| 1478 | export->n_pages = ev_document_get_n_pages (op->document); | |||
| 1479 | ||||
| 1480 | return object; | |||
| 1481 | } | |||
| 1482 | ||||
| 1483 | static void | |||
| 1484 | ev_print_operation_export_class_init (EvPrintOperationExportClass *klass) | |||
| 1485 | { | |||
| 1486 | GObjectClass *g_object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); | |||
| 1487 | EvPrintOperationClass *ev_print_op_class = EV_PRINT_OPERATION_CLASS (klass)((((EvPrintOperationClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((klass)), ((ev_print_operation_get_type()))))) ); | |||
| 1488 | ||||
| 1489 | ev_print_op_class->set_current_page = ev_print_operation_export_set_current_page; | |||
| 1490 | ev_print_op_class->set_print_settings = ev_print_operation_export_set_print_settings; | |||
| 1491 | ev_print_op_class->get_print_settings = ev_print_operation_export_get_print_settings; | |||
| 1492 | ev_print_op_class->set_default_page_setup = ev_print_operation_export_set_default_page_setup; | |||
| 1493 | ev_print_op_class->get_default_page_setup = ev_print_operation_export_get_default_page_setup; | |||
| 1494 | ev_print_op_class->set_job_name = ev_print_operation_export_set_job_name; | |||
| 1495 | ev_print_op_class->get_job_name = ev_print_operation_export_get_job_name; | |||
| 1496 | ev_print_op_class->run = ev_print_operation_export_run; | |||
| 1497 | ev_print_op_class->cancel = ev_print_operation_export_cancel; | |||
| 1498 | ev_print_op_class->get_error = ev_print_operation_export_get_error; | |||
| 1499 | ev_print_op_class->set_embed_page_setup = ev_print_operation_export_set_embed_page_setup; | |||
| 1500 | ev_print_op_class->get_embed_page_setup = ev_print_operation_export_get_embed_page_setup; | |||
| 1501 | ||||
| 1502 | g_object_class->constructor = ev_print_operation_export_constructor; | |||
| 1503 | g_object_class->finalize = ev_print_operation_export_finalize; | |||
| 1504 | } | |||
| 1505 | ||||
| 1506 | #endif /* CTKUNIXPRINT_ENABLED */ | |||
| 1507 | ||||
| 1508 | /* Print to cairo interface */ | |||
| 1509 | #define EV_TYPE_PRINT_OPERATION_PRINT(ev_print_operation_print_get_type()) (ev_print_operation_print_get_type()) | |||
| 1510 | #define EV_PRINT_OPERATION_PRINT(object)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ev_print_operation_print_get_type ())))))) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PRINT_OPERATION_PRINT, EvPrintOperationPrint)(((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ev_print_operation_print_get_type ())))))) | |||
| 1511 | #define EV_PRINT_OPERATION_PRINT_CLASS(klass)((((EvPrintOperationPrintClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ev_print_operation_print_get_type ())))))) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_PRINT_OPERATION_PRINT, EvPrintOperationPrintClass)(((EvPrintOperationPrintClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ev_print_operation_print_get_type ())))))) | |||
| 1512 | #define EV_IS_PRINT_OPERATION_PRINT(object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ev_print_operation_print_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; })))) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PRINT_OPERATION_PRINT)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ev_print_operation_print_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; })))) | |||
| 1513 | ||||
| 1514 | typedef struct _EvPrintOperationPrint EvPrintOperationPrint; | |||
| 1515 | typedef struct _EvPrintOperationPrintClass EvPrintOperationPrintClass; | |||
| 1516 | ||||
| 1517 | static GType ev_print_operation_print_get_type (void) G_GNUC_CONST__attribute__ ((__const__)); | |||
| 1518 | ||||
| 1519 | typedef enum { | |||
| 1520 | EV_SCALE_NONE, | |||
| 1521 | EV_SCALE_SHRINK_TO_PRINTABLE_AREA, | |||
| 1522 | EV_SCALE_FIT_TO_PRINTABLE_AREA | |||
| 1523 | } EvPrintScale; | |||
| 1524 | ||||
| 1525 | #define EV_PRINT_SETTING_PAGE_SCALE"lector-print-setting-page-scale" "lector-print-setting-page-scale" | |||
| 1526 | #define EV_PRINT_SETTING_AUTOROTATE"lector-print-setting-page-autorotate" "lector-print-setting-page-autorotate" | |||
| 1527 | #define EV_PRINT_SETTING_PAGE_SIZE"lector-print-setting-page-size" "lector-print-setting-page-size" | |||
| 1528 | ||||
| 1529 | struct _EvPrintOperationPrint { | |||
| 1530 | EvPrintOperation parent; | |||
| 1531 | ||||
| 1532 | CtkPrintOperation *op; | |||
| 1533 | gint n_pages_to_print; | |||
| 1534 | gint total; | |||
| 1535 | EvJob *job_print; | |||
| 1536 | gchar *job_name; | |||
| 1537 | ||||
| 1538 | /* Page handling tab */ | |||
| 1539 | CtkWidget *scale_combo; | |||
| 1540 | EvPrintScale page_scale; | |||
| 1541 | CtkWidget *autorotate_button; | |||
| 1542 | gboolean autorotate; | |||
| 1543 | CtkWidget *source_button; | |||
| 1544 | gboolean use_source_size; | |||
| 1545 | }; | |||
| 1546 | ||||
| 1547 | struct _EvPrintOperationPrintClass { | |||
| 1548 | EvPrintOperationClass parent_class; | |||
| 1549 | }; | |||
| 1550 | ||||
| 1551 | G_DEFINE_TYPE (EvPrintOperationPrint, ev_print_operation_print, EV_TYPE_PRINT_OPERATION)static void ev_print_operation_print_init (EvPrintOperationPrint *self); static void ev_print_operation_print_class_init (EvPrintOperationPrintClass *klass); static GType ev_print_operation_print_get_type_once (void); static gpointer ev_print_operation_print_parent_class = ((void*)0); static gint EvPrintOperationPrint_private_offset ; static void ev_print_operation_print_class_intern_init (gpointer klass) { ev_print_operation_print_parent_class = g_type_class_peek_parent (klass); if (EvPrintOperationPrint_private_offset != 0) g_type_class_adjust_private_offset (klass, &EvPrintOperationPrint_private_offset); ev_print_operation_print_class_init ((EvPrintOperationPrintClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ev_print_operation_print_get_instance_private (EvPrintOperationPrint *self) { return (((gpointer) ((guint8 *) (self) + (glong) (EvPrintOperationPrint_private_offset)))) ; } GType ev_print_operation_print_get_type (void) { static GType 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_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ev_print_operation_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_pointer ((&static_g_define_type_id), ( gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType ev_print_operation_print_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ev_print_operation_get_type()), g_intern_static_string ("EvPrintOperationPrint" ), sizeof (EvPrintOperationPrintClass), (GClassInitFunc)(void (*)(void)) ev_print_operation_print_class_intern_init, sizeof (EvPrintOperationPrint), (GInstanceInitFunc)(void (*)(void)) ev_print_operation_print_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; } | |||
| 1552 | ||||
| 1553 | static void | |||
| 1554 | ev_print_operation_print_set_current_page (EvPrintOperation *op, | |||
| 1555 | gint current_page) | |||
| 1556 | { | |||
| 1557 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1558 | ||||
| 1559 | ctk_print_operation_set_current_page (print->op, current_page); | |||
| 1560 | } | |||
| 1561 | ||||
| 1562 | static void | |||
| 1563 | ev_print_operation_print_set_print_settings (EvPrintOperation *op, | |||
| 1564 | CtkPrintSettings *print_settings) | |||
| 1565 | { | |||
| 1566 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1567 | ||||
| 1568 | ctk_print_operation_set_print_settings (print->op, print_settings); | |||
| 1569 | } | |||
| 1570 | ||||
| 1571 | static CtkPrintSettings * | |||
| 1572 | ev_print_operation_print_get_print_settings (EvPrintOperation *op) | |||
| 1573 | { | |||
| 1574 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1575 | ||||
| 1576 | return ctk_print_operation_get_print_settings (print->op); | |||
| 1577 | } | |||
| 1578 | ||||
| 1579 | static void | |||
| 1580 | ev_print_operation_print_set_default_page_setup (EvPrintOperation *op, | |||
| 1581 | CtkPageSetup *page_setup) | |||
| 1582 | { | |||
| 1583 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1584 | ||||
| 1585 | ctk_print_operation_set_default_page_setup (print->op, page_setup); | |||
| 1586 | } | |||
| 1587 | ||||
| 1588 | static CtkPageSetup * | |||
| 1589 | ev_print_operation_print_get_default_page_setup (EvPrintOperation *op) | |||
| 1590 | { | |||
| 1591 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1592 | ||||
| 1593 | return ctk_print_operation_get_default_page_setup (print->op); | |||
| 1594 | } | |||
| 1595 | ||||
| 1596 | static void | |||
| 1597 | ev_print_operation_print_set_job_name (EvPrintOperation *op, | |||
| 1598 | const gchar *job_name) | |||
| 1599 | { | |||
| 1600 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1601 | ||||
| 1602 | g_free (print->job_name); | |||
| 1603 | print->job_name = g_strdup (job_name)g_strdup_inline (job_name); | |||
| 1604 | ||||
| 1605 | ctk_print_operation_set_job_name (print->op, print->job_name); | |||
| 1606 | } | |||
| 1607 | ||||
| 1608 | static const gchar * | |||
| 1609 | ev_print_operation_print_get_job_name (EvPrintOperation *op) | |||
| 1610 | { | |||
| 1611 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1612 | ||||
| 1613 | if (!print->job_name) { | |||
| 1614 | gchar *name; | |||
| 1615 | ||||
| 1616 | g_object_get (print->op, "job_name", &name, NULL((void*)0)); | |||
| 1617 | print->job_name = name; | |||
| 1618 | } | |||
| 1619 | ||||
| 1620 | return print->job_name; | |||
| 1621 | } | |||
| 1622 | ||||
| 1623 | static void | |||
| 1624 | ev_print_operation_print_run (EvPrintOperation *op, | |||
| 1625 | CtkWindow *parent) | |||
| 1626 | { | |||
| 1627 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1628 | ||||
| 1629 | ctk_print_operation_run (print->op, | |||
| 1630 | CTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, | |||
| 1631 | parent, NULL((void*)0)); | |||
| 1632 | } | |||
| 1633 | ||||
| 1634 | static void | |||
| 1635 | ev_print_operation_print_cancel (EvPrintOperation *op) | |||
| 1636 | { | |||
| 1637 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1638 | ||||
| 1639 | if (print->job_print) | |||
| 1640 | ev_job_cancel (print->job_print); | |||
| 1641 | else | |||
| 1642 | ctk_print_operation_cancel (print->op); | |||
| 1643 | } | |||
| 1644 | ||||
| 1645 | static void | |||
| 1646 | ev_print_operation_print_get_error (EvPrintOperation *op, | |||
| 1647 | GError **error) | |||
| 1648 | { | |||
| 1649 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1650 | ||||
| 1651 | ctk_print_operation_get_error (print->op, error); | |||
| 1652 | } | |||
| 1653 | ||||
| 1654 | static void | |||
| 1655 | ev_print_operation_print_set_embed_page_setup (EvPrintOperation *op, | |||
| 1656 | gboolean embed) | |||
| 1657 | { | |||
| 1658 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1659 | ||||
| 1660 | ctk_print_operation_set_embed_page_setup (print->op, embed); | |||
| 1661 | } | |||
| 1662 | ||||
| 1663 | static gboolean | |||
| 1664 | ev_print_operation_print_get_embed_page_setup (EvPrintOperation *op) | |||
| 1665 | { | |||
| 1666 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((op)), ((ev_print_operation_print_get_type ())))))); | |||
| 1667 | ||||
| 1668 | return ctk_print_operation_get_embed_page_setup (print->op); | |||
| 1669 | } | |||
| 1670 | ||||
| 1671 | static void | |||
| 1672 | ev_print_operation_print_begin_print (EvPrintOperationPrint *print, | |||
| 1673 | CtkPrintContext *context) | |||
| 1674 | { | |||
| 1675 | EvPrintOperation *op = EV_PRINT_OPERATION (print)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((print)), ((ev_print_operation_get_type()))) ))); | |||
| 1676 | gint n_pages; | |||
| 1677 | ||||
| 1678 | n_pages = ev_document_get_n_pages (op->document); | |||
| 1679 | ctk_print_operation_set_n_pages (print->op, n_pages); | |||
| 1680 | ev_print_operation_update_status (op, -1, n_pages, 0); | |||
| 1681 | ||||
| 1682 | g_signal_emit (op, signals[BEGIN_PRINT], 0); | |||
| 1683 | } | |||
| 1684 | ||||
| 1685 | static void | |||
| 1686 | ev_print_operation_print_done (EvPrintOperationPrint *print, | |||
| 1687 | CtkPrintOperationResult result) | |||
| 1688 | { | |||
| 1689 | EvPrintOperation *op = EV_PRINT_OPERATION (print)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((print)), ((ev_print_operation_get_type()))) ))); | |||
| 1690 | ||||
| 1691 | ev_print_operation_update_status (op, 0, print->n_pages_to_print, 1.0); | |||
| 1692 | ||||
| 1693 | g_signal_emit (op, signals[DONE], 0, result); | |||
| 1694 | } | |||
| 1695 | ||||
| 1696 | static void | |||
| 1697 | ev_print_operation_print_status_changed (EvPrintOperationPrint *print) | |||
| 1698 | { | |||
| 1699 | CtkPrintStatus status; | |||
| 1700 | ||||
| 1701 | status = ctk_print_operation_get_status (print->op); | |||
| 1702 | if (status == CTK_PRINT_STATUS_GENERATING_DATA) | |||
| 1703 | print->n_pages_to_print = ctk_print_operation_get_n_pages_to_print (print->op); | |||
| 1704 | } | |||
| 1705 | ||||
| 1706 | static void | |||
| 1707 | print_job_finished (EvJobPrint *job, | |||
| 1708 | EvPrintOperationPrint *print) | |||
| 1709 | { | |||
| 1710 | EvPrintOperation *op = EV_PRINT_OPERATION (print)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((print)), ((ev_print_operation_get_type()))) ))); | |||
| 1711 | ||||
| 1712 | ctk_print_operation_draw_page_finish (print->op); | |||
| 1713 | ||||
| 1714 | print->total++; | |||
| 1715 | ev_print_operation_update_status (op, print->total, | |||
| 1716 | print->n_pages_to_print, | |||
| 1717 | print->total / (gdouble)print->n_pages_to_print); | |||
| 1718 | ev_job_print_set_cairo (job, NULL((void*)0)); | |||
| 1719 | } | |||
| 1720 | ||||
| 1721 | static gboolean | |||
| 1722 | draw_page_finish_idle (EvPrintOperationPrint *print) | |||
| 1723 | { | |||
| 1724 | if (ev_job_scheduler_get_running_thread_job () == print->job_print) | |||
| 1725 | return TRUE(!(0)); | |||
| 1726 | ||||
| 1727 | ctk_print_operation_draw_page_finish (print->op); | |||
| 1728 | ||||
| 1729 | return FALSE(0); | |||
| 1730 | } | |||
| 1731 | ||||
| 1732 | static void | |||
| 1733 | print_job_cancelled (EvJobPrint *job, | |||
| 1734 | EvPrintOperationPrint *print) | |||
| 1735 | { | |||
| 1736 | /* Finish the current page, so that draw-page | |||
| 1737 | * is emitted again and it will cancel the | |||
| 1738 | * print operation. If the job is still | |||
| 1739 | * running, wait until it finishes. | |||
| 1740 | */ | |||
| 1741 | if (ev_job_scheduler_get_running_thread_job () == print->job_print) | |||
| 1742 | g_idle_add ((GSourceFunc)draw_page_finish_idle, print); | |||
| 1743 | else | |||
| 1744 | ctk_print_operation_draw_page_finish (print->op); | |||
| 1745 | } | |||
| 1746 | ||||
| 1747 | static void | |||
| 1748 | ev_print_operation_print_request_page_setup (EvPrintOperationPrint *print, | |||
| 1749 | CtkPrintContext *context, | |||
| 1750 | gint page_nr, | |||
| 1751 | CtkPageSetup *setup) | |||
| 1752 | { | |||
| 1753 | EvPrintOperation *op = EV_PRINT_OPERATION (print)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((print)), ((ev_print_operation_get_type()))) ))); | |||
| 1754 | gdouble width, height; | |||
| 1755 | CtkPaperSize *paper_size; | |||
| 1756 | ||||
| 1757 | ev_document_get_page_size (op->document, page_nr, | |||
| 1758 | &width, &height); | |||
| 1759 | ||||
| 1760 | if (print->use_source_size) { | |||
| 1761 | paper_size = ctk_paper_size_new_custom ("custom", "custom", | |||
| 1762 | width, height, CTK_UNIT_POINTS); | |||
| 1763 | ctk_page_setup_set_paper_size_and_default_margins (setup, paper_size); | |||
| 1764 | ctk_paper_size_free (paper_size); | |||
| 1765 | } | |||
| 1766 | ||||
| 1767 | if (print->autorotate) { | |||
| 1768 | if (width > height) | |||
| 1769 | ctk_page_setup_set_orientation (setup, CTK_PAGE_ORIENTATION_LANDSCAPE); | |||
| 1770 | else | |||
| 1771 | ctk_page_setup_set_orientation (setup, CTK_PAGE_ORIENTATION_PORTRAIT); | |||
| 1772 | } | |||
| 1773 | } | |||
| 1774 | ||||
| 1775 | static void | |||
| 1776 | _print_context_get_hard_margins (CtkPrintContext *context, | |||
| 1777 | gdouble *top, | |||
| 1778 | gdouble *bottom, | |||
| 1779 | gdouble *left, | |||
| 1780 | gdouble *right) | |||
| 1781 | { | |||
| 1782 | if (!ctk_print_context_get_hard_margins (context, top, bottom, left, right)) { | |||
| 1783 | *top = 0; | |||
| 1784 | *bottom = 0; | |||
| 1785 | *left = 0; | |||
| 1786 | *right = 0; | |||
| 1787 | } | |||
| 1788 | } | |||
| 1789 | ||||
| 1790 | static void | |||
| 1791 | ev_print_operation_print_draw_page (EvPrintOperationPrint *print, | |||
| 1792 | CtkPrintContext *context, | |||
| 1793 | gint page) | |||
| 1794 | { | |||
| 1795 | EvPrintOperation *op = EV_PRINT_OPERATION (print)((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((print)), ((ev_print_operation_get_type()))) ))); | |||
| 1796 | cairo_t *cr; | |||
| 1797 | gdouble cr_width, cr_height; | |||
| 1798 | gdouble width, height, scale; | |||
| 1799 | gdouble x_scale, y_scale; | |||
| 1800 | gdouble top, bottom, left, right; | |||
| 1801 | ||||
| 1802 | ctk_print_operation_set_defer_drawing (print->op); | |||
| 1803 | ||||
| 1804 | if (!print->job_print) { | |||
| 1805 | print->job_print = ev_job_print_new (op->document); | |||
| 1806 | g_signal_connect (G_OBJECT (print->job_print), "finished",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((print->job_print)), (((GType) ((20) << (2))))))))), ("finished"), (((GCallback) (print_job_finished ))), ((gpointer)print), ((void*)0), (GConnectFlags) 0) | |||
| 1807 | G_CALLBACK (print_job_finished),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((print->job_print)), (((GType) ((20) << (2))))))))), ("finished"), (((GCallback) (print_job_finished ))), ((gpointer)print), ((void*)0), (GConnectFlags) 0) | |||
| 1808 | (gpointer)print)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((print->job_print)), (((GType) ((20) << (2))))))))), ("finished"), (((GCallback) (print_job_finished ))), ((gpointer)print), ((void*)0), (GConnectFlags) 0); | |||
| 1809 | g_signal_connect (G_OBJECT (print->job_print), "cancelled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((print->job_print)), (((GType) ((20) << (2))))))))), ("cancelled"), (((GCallback) (print_job_cancelled ))), ((gpointer)print), ((void*)0), (GConnectFlags) 0) | |||
| 1810 | G_CALLBACK (print_job_cancelled),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((print->job_print)), (((GType) ((20) << (2))))))))), ("cancelled"), (((GCallback) (print_job_cancelled ))), ((gpointer)print), ((void*)0), (GConnectFlags) 0) | |||
| 1811 | (gpointer)print)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((print->job_print)), (((GType) ((20) << (2))))))))), ("cancelled"), (((GCallback) (print_job_cancelled ))), ((gpointer)print), ((void*)0), (GConnectFlags) 0); | |||
| 1812 | } else if (g_cancellable_is_cancelled (print->job_print->cancellable)) { | |||
| 1813 | ctk_print_operation_cancel (print->op); | |||
| 1814 | ev_job_print_set_cairo (EV_JOB_PRINT (print->job_print)((((EvJobPrint*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->job_print)), ((ev_job_print_get_type())))))), NULL((void*)0)); | |||
| 1815 | return; | |||
| 1816 | } | |||
| 1817 | ||||
| 1818 | ev_job_print_set_page (EV_JOB_PRINT (print->job_print)((((EvJobPrint*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->job_print)), ((ev_job_print_get_type())))))), page); | |||
| 1819 | ||||
| 1820 | cr = ctk_print_context_get_cairo_context (context); | |||
| 1821 | cr_width = ctk_print_context_get_width (context); | |||
| 1822 | cr_height = ctk_print_context_get_height (context); | |||
| 1823 | ev_document_get_page_size (op->document, page, &width, &height); | |||
| 1824 | ||||
| 1825 | if (print->page_scale == EV_SCALE_NONE) { | |||
| 1826 | /* Center document page on the printed page */ | |||
| 1827 | if (print->autorotate) | |||
| 1828 | cairo_translate (cr, (cr_width - width) / 2, (cr_height - height) / 2); | |||
| 1829 | } else { | |||
| 1830 | _print_context_get_hard_margins (context, &top, &bottom, &left, &right); | |||
| 1831 | ||||
| 1832 | x_scale = (cr_width - left - right) / width; | |||
| 1833 | y_scale = (cr_height - top - bottom) / height; | |||
| 1834 | ||||
| 1835 | if (x_scale < y_scale) | |||
| 1836 | scale = x_scale; | |||
| 1837 | else | |||
| 1838 | scale = y_scale; | |||
| 1839 | ||||
| 1840 | if (print->autorotate) { | |||
| 1841 | double left_right_sides, top_bottom_sides; | |||
| 1842 | ||||
| 1843 | cairo_translate (cr, (cr_width - scale * width) / 2, | |||
| 1844 | (cr_height - scale * height) / 2); | |||
| 1845 | ||||
| 1846 | /* Ensure document page is within the margins. The | |||
| 1847 | * scale guarantees the document will fit in the | |||
| 1848 | * margins so we just need to check each side and | |||
| 1849 | * if it overhangs the margin, translate it to the | |||
| 1850 | * margin. */ | |||
| 1851 | left_right_sides = (cr_width - width*scale)/2; | |||
| 1852 | top_bottom_sides = (cr_height - height*scale)/2; | |||
| 1853 | if (left_right_sides < left) | |||
| 1854 | cairo_translate (cr, left - left_right_sides, 0); | |||
| 1855 | ||||
| 1856 | if (left_right_sides < right) | |||
| 1857 | cairo_translate (cr, -(right - left_right_sides), 0); | |||
| 1858 | ||||
| 1859 | if (top_bottom_sides < top) | |||
| 1860 | cairo_translate (cr, 0, top - top_bottom_sides); | |||
| 1861 | ||||
| 1862 | if (top_bottom_sides < bottom) | |||
| 1863 | cairo_translate (cr, 0, -(bottom - top_bottom_sides)); | |||
| 1864 | } else { | |||
| 1865 | cairo_translate (cr, left, top); | |||
| 1866 | } | |||
| 1867 | ||||
| 1868 | if (print->page_scale == EV_SCALE_FIT_TO_PRINTABLE_AREA || scale < 1.0) { | |||
| 1869 | cairo_scale (cr, scale, scale); | |||
| 1870 | } | |||
| 1871 | } | |||
| 1872 | ||||
| 1873 | ev_job_print_set_cairo (EV_JOB_PRINT (print->job_print)((((EvJobPrint*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->job_print)), ((ev_job_print_get_type())))))), cr); | |||
| 1874 | ev_job_scheduler_push_job (print->job_print, EV_JOB_PRIORITY_NONE); | |||
| 1875 | } | |||
| 1876 | ||||
| 1877 | static GObject * | |||
| 1878 | ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print, | |||
| 1879 | CtkPrintContext *context) | |||
| 1880 | { | |||
| 1881 | CtkPrintSettings *settings; | |||
| 1882 | CtkWidget *label; | |||
| 1883 | CtkWidget *grid; | |||
| 1884 | EvPrintScale page_scale; | |||
| 1885 | gboolean autorotate; | |||
| 1886 | gboolean use_source_size; | |||
| 1887 | ||||
| 1888 | settings = ctk_print_operation_get_print_settings (print->op); | |||
| 1889 | page_scale = ctk_print_settings_get_int_with_default (settings, EV_PRINT_SETTING_PAGE_SCALE"lector-print-setting-page-scale", 1); | |||
| 1890 | autorotate = ctk_print_settings_has_key (settings, EV_PRINT_SETTING_AUTOROTATE"lector-print-setting-page-autorotate") ? | |||
| 1891 | ctk_print_settings_get_bool (settings, EV_PRINT_SETTING_AUTOROTATE"lector-print-setting-page-autorotate") : | |||
| 1892 | TRUE(!(0)); | |||
| 1893 | use_source_size = ctk_print_settings_get_bool (settings, EV_PRINT_SETTING_PAGE_SIZE"lector-print-setting-page-size"); | |||
| 1894 | ||||
| 1895 | grid = ctk_grid_new (); | |||
| 1896 | ctk_grid_set_row_spacing (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), 6); | |||
| 1897 | ctk_grid_set_column_spacing (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), 12); | |||
| 1898 | ctk_container_set_border_width (CTK_CONTAINER (grid)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_container_get_type ())))))), 12); | |||
| 1899 | ||||
| 1900 | label = ctk_label_new (_("Page Scaling:")gettext ("Page Scaling:")); | |||
| 1901 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), label, 0, 0, 1, 1); | |||
| 1902 | ctk_widget_show (label); | |||
| 1903 | ||||
| 1904 | print->scale_combo = ctk_combo_box_text_new (); | |||
| 1905 | /* translators: Value for 'Page Scaling:' to not scale the document pages on printing */ | |||
| 1906 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (print->scale_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->scale_combo)), ((ctk_combo_box_text_get_type ( ))))))), _("None")gettext ("None")); | |||
| 1907 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (print->scale_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->scale_combo)), ((ctk_combo_box_text_get_type ( ))))))), _("Shrink to Printable Area")gettext ("Shrink to Printable Area")); | |||
| 1908 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (print->scale_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->scale_combo)), ((ctk_combo_box_text_get_type ( ))))))), _("Fit to Printable Area")gettext ("Fit to Printable Area")); | |||
| 1909 | ctk_combo_box_set_active (CTK_COMBO_BOX (print->scale_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->scale_combo)), ((ctk_combo_box_get_type ())))) )), page_scale); | |||
| 1910 | ctk_widget_set_tooltip_text (print->scale_combo, | |||
| 1911 | _("Scale document pages to fit the selected printer page. Select from one of the following:\n"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1912 | "\n"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1913 | "• \"None\": No page scaling is performed.\n"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1914 | "\n"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1915 | "• \"Shrink to Printable Area\": Document pages larger than the printable area"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1916 | " are reduced to fit the printable area of the printer page.\n"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1917 | "\n"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1918 | "• \"Fit to Printable Area\": Document pages are enlarged or reduced as"gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" ) | |||
| 1919 | " required to fit the printable area of the printer page.\n")gettext ("Scale document pages to fit the selected printer page. Select from one of the following:\n" "\n" "• \"None\": No page scaling is performed.\n" "\n" "• \"Shrink to Printable Area\": Document pages larger than the printable area" " are reduced to fit the printable area of the printer page.\n" "\n" "• \"Fit to Printable Area\": Document pages are enlarged or reduced as" " required to fit the printable area of the printer page.\n" )); | |||
| 1920 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), print->scale_combo, 1, 0, 1, 1); | |||
| 1921 | ctk_widget_show (print->scale_combo); | |||
| 1922 | ||||
| 1923 | print->autorotate_button = ctk_check_button_new_with_label (_("Auto Rotate and Center")gettext ("Auto Rotate and Center")); | |||
| 1924 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (print->autorotate_button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->autorotate_button)), ((ctk_toggle_button_get_type ())))))), autorotate); | |||
| 1925 | ctk_widget_set_tooltip_text (print->autorotate_button, | |||
| 1926 | _("Rotate printer page orientation of each page to match orientation of each document page. "gettext ("Rotate printer page orientation of each page to match orientation of each document page. " "Document pages will be centered within the printer page.") | |||
| 1927 | "Document pages will be centered within the printer page.")gettext ("Rotate printer page orientation of each page to match orientation of each document page. " "Document pages will be centered within the printer page.")); | |||
| 1928 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), print->autorotate_button, 0, 1, 2, 1); | |||
| 1929 | ctk_widget_show (print->autorotate_button); | |||
| 1930 | ||||
| 1931 | print->source_button = ctk_check_button_new_with_label (_("Select page size using document page size")gettext ("Select page size using document page size")); | |||
| 1932 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (print->source_button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->source_button)), ((ctk_toggle_button_get_type ( ))))))), use_source_size); | |||
| 1933 | ctk_widget_set_tooltip_text (print->source_button, _("When enabled, each page will be printed on "gettext ("When enabled, each page will be printed on " "the same size paper as the document page." ) | |||
| 1934 | "the same size paper as the document page.")gettext ("When enabled, each page will be printed on " "the same size paper as the document page." )); | |||
| 1935 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), print->source_button, 0, 2, 2, 1); | |||
| 1936 | ctk_widget_show (print->source_button); | |||
| 1937 | ||||
| 1938 | return G_OBJECT (grid)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), (((GType) ((20) << (2)))))))); | |||
| 1939 | } | |||
| 1940 | ||||
| 1941 | static void | |||
| 1942 | ev_print_operation_print_custom_widget_apply (EvPrintOperationPrint *print, | |||
| 1943 | CtkPrintContext *context) | |||
| 1944 | { | |||
| 1945 | CtkPrintSettings *settings; | |||
| 1946 | ||||
| 1947 | print->page_scale = ctk_combo_box_get_active (CTK_COMBO_BOX (print->scale_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->scale_combo)), ((ctk_combo_box_get_type ())))) ))); | |||
| 1948 | print->autorotate = ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (print->autorotate_button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->autorotate_button)), ((ctk_toggle_button_get_type ()))))))); | |||
| 1949 | print->use_source_size = ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (print->source_button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print->source_button)), ((ctk_toggle_button_get_type ( )))))))); | |||
| 1950 | settings = ctk_print_operation_get_print_settings (print->op); | |||
| 1951 | ctk_print_settings_set_int (settings, EV_PRINT_SETTING_PAGE_SCALE"lector-print-setting-page-scale", print->page_scale); | |||
| 1952 | ctk_print_settings_set_bool (settings, EV_PRINT_SETTING_AUTOROTATE"lector-print-setting-page-autorotate", print->autorotate); | |||
| 1953 | ctk_print_settings_set_bool (settings, EV_PRINT_SETTING_PAGE_SIZE"lector-print-setting-page-size", print->use_source_size); | |||
| 1954 | } | |||
| 1955 | ||||
| 1956 | static void | |||
| 1957 | ev_print_operation_print_finalize (GObject *object) | |||
| 1958 | { | |||
| 1959 | EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (object)((((EvPrintOperationPrint*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ev_print_operation_print_get_type ())))))); | |||
| 1960 | ||||
| 1961 | if (print->op) { | |||
| 1962 | g_object_unref (print->op); | |||
| 1963 | print->op = NULL((void*)0); | |||
| 1964 | } | |||
| 1965 | ||||
| 1966 | if (print->job_name) { | |||
| 1967 | g_free (print->job_name); | |||
| 1968 | print->job_name = NULL((void*)0); | |||
| 1969 | } | |||
| 1970 | ||||
| 1971 | if (print->job_print) { | |||
| 1972 | if (!ev_job_is_finished (print->job_print)) | |||
| 1973 | ev_job_cancel (print->job_print); | |||
| 1974 | g_signal_handlers_disconnect_by_func (print->job_print,g_signal_handlers_disconnect_matched ((print->job_print), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (print_job_finished), (print)) | |||
| 1975 | print_job_finished,g_signal_handlers_disconnect_matched ((print->job_print), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (print_job_finished), (print)) | |||
| 1976 | print)g_signal_handlers_disconnect_matched ((print->job_print), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (print_job_finished), (print)); | |||
| 1977 | g_signal_handlers_disconnect_by_func (print->job_print,g_signal_handlers_disconnect_matched ((print->job_print), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (print_job_cancelled), (print)) | |||
| 1978 | print_job_cancelled,g_signal_handlers_disconnect_matched ((print->job_print), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (print_job_cancelled), (print)) | |||
| 1979 | print)g_signal_handlers_disconnect_matched ((print->job_print), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (print_job_cancelled), (print)); | |||
| 1980 | g_object_unref (print->job_print); | |||
| 1981 | print->job_print = NULL((void*)0); | |||
| 1982 | } | |||
| 1983 | ||||
| 1984 | (* G_OBJECT_CLASS (ev_print_operation_print_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ev_print_operation_print_parent_class)), (((GType) ((20) << (2))))))))->finalize) (object); | |||
| 1985 | } | |||
| 1986 | ||||
| 1987 | static void | |||
| 1988 | ev_print_operation_print_init (EvPrintOperationPrint *print) | |||
| 1989 | { | |||
| 1990 | print->op = ctk_print_operation_new (); | |||
| 1991 | g_signal_connect_swapped (print->op, "begin_print",g_signal_connect_data ((print->op), ("begin_print"), (((GCallback ) (ev_print_operation_print_begin_print))), (print), ((void*) 0), G_CONNECT_SWAPPED) | |||
| 1992 | G_CALLBACK (ev_print_operation_print_begin_print),g_signal_connect_data ((print->op), ("begin_print"), (((GCallback ) (ev_print_operation_print_begin_print))), (print), ((void*) 0), G_CONNECT_SWAPPED) | |||
| 1993 | print)g_signal_connect_data ((print->op), ("begin_print"), (((GCallback ) (ev_print_operation_print_begin_print))), (print), ((void*) 0), G_CONNECT_SWAPPED); | |||
| 1994 | g_signal_connect_swapped (print->op, "done",g_signal_connect_data ((print->op), ("done"), (((GCallback ) (ev_print_operation_print_done))), (print), ((void*)0), G_CONNECT_SWAPPED ) | |||
| 1995 | G_CALLBACK (ev_print_operation_print_done),g_signal_connect_data ((print->op), ("done"), (((GCallback ) (ev_print_operation_print_done))), (print), ((void*)0), G_CONNECT_SWAPPED ) | |||
| 1996 | print)g_signal_connect_data ((print->op), ("done"), (((GCallback ) (ev_print_operation_print_done))), (print), ((void*)0), G_CONNECT_SWAPPED ); | |||
| 1997 | g_signal_connect_swapped (print->op, "draw_page",g_signal_connect_data ((print->op), ("draw_page"), (((GCallback ) (ev_print_operation_print_draw_page))), (print), ((void*)0) , G_CONNECT_SWAPPED) | |||
| 1998 | G_CALLBACK (ev_print_operation_print_draw_page),g_signal_connect_data ((print->op), ("draw_page"), (((GCallback ) (ev_print_operation_print_draw_page))), (print), ((void*)0) , G_CONNECT_SWAPPED) | |||
| 1999 | print)g_signal_connect_data ((print->op), ("draw_page"), (((GCallback ) (ev_print_operation_print_draw_page))), (print), ((void*)0) , G_CONNECT_SWAPPED); | |||
| 2000 | g_signal_connect_swapped (print->op, "status_changed",g_signal_connect_data ((print->op), ("status_changed"), (( (GCallback) (ev_print_operation_print_status_changed))), (print ), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2001 | G_CALLBACK (ev_print_operation_print_status_changed),g_signal_connect_data ((print->op), ("status_changed"), (( (GCallback) (ev_print_operation_print_status_changed))), (print ), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2002 | print)g_signal_connect_data ((print->op), ("status_changed"), (( (GCallback) (ev_print_operation_print_status_changed))), (print ), ((void*)0), G_CONNECT_SWAPPED); | |||
| 2003 | g_signal_connect_swapped (print->op, "request_page_setup",g_signal_connect_data ((print->op), ("request_page_setup") , (((GCallback) (ev_print_operation_print_request_page_setup) )), (print), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2004 | G_CALLBACK (ev_print_operation_print_request_page_setup),g_signal_connect_data ((print->op), ("request_page_setup") , (((GCallback) (ev_print_operation_print_request_page_setup) )), (print), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2005 | print)g_signal_connect_data ((print->op), ("request_page_setup") , (((GCallback) (ev_print_operation_print_request_page_setup) )), (print), ((void*)0), G_CONNECT_SWAPPED); | |||
| 2006 | g_signal_connect_swapped (print->op, "create_custom_widget",g_signal_connect_data ((print->op), ("create_custom_widget" ), (((GCallback) (ev_print_operation_print_create_custom_widget ))), (print), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2007 | G_CALLBACK (ev_print_operation_print_create_custom_widget),g_signal_connect_data ((print->op), ("create_custom_widget" ), (((GCallback) (ev_print_operation_print_create_custom_widget ))), (print), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2008 | print)g_signal_connect_data ((print->op), ("create_custom_widget" ), (((GCallback) (ev_print_operation_print_create_custom_widget ))), (print), ((void*)0), G_CONNECT_SWAPPED); | |||
| 2009 | g_signal_connect_swapped (print->op, "custom_widget_apply",g_signal_connect_data ((print->op), ("custom_widget_apply" ), (((GCallback) (ev_print_operation_print_custom_widget_apply ))), (print), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2010 | G_CALLBACK (ev_print_operation_print_custom_widget_apply),g_signal_connect_data ((print->op), ("custom_widget_apply" ), (((GCallback) (ev_print_operation_print_custom_widget_apply ))), (print), ((void*)0), G_CONNECT_SWAPPED) | |||
| 2011 | print)g_signal_connect_data ((print->op), ("custom_widget_apply" ), (((GCallback) (ev_print_operation_print_custom_widget_apply ))), (print), ((void*)0), G_CONNECT_SWAPPED); | |||
| 2012 | ctk_print_operation_set_allow_async (print->op, TRUE(!(0))); | |||
| 2013 | ctk_print_operation_set_use_full_page (print->op, TRUE(!(0))); | |||
| 2014 | ctk_print_operation_set_unit (print->op, CTK_UNIT_POINTS); | |||
| 2015 | ctk_print_operation_set_custom_tab_label (print->op, _("Page Handling")gettext ("Page Handling")); | |||
| 2016 | } | |||
| 2017 | ||||
| 2018 | static void | |||
| 2019 | ev_print_operation_print_class_init (EvPrintOperationPrintClass *klass) | |||
| 2020 | { | |||
| 2021 | GObjectClass *g_object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); | |||
| 2022 | EvPrintOperationClass *ev_print_op_class = EV_PRINT_OPERATION_CLASS (klass)((((EvPrintOperationClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((klass)), ((ev_print_operation_get_type()))))) ); | |||
| 2023 | ||||
| 2024 | ev_print_op_class->set_current_page = ev_print_operation_print_set_current_page; | |||
| 2025 | ev_print_op_class->set_print_settings = ev_print_operation_print_set_print_settings; | |||
| 2026 | ev_print_op_class->get_print_settings = ev_print_operation_print_get_print_settings; | |||
| 2027 | ev_print_op_class->set_default_page_setup = ev_print_operation_print_set_default_page_setup; | |||
| 2028 | ev_print_op_class->get_default_page_setup = ev_print_operation_print_get_default_page_setup; | |||
| 2029 | ev_print_op_class->set_job_name = ev_print_operation_print_set_job_name; | |||
| 2030 | ev_print_op_class->get_job_name = ev_print_operation_print_get_job_name; | |||
| 2031 | ev_print_op_class->run = ev_print_operation_print_run; | |||
| 2032 | ev_print_op_class->cancel = ev_print_operation_print_cancel; | |||
| 2033 | ev_print_op_class->get_error = ev_print_operation_print_get_error; | |||
| 2034 | ev_print_op_class->set_embed_page_setup = ev_print_operation_print_set_embed_page_setup; | |||
| 2035 | ev_print_op_class->get_embed_page_setup = ev_print_operation_print_get_embed_page_setup; | |||
| 2036 | ||||
| 2037 | g_object_class->finalize = ev_print_operation_print_finalize; | |||
| 2038 | } | |||
| 2039 | ||||
| 2040 | gboolean | |||
| 2041 | ev_print_operation_exists_for_document (EvDocument *document) | |||
| 2042 | { | |||
| 2043 | #if CTKUNIXPRINT_ENABLED1 | |||
| 2044 | return (EV_IS_FILE_EXPORTER(document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (document)); GType __t = ((ev_file_exporter_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; })))) || EV_IS_DOCUMENT_PRINT(document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (document)); GType __t = ((ev_document_print_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; }))))); | |||
| 2045 | #else | |||
| 2046 | return EV_IS_DOCUMENT_PRINT(document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (document)); GType __t = ((ev_document_print_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; })))); | |||
| 2047 | #endif /* CTKUNIXPRINT_ENABLED */ | |||
| 2048 | } | |||
| 2049 | ||||
| 2050 | /* Factory method */ | |||
| 2051 | EvPrintOperation * | |||
| 2052 | ev_print_operation_new (EvDocument *document) | |||
| 2053 | { | |||
| 2054 | EvPrintOperation *op = NULL((void*)0); | |||
| 2055 | ||||
| 2056 | g_return_val_if_fail (ev_print_operation_exists_for_document (document), NULL)do { if ((ev_print_operation_exists_for_document (document))) { } else { g_return_if_fail_warning ("LectorView", ((const char *) (__func__)), "ev_print_operation_exists_for_document (document)" ); return (((void*)0)); } } while (0); | |||
| 2057 | ||||
| 2058 | if (EV_IS_DOCUMENT_PRINT (document)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (document)); GType __t = ((ev_document_print_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; }))))) | |||
| 2059 | op = EV_PRINT_OPERATION (g_object_new (EV_TYPE_PRINT_OPERATION_PRINT,((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((g_object_new ((ev_print_operation_print_get_type ()), "document", document, ((void*)0)))), ((ev_print_operation_get_type ())))))) | |||
| 2060 | "document", document, NULL))((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((g_object_new ((ev_print_operation_print_get_type ()), "document", document, ((void*)0)))), ((ev_print_operation_get_type ())))))); | |||
| 2061 | else | |||
| 2062 | #if CTKUNIXPRINT_ENABLED1 | |||
| 2063 | op = EV_PRINT_OPERATION (g_object_new (EV_TYPE_PRINT_OPERATION_EXPORT,((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((g_object_new ((ev_print_operation_export_get_type ()), "document", document, ((void*)0)))), ((ev_print_operation_get_type ())))))) | |||
| 2064 | "document", document, NULL))((((EvPrintOperation*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((g_object_new ((ev_print_operation_export_get_type ()), "document", document, ((void*)0)))), ((ev_print_operation_get_type ())))))); | |||
| 2065 | #else | |||
| 2066 | op = NULL((void*)0); | |||
| 2067 | #endif | |||
| 2068 | return op; | |||
| 2069 | } |