]> Pileus Git - ~andy/gtk/blob - gtk/gtkprintjob.c
Move GtkPrintJob docs inline
[~andy/gtk] / gtk / gtkprintjob.c
1 /* GtkPrintJob
2  * Copyright (C) 2006 John (J5) Palmieri  <johnp@redhat.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /**
21  * SECTION:gtkprintjob
22  * @Title: GtkPrintJob
23  * @Short_description: Represents a print job
24  *
25  * A #GtkPrintJob object represents a job that is sent to a
26  * printer. You only need to deal directly with print jobs if
27  * you use the non-portable #GtkPrintUnixDialog API.
28  *
29  * Use gtk_print_job_get_surface() to obtain the cairo surface
30  * onto which the pages must be drawn. Use gtk_print_job_send()
31  * to send the finished job to the printer. If you don't use cairo
32  * #GtkPrintJob also supports printing of manually generated postscript,
33  * via gtk_print_job_set_source_file().
34  */
35 #include "config.h"
36 #include <stdlib.h>
37 #include <string.h>
38 #include <stdio.h>
39 #include <fcntl.h>
40 #include <errno.h>
41 #ifdef HAVE_UNISTD_H
42 #include <unistd.h>
43 #endif
44 #include <sys/types.h>
45 #include <sys/stat.h>
46
47 #include <glib/gstdio.h>
48 #include "gtkintl.h"
49 #include "gtkprivate.h"
50
51 #include "gtkprintjob.h"
52 #include "gtkprinter.h"
53 #include "gtkprinter-private.h"
54 #include "gtkprintbackend.h"
55
56 #ifndef O_BINARY
57 #define O_BINARY 0
58 #endif
59
60 struct _GtkPrintJobPrivate
61 {
62   gchar *title;
63
64   GIOChannel *spool_io;
65   cairo_surface_t *surface;
66
67   GtkPrintStatus status;
68   GtkPrintBackend *backend;
69   GtkPrinter *printer;
70   GtkPrintSettings *settings;
71   GtkPageSetup *page_setup;
72
73   GtkPrintPages print_pages;
74   GtkPageRange *page_ranges;
75   gint num_page_ranges;
76   GtkPageSet page_set;
77   gint num_copies;
78   gdouble scale;
79   guint number_up;
80   GtkNumberUpLayout number_up_layout;
81
82   guint printer_set           : 1;
83   guint page_setup_set        : 1;
84   guint settings_set          : 1;
85   guint track_print_status    : 1;
86   guint rotate_to_orientation : 1;
87   guint collate               : 1;
88   guint reverse               : 1;
89 };
90
91 #define GTK_PRINT_JOB_GET_PRIVATE(o)  \
92    (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINT_JOB, GtkPrintJobPrivate))
93
94 static void     gtk_print_job_finalize     (GObject               *object);
95 static void     gtk_print_job_set_property (GObject               *object,
96                                             guint                  prop_id,
97                                             const GValue          *value,
98                                             GParamSpec            *pspec);
99 static void     gtk_print_job_get_property (GObject               *object,
100                                             guint                  prop_id,
101                                             GValue                *value,
102                                             GParamSpec            *pspec);
103 static GObject* gtk_print_job_constructor  (GType                  type,
104                                             guint                  n_construct_properties,
105                                             GObjectConstructParam *construct_params);
106
107 enum {
108   STATUS_CHANGED,
109   LAST_SIGNAL
110 };
111
112 enum {
113   PROP_0,
114   PROP_TITLE,
115   PROP_PRINTER,
116   PROP_PAGE_SETUP,
117   PROP_SETTINGS,
118   PROP_TRACK_PRINT_STATUS
119 };
120
121 static guint signals[LAST_SIGNAL] = { 0 };
122
123 G_DEFINE_TYPE (GtkPrintJob, gtk_print_job, G_TYPE_OBJECT)
124
125 static void
126 gtk_print_job_class_init (GtkPrintJobClass *class)
127 {
128   GObjectClass *object_class;
129   object_class = (GObjectClass *) class;
130
131   object_class->finalize = gtk_print_job_finalize;
132   object_class->constructor = gtk_print_job_constructor;
133   object_class->set_property = gtk_print_job_set_property;
134   object_class->get_property = gtk_print_job_get_property;
135
136   g_type_class_add_private (class, sizeof (GtkPrintJobPrivate));
137
138   g_object_class_install_property (object_class,
139                                    PROP_TITLE,
140                                    g_param_spec_string ("title",
141                                                         P_("Title"),
142                                                         P_("Title of the print job"),
143                                                         NULL,
144                                                         GTK_PARAM_READWRITE |
145                                                         G_PARAM_CONSTRUCT_ONLY));
146
147   g_object_class_install_property (object_class,
148                                    PROP_PRINTER,
149                                    g_param_spec_object ("printer",
150                                                         P_("Printer"),
151                                                         P_("Printer to print the job to"),
152                                                         GTK_TYPE_PRINTER,
153                                                         GTK_PARAM_READWRITE |
154                                                         G_PARAM_CONSTRUCT_ONLY));
155
156   g_object_class_install_property (object_class,
157                                    PROP_SETTINGS,
158                                    g_param_spec_object ("settings",
159                                                         P_("Settings"),
160                                                         P_("Printer settings"),
161                                                         GTK_TYPE_PRINT_SETTINGS,
162                                                         GTK_PARAM_READWRITE |
163                                                         G_PARAM_CONSTRUCT_ONLY));
164
165   g_object_class_install_property (object_class,
166                                    PROP_PAGE_SETUP,
167                                    g_param_spec_object ("page-setup",
168                                                         P_("Page Setup"),
169                                                         P_("Page Setup"),
170                                                         GTK_TYPE_PAGE_SETUP,
171                                                         GTK_PARAM_READWRITE |
172                                                         G_PARAM_CONSTRUCT_ONLY));
173
174   g_object_class_install_property (object_class,
175                                    PROP_TRACK_PRINT_STATUS,
176                                    g_param_spec_boolean ("track-print-status",
177                                                          P_("Track Print Status"),
178                                                          P_("TRUE if the print job will continue to emit "
179                                                             "status-changed signals after the print data "
180                                                             "has been sent to the printer or print server."),
181                                                          FALSE,
182                                                          GTK_PARAM_READWRITE));
183   
184
185   /**
186    * GtkPrintJob::status-changed:
187    * @job: the #GtkPrintJob object on which the signal was emitted
188    *
189    * Gets emitted when the status of a job changes. The signal handler
190    * can use gtk_print_job_get_status() to obtain the new status.
191    *
192    * Since: 2.10
193    */
194   signals[STATUS_CHANGED] =
195     g_signal_new (I_("status-changed"),
196                   G_TYPE_FROM_CLASS (class),
197                   G_SIGNAL_RUN_LAST,
198                   G_STRUCT_OFFSET (GtkPrintJobClass, status_changed),
199                   NULL, NULL,
200                   g_cclosure_marshal_VOID__VOID,
201                   G_TYPE_NONE, 0);
202 }
203
204 static void
205 gtk_print_job_init (GtkPrintJob *job)
206 {
207   GtkPrintJobPrivate *priv;
208
209   priv = job->priv = GTK_PRINT_JOB_GET_PRIVATE (job);
210
211   priv->spool_io = NULL;
212
213   priv->title = g_strdup ("");
214   priv->surface = NULL;
215   priv->backend = NULL;
216   priv->printer = NULL;
217
218   priv->printer_set = FALSE;
219   priv->settings_set = FALSE;
220   priv->page_setup_set = FALSE;
221   priv->status = GTK_PRINT_STATUS_INITIAL;
222   priv->track_print_status = FALSE;
223
224   priv->print_pages = GTK_PRINT_PAGES_ALL;
225   priv->page_ranges = NULL;
226   priv->num_page_ranges = 0;
227   priv->collate = FALSE;
228   priv->reverse = FALSE;
229   priv->num_copies = 1;
230   priv->scale = 1.0;
231   priv->page_set = GTK_PAGE_SET_ALL;
232   priv->rotate_to_orientation = FALSE;
233   priv->number_up = 1;
234   priv->number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
235 }
236
237
238 static GObject*
239 gtk_print_job_constructor (GType                  type,
240                            guint                  n_construct_properties,
241                            GObjectConstructParam *construct_params)
242 {
243   GtkPrintJob *job;
244   GtkPrintJobPrivate *priv;
245   GObject *object;
246
247   object =
248     G_OBJECT_CLASS (gtk_print_job_parent_class)->constructor (type,
249                                                               n_construct_properties,
250                                                               construct_params);
251
252   job = GTK_PRINT_JOB (object);
253
254   priv = job->priv;
255   g_assert (priv->printer_set &&
256             priv->settings_set &&
257             priv->page_setup_set);
258   
259   _gtk_printer_prepare_for_print (priv->printer,
260                                   job,
261                                   priv->settings,
262                                   priv->page_setup);
263
264   return object;
265 }
266
267
268 static void
269 gtk_print_job_finalize (GObject *object)
270 {
271   GtkPrintJob *job = GTK_PRINT_JOB (object);
272   GtkPrintJobPrivate *priv = job->priv;
273
274   if (priv->spool_io != NULL)
275     {
276       g_io_channel_unref (priv->spool_io);
277       priv->spool_io = NULL;
278     }
279
280   if (priv->backend)
281     g_object_unref (priv->backend);
282
283   if (priv->printer)
284     g_object_unref (priv->printer);
285
286   if (priv->surface)
287     cairo_surface_destroy (priv->surface);
288
289   if (priv->settings)
290     g_object_unref (priv->settings);
291
292   if (priv->page_setup)
293     g_object_unref (priv->page_setup);
294
295   g_free (priv->page_ranges);
296   priv->page_ranges = NULL;
297
298   g_free (priv->title);
299   priv->title = NULL;
300
301   G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize (object);
302 }
303
304 /**
305  * gtk_print_job_new:
306  * @title: the job title
307  * @printer: a #GtkPrinter
308  * @settings: a #GtkPrintSettings
309  * @page_setup: a #GtkPageSetup
310  *
311  * Creates a new #GtkPrintJob.
312  *
313  * Return value: a new #GtkPrintJob
314  *
315  * Since: 2.10
316  **/
317 GtkPrintJob *
318 gtk_print_job_new (const gchar      *title,
319                    GtkPrinter       *printer,
320                    GtkPrintSettings *settings,
321                    GtkPageSetup     *page_setup)
322 {
323   GObject *result;
324   result = g_object_new (GTK_TYPE_PRINT_JOB,
325                          "title", title,
326                          "printer", printer,
327                          "settings", settings,
328                          "page-setup", page_setup,
329                          NULL);
330   return (GtkPrintJob *) result;
331 }
332
333 /**
334  * gtk_print_job_get_settings:
335  * @job: a #GtkPrintJob
336  * 
337  * Gets the #GtkPrintSettings of the print job.
338  * 
339  * Return value: the settings of @job
340  *
341  * Since: 2.10
342  */
343 GtkPrintSettings *
344 gtk_print_job_get_settings (GtkPrintJob *job)
345 {
346   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
347   
348   return job->priv->settings;
349 }
350
351 /**
352  * gtk_print_job_get_printer:
353  * @job: a #GtkPrintJob
354  * 
355  * Gets the #GtkPrinter of the print job.
356  * 
357  * Return value: the printer of @job
358  *
359  * Since: 2.10
360  */
361 GtkPrinter *
362 gtk_print_job_get_printer (GtkPrintJob *job)
363 {
364   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
365   
366   return job->priv->printer;
367 }
368
369 /**
370  * gtk_print_job_get_title:
371  * @job: a #GtkPrintJob
372  * 
373  * Gets the job title.
374  * 
375  * Return value: the title of @job
376  *
377  * Since: 2.10
378  */
379 G_CONST_RETURN gchar *
380 gtk_print_job_get_title (GtkPrintJob *job)
381 {
382   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
383   
384   return job->priv->title;
385 }
386
387 /**
388  * gtk_print_job_get_status:
389  * @job: a #GtkPrintJob
390  * 
391  * Gets the status of the print job.
392  * 
393  * Return value: the status of @job
394  *
395  * Since: 2.10
396  */
397 GtkPrintStatus
398 gtk_print_job_get_status (GtkPrintJob *job)
399 {
400   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), GTK_PRINT_STATUS_FINISHED);
401   
402   return job->priv->status;
403 }
404
405 void
406 gtk_print_job_set_status (GtkPrintJob   *job,
407                           GtkPrintStatus status)
408 {
409   GtkPrintJobPrivate *priv;
410
411   g_return_if_fail (GTK_IS_PRINT_JOB (job));
412
413   priv = job->priv;
414
415   if (priv->status == status)
416     return;
417
418   priv->status = status;
419   g_signal_emit (job, signals[STATUS_CHANGED], 0);
420 }
421
422 /**
423  * gtk_print_job_set_source_file:
424  * @job: a #GtkPrintJob
425  * @filename: the file to be printed
426  * @error: return location for errors
427  * 
428  * Make the #GtkPrintJob send an existing document to the 
429  * printing system. The file can be in any format understood
430  * by the platforms printing system (typically PostScript,
431  * but on many platforms PDF may work too). See 
432  * gtk_printer_accepts_pdf() and gtk_printer_accepts_ps().
433  * 
434  * Returns: %FALSE if an error occurred
435  *
436  * Since: 2.10
437  **/
438 gboolean
439 gtk_print_job_set_source_file (GtkPrintJob *job,
440                                const gchar *filename,
441                                GError     **error)
442 {
443   GtkPrintJobPrivate *priv;
444   GError *tmp_error;
445
446   tmp_error = NULL;
447
448   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
449
450   priv = job->priv;
451
452   priv->spool_io = g_io_channel_new_file (filename, "r", &tmp_error);
453
454   if (tmp_error == NULL)
455     g_io_channel_set_encoding (priv->spool_io, NULL, &tmp_error);
456
457   if (tmp_error != NULL)
458     {
459       g_propagate_error (error, tmp_error);
460       return FALSE;
461     }
462
463   return TRUE;
464 }
465
466 /**
467  * gtk_print_job_get_surface:
468  * @job: a #GtkPrintJob
469  * @error: (allow-none): return location for errors, or %NULL
470  * 
471  * Gets a cairo surface onto which the pages of
472  * the print job should be rendered.
473  * 
474  * Return value: the cairo surface of @job
475  *
476  * Since: 2.10
477  **/
478 cairo_surface_t *
479 gtk_print_job_get_surface (GtkPrintJob  *job,
480                            GError      **error)
481 {
482   GtkPrintJobPrivate *priv;
483   gchar *filename;
484   gdouble width, height;
485   GtkPaperSize *paper_size;
486   int fd;
487   GError *tmp_error;
488
489   tmp_error = NULL;
490
491   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
492
493   priv = job->priv;
494
495   if (priv->surface)
496     return priv->surface;
497  
498   g_return_val_if_fail (priv->spool_io == NULL, NULL);
499  
500   fd = g_file_open_tmp ("gtkprint_XXXXXX", 
501                          &filename, 
502                          &tmp_error);
503   if (fd == -1)
504     {
505       g_free (filename);
506       g_propagate_error (error, tmp_error);
507       return NULL;
508     }
509
510   fchmod (fd, S_IRUSR | S_IWUSR);
511   
512 #ifdef G_ENABLE_DEBUG 
513   /* If we are debugging printing don't delete the tmp files */
514   if (!(gtk_get_debug_flags () & GTK_DEBUG_PRINTING))
515 #endif /* G_ENABLE_DEBUG */
516   g_unlink (filename);
517   g_free (filename);
518
519   paper_size = gtk_page_setup_get_paper_size (priv->page_setup);
520   width = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
521   height = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
522  
523   priv->spool_io = g_io_channel_unix_new (fd);
524   g_io_channel_set_close_on_unref (priv->spool_io, TRUE);
525   g_io_channel_set_encoding (priv->spool_io, NULL, &tmp_error);
526   
527   if (tmp_error != NULL)
528     {
529       g_io_channel_unref (priv->spool_io);
530       priv->spool_io = NULL;
531       g_propagate_error (error, tmp_error);
532       return NULL;
533     }
534
535   priv->surface = _gtk_printer_create_cairo_surface (priv->printer,
536                                                      priv->settings,
537                                                      width, height,
538                                                      priv->spool_io);
539   
540   return priv->surface;
541 }
542
543 /**
544  * gtk_print_job_set_track_print_status:
545  * @job: a #GtkPrintJob
546  * @track_status: %TRUE to track status after printing
547  * 
548  * If track_status is %TRUE, the print job will try to continue report
549  * on the status of the print job in the printer queues and printer. This
550  * can allow your application to show things like "out of paper" issues,
551  * and when the print job actually reaches the printer.
552  * 
553  * This function is often implemented using some form of polling, so it should
554  * not be enabled unless needed.
555  *
556  * Since: 2.10
557  */
558 void
559 gtk_print_job_set_track_print_status (GtkPrintJob *job,
560                                       gboolean     track_status)
561 {
562   GtkPrintJobPrivate *priv;
563
564   g_return_if_fail (GTK_IS_PRINT_JOB (job));
565
566   priv = job->priv;
567
568   track_status = track_status != FALSE;
569
570   if (priv->track_print_status != track_status)
571     {
572       priv->track_print_status = track_status;
573       
574       g_object_notify (G_OBJECT (job), "track-print-status");
575     }
576 }
577
578 /**
579  * gtk_print_job_get_track_print_status:
580  * @job: a #GtkPrintJob
581  *
582  * Returns wheter jobs will be tracked after printing.
583  * For details, see gtk_print_job_set_track_print_status().
584  *
585  * Return value: %TRUE if print job status will be reported after printing
586  *
587  * Since: 2.10
588  */
589 gboolean
590 gtk_print_job_get_track_print_status (GtkPrintJob *job)
591 {
592   GtkPrintJobPrivate *priv;
593
594   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
595
596   priv = job->priv;
597   
598   return priv->track_print_status;
599 }
600
601 static void
602 gtk_print_job_set_property (GObject      *object,
603                             guint         prop_id,
604                             const GValue *value,
605                             GParamSpec   *pspec)
606
607 {
608   GtkPrintJob *job = GTK_PRINT_JOB (object);
609   GtkPrintJobPrivate *priv = job->priv;
610   GtkPrintSettings *settings;
611
612   switch (prop_id)
613     {
614     case PROP_TITLE:
615       g_free (priv->title);
616       priv->title = g_value_dup_string (value);
617       break;
618     
619     case PROP_PRINTER:
620       priv->printer = GTK_PRINTER (g_value_dup_object (value));
621       priv->printer_set = TRUE;
622       priv->backend = g_object_ref (gtk_printer_get_backend (priv->printer));
623       break;
624
625     case PROP_PAGE_SETUP:
626       priv->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
627       priv->page_setup_set = TRUE;
628       break;
629       
630     case PROP_SETTINGS:
631       /* We save a copy of the settings since we modify
632        * if when preparing the printer job. */
633       settings = GTK_PRINT_SETTINGS (g_value_get_object (value));
634       priv->settings = gtk_print_settings_copy (settings);
635       priv->settings_set = TRUE;
636       break;
637
638     case PROP_TRACK_PRINT_STATUS:
639       gtk_print_job_set_track_print_status (job, g_value_get_boolean (value));
640       break;
641
642     default:
643       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
644       break;
645     }
646 }
647
648 static void
649 gtk_print_job_get_property (GObject    *object,
650                             guint       prop_id,
651                             GValue     *value,
652                             GParamSpec *pspec)
653 {
654   GtkPrintJob *job = GTK_PRINT_JOB (object);
655   GtkPrintJobPrivate *priv = job->priv;
656
657   switch (prop_id)
658     {
659     case PROP_TITLE:
660       g_value_set_string (value, priv->title);
661       break;
662     case PROP_PRINTER:
663       g_value_set_object (value, priv->printer);
664       break;
665     case PROP_SETTINGS:
666       g_value_set_object (value, priv->settings);
667       break;
668     case PROP_PAGE_SETUP:
669       g_value_set_object (value, priv->page_setup);
670       break;
671     case PROP_TRACK_PRINT_STATUS:
672       g_value_set_boolean (value, priv->track_print_status);
673       break;
674     default:
675       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
676       break;
677     }
678 }
679
680 /**
681  * gtk_print_job_send:
682  * @job: a GtkPrintJob
683  * @callback: function to call when the job completes or an error occurs
684  * @user_data: user data that gets passed to @callback
685  * @dnotify: destroy notify for @user_data
686  * 
687  * Sends the print job off to the printer.  
688  * 
689  * Since: 2.10
690  **/
691 void
692 gtk_print_job_send (GtkPrintJob             *job,
693                     GtkPrintJobCompleteFunc  callback,
694                     gpointer                 user_data,
695                     GDestroyNotify           dnotify)
696 {
697   GtkPrintJobPrivate *priv;
698
699   g_return_if_fail (GTK_IS_PRINT_JOB (job));
700
701   priv = job->priv;
702   g_return_if_fail (priv->spool_io != NULL);
703   
704   gtk_print_job_set_status (job, GTK_PRINT_STATUS_SENDING_DATA);
705   
706   g_io_channel_seek_position (priv->spool_io, 0, G_SEEK_SET, NULL);
707   
708   gtk_print_backend_print_stream (priv->backend, job,
709                                   priv->spool_io,
710                                   callback, user_data, dnotify);
711 }
712
713 /**
714  * gtk_print_job_get_pages:
715  * @job: a #GtkPrintJob
716  *
717  * Gets the #GtkPrintPages setting for this job.
718  *
719  * Returns: the #GtkPrintPages setting
720  *
721  * Since: 3.0
722  */
723 GtkPrintPages
724 gtk_print_job_get_pages (GtkPrintJob *job)
725 {
726   return job->priv->print_pages;
727 }
728
729 /**
730  * gtk_print_job_set_pages:
731  * @job: a #GtkPrintJob
732  * @pages: the #GtkPrintPages setting
733  *
734  * Sets the #GtkPrintPages setting for this job.
735  *
736  * Since: 3.0
737  */
738 void
739 gtk_print_job_set_pages (GtkPrintJob   *job,
740                          GtkPrintPages  pages)
741 {
742   job->priv->print_pages = pages;
743 }
744
745 /**
746  * gtk_print_job_get_page_ranges:
747  * @job: a #GtkPrintJob
748  * @n_ranges: (out): return location for the number of ranges
749  *
750  * Gets the page ranges for this job.
751  *
752  * Returns: a pointer to an array of #GtkPageRange structs
753  *
754  * Since: 3.0
755  */
756 GtkPageRange *
757 gtk_print_job_get_page_ranges (GtkPrintJob *job,
758                                gint        *n_ranges)
759 {
760   *n_ranges = job->priv->num_page_ranges;
761   return job->priv->page_ranges;
762 }
763
764 /**
765  * gtk_print_job_set_page_ranges:
766  * @job: a #GtkPrintJob
767  * @ranges: pointer to an array of #GtkPageRange structs
768  * @n_ranges: the length of the @ranges array
769  *
770  * Sets the page ranges for this job.
771  *
772  * Since: 3.0
773  */
774 void
775 gtk_print_job_set_page_ranges (GtkPrintJob  *job,
776                                GtkPageRange *ranges,
777                                gint          n_ranges)
778 {
779   job->priv->page_ranges = ranges;
780   job->priv->num_page_ranges = n_ranges;
781 }
782
783 /**
784  * gtk_print_job_get_page_set:
785  * @job: a #GtkPrintJob
786  *
787  * Gets the #GtkPageSet setting for this job.
788  *
789  * Returns: the #GtkPageSet setting
790  *
791  * Since: 3.0
792  */
793 GtkPageSet
794 gtk_print_job_get_page_set (GtkPrintJob *job)
795 {
796   return job->priv->page_set;
797 }
798
799 /**
800  * gtk_print_job_set_page_set:
801  * @job: a #GtkPrintJob
802  * @page_set: a #GtkPageSet setting
803  *
804  * Sets the #GtkPageSet setting for this job.
805  *
806  * Since: 3.0
807  */
808 void
809 gtk_print_job_set_page_set (GtkPrintJob *job,
810                             GtkPageSet   page_set)
811 {
812   job->priv->page_set = page_set;
813 }
814
815 /**
816  * gtk_print_job_get_num_copies:
817  * @job: a #GtkPrintJob
818  *
819  * Gets the number of copies of this job.
820  *
821  * Returns: the number of copies
822  *
823  * Since: 3.0
824  */
825 gint
826 gtk_print_job_get_num_copies (GtkPrintJob *job)
827 {
828   return job->priv->num_copies;
829 }
830
831 /**
832  * gtk_print_job_set_num_copies:
833  * @job: a #GtkPrintJob
834  * @num_copies: the number of copies
835  *
836  * Sets the number of copies for this job.
837  *
838  * Since: 3.0
839  */
840 void
841 gtk_print_job_set_num_copies (GtkPrintJob *job,
842                               gint         num_copies)
843 {
844   job->priv->num_copies = num_copies;
845 }
846
847 /**
848  * gtk_print_job_get_scale:
849  * @job: a #GtkPrintJob
850  *
851  * Gets the scale for this job (where 1.0 means unscaled).
852  *
853  * Returns: the scale
854  *
855  * Since: 3.0
856  */
857 gdouble
858 gtk_print_job_get_scale (GtkPrintJob *job)
859
860 {
861   return job->priv->scale;
862 }
863
864 /**
865  * gtk_print_job_set_scale:
866  * @job: a #GtkPrintJob
867  * @scale: the scale
868  *
869  * Sets the scale for this job (where 1.0 means unscaled).
870  *
871  * Since: 3.0
872  */
873 void
874 gtk_print_job_set_scale (GtkPrintJob *job,
875                          gdouble      scale)
876 {
877   job->priv->scale = scale;
878 }
879
880 /**
881  * gtk_print_job_get_n_up:
882  * @job: a #GtkPrintJob
883  *
884  * Gets the n-up setting for this job.
885  *
886  * Returns: the n-up setting
887  *
888  * Since: 3.0
889  */
890 guint
891 gtk_print_job_get_n_up (GtkPrintJob *job)
892 {
893   return job->priv->number_up;
894 }
895
896 /**
897  * gtk_print_job_set_n_up:
898  * @job: a #GtkPrintJob
899  * @n_up: the n-up value
900  *
901  * Sets the n-up setting for this job.
902  *
903  * Since: 3.0
904  */
905 void
906 gtk_print_job_set_n_up (GtkPrintJob *job,
907                         guint        n_up)
908 {
909   job->priv->number_up = n_up;
910 }
911
912 /**
913  * gtk_print_job_get_n_up_layout:
914  * @job: a #GtkPrintJob
915  *
916  * Gets the n-up layout setting for this job.
917  *
918  * Returns: the n-up layout
919  *
920  * Since: 3.0
921  */
922 GtkNumberUpLayout
923 gtk_print_job_get_n_up_layout (GtkPrintJob *job)
924 {
925   return job->priv->number_up_layout;
926 }
927
928 /**
929  * gtk_print_job_set_n_up_layout:
930  * @job: a #GtkPrintJob
931  * @layout: the n-up layout setting
932  *
933  * Sets the n-up layout setting for this job.
934  *
935  * Since: 3.0
936  */
937 void
938 gtk_print_job_set_n_up_layout (GtkPrintJob       *job,
939                                GtkNumberUpLayout  layout)
940 {
941   job->priv->number_up_layout = layout;
942 }
943
944 /**
945  * gtk_print_job_get_rotate:
946  * @job: a #GtkPrintJob
947  *
948  * Gets whether the job is printed rotated.
949  *
950  * Returns: whether the job is printed rotated
951  *
952  * Since: 3.0
953  */
954 gboolean
955 gtk_print_job_get_rotate (GtkPrintJob *job)
956 {
957   return job->priv->rotate_to_orientation;
958 }
959
960 /**
961  * gtk_print_job_set_rotate:
962  * @job: a #GtkPrintJob
963  * @rotate: whether to print rotated
964  *
965  * Sets whether this job is printed rotated.
966  *
967  * Since: 3.0
968  */
969 void
970 gtk_print_job_set_rotate (GtkPrintJob *job,
971                           gboolean     rotate)
972 {
973   job->priv->rotate_to_orientation = rotate;
974 }
975
976 /**
977  * gtk_print_job_get_collate:
978  * @job: a #GtkPrintJob
979  *
980  * Gets whether this job is printed collated.
981  *
982  * Returns: whether the job is printed collated
983  *
984  * Since: 3.0
985  */
986 gboolean
987 gtk_print_job_get_collate (GtkPrintJob *job)
988 {
989   return job->priv->collate;
990 }
991
992 /**
993  * gtk_print_job_set_collated:
994  * @job: a #GtkPrintJob
995  * @collate: whether the job is printed collated
996  *
997  * Sets whether this job is printed collated.
998  *
999  * Since: 3.0
1000  */
1001 void
1002 gtk_print_job_set_collate (GtkPrintJob *job,
1003                            gboolean     collate)
1004 {
1005   job->priv->collate = collate;
1006 }
1007
1008 /**
1009  * gtk_print_job_get_reverse:
1010  * @job: a #GtkPrintJob
1011  *
1012  * Gets whether this job is printed reversed.
1013  *
1014  * Returns: whether the job is printed reversed.
1015  *
1016  * Since: 3.0
1017  */
1018 gboolean
1019 gtk_print_job_get_reverse (GtkPrintJob *job)
1020 {
1021   return job->priv->reverse;
1022 }
1023
1024 /**
1025  * gtk_print_job_set_reverse:
1026  * @job: a #GtkPrintJob
1027  * @reverse: whether the job is printed reversed
1028  *
1029  * Sets whether this job is printed reversed.
1030  *
1031  * Since: 3.0
1032  */
1033 void
1034 gtk_print_job_set_reverse (GtkPrintJob *job,
1035                            gboolean     reverse)
1036 {
1037   job->priv->reverse = reverse;
1038 }