]> Pileus Git - ~andy/gtk/blob - gtk/gtkprintjob.c
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
16  */
17
18 /**
19  * SECTION:gtkprintjob
20  * @Title: GtkPrintJob
21  * @Short_description: Represents a print job
22  *
23  * A #GtkPrintJob object represents a job that is sent to a
24  * printer. You only need to deal directly with print jobs if
25  * you use the non-portable #GtkPrintUnixDialog API.
26  *
27  * Use gtk_print_job_get_surface() to obtain the cairo surface
28  * onto which the pages must be drawn. Use gtk_print_job_send()
29  * to send the finished job to the printer. If you don't use cairo
30  * #GtkPrintJob also supports printing of manually generated postscript,
31  * via gtk_print_job_set_source_file().
32  */
33 #include "config.h"
34 #include <stdlib.h>
35 #include <string.h>
36 #include <stdio.h>
37 #include <fcntl.h>
38 #include <errno.h>
39 #ifdef HAVE_UNISTD_H
40 #include <unistd.h>
41 #endif
42 #include <sys/types.h>
43 #include <sys/stat.h>
44
45 #include <glib/gstdio.h>
46 #include "gtkintl.h"
47 #include "gtkprivate.h"
48
49 #include "gtkprintjob.h"
50 #include "gtkprinter.h"
51 #include "gtkprinter-private.h"
52 #include "gtkprintbackend.h"
53
54 #ifndef O_BINARY
55 #define O_BINARY 0
56 #endif
57
58 struct _GtkPrintJobPrivate
59 {
60   gchar *title;
61
62   GIOChannel *spool_io;
63   cairo_surface_t *surface;
64
65   GtkPrintStatus status;
66   GtkPrintBackend *backend;
67   GtkPrinter *printer;
68   GtkPrintSettings *settings;
69   GtkPageSetup *page_setup;
70
71   GtkPrintPages print_pages;
72   GtkPageRange *page_ranges;
73   gint num_page_ranges;
74   GtkPageSet page_set;
75   gint num_copies;
76   gdouble scale;
77   guint number_up;
78   GtkNumberUpLayout number_up_layout;
79
80   guint printer_set           : 1;
81   guint page_setup_set        : 1;
82   guint settings_set          : 1;
83   guint track_print_status    : 1;
84   guint rotate_to_orientation : 1;
85   guint collate               : 1;
86   guint reverse               : 1;
87 };
88
89 #define GTK_PRINT_JOB_GET_PRIVATE(o)  \
90    (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINT_JOB, GtkPrintJobPrivate))
91
92 static void     gtk_print_job_finalize     (GObject               *object);
93 static void     gtk_print_job_set_property (GObject               *object,
94                                             guint                  prop_id,
95                                             const GValue          *value,
96                                             GParamSpec            *pspec);
97 static void     gtk_print_job_get_property (GObject               *object,
98                                             guint                  prop_id,
99                                             GValue                *value,
100                                             GParamSpec            *pspec);
101 static GObject* gtk_print_job_constructor  (GType                  type,
102                                             guint                  n_construct_properties,
103                                             GObjectConstructParam *construct_params);
104
105 enum {
106   STATUS_CHANGED,
107   LAST_SIGNAL
108 };
109
110 enum {
111   PROP_0,
112   PROP_TITLE,
113   PROP_PRINTER,
114   PROP_PAGE_SETUP,
115   PROP_SETTINGS,
116   PROP_TRACK_PRINT_STATUS
117 };
118
119 static guint signals[LAST_SIGNAL] = { 0 };
120
121 G_DEFINE_TYPE (GtkPrintJob, gtk_print_job, G_TYPE_OBJECT)
122
123 static void
124 gtk_print_job_class_init (GtkPrintJobClass *class)
125 {
126   GObjectClass *object_class;
127   object_class = (GObjectClass *) class;
128
129   object_class->finalize = gtk_print_job_finalize;
130   object_class->constructor = gtk_print_job_constructor;
131   object_class->set_property = gtk_print_job_set_property;
132   object_class->get_property = gtk_print_job_get_property;
133
134   g_type_class_add_private (class, sizeof (GtkPrintJobPrivate));
135
136   g_object_class_install_property (object_class,
137                                    PROP_TITLE,
138                                    g_param_spec_string ("title",
139                                                         P_("Title"),
140                                                         P_("Title of the print job"),
141                                                         NULL,
142                                                         GTK_PARAM_READWRITE |
143                                                         G_PARAM_CONSTRUCT_ONLY));
144
145   g_object_class_install_property (object_class,
146                                    PROP_PRINTER,
147                                    g_param_spec_object ("printer",
148                                                         P_("Printer"),
149                                                         P_("Printer to print the job to"),
150                                                         GTK_TYPE_PRINTER,
151                                                         GTK_PARAM_READWRITE |
152                                                         G_PARAM_CONSTRUCT_ONLY));
153
154   g_object_class_install_property (object_class,
155                                    PROP_SETTINGS,
156                                    g_param_spec_object ("settings",
157                                                         P_("Settings"),
158                                                         P_("Printer settings"),
159                                                         GTK_TYPE_PRINT_SETTINGS,
160                                                         GTK_PARAM_READWRITE |
161                                                         G_PARAM_CONSTRUCT_ONLY));
162
163   g_object_class_install_property (object_class,
164                                    PROP_PAGE_SETUP,
165                                    g_param_spec_object ("page-setup",
166                                                         P_("Page Setup"),
167                                                         P_("Page Setup"),
168                                                         GTK_TYPE_PAGE_SETUP,
169                                                         GTK_PARAM_READWRITE |
170                                                         G_PARAM_CONSTRUCT_ONLY));
171
172   g_object_class_install_property (object_class,
173                                    PROP_TRACK_PRINT_STATUS,
174                                    g_param_spec_boolean ("track-print-status",
175                                                          P_("Track Print Status"),
176                                                          P_("TRUE if the print job will continue to emit "
177                                                             "status-changed signals after the print data "
178                                                             "has been sent to the printer or print server."),
179                                                          FALSE,
180                                                          GTK_PARAM_READWRITE));
181   
182
183   /**
184    * GtkPrintJob::status-changed:
185    * @job: the #GtkPrintJob object on which the signal was emitted
186    *
187    * Gets emitted when the status of a job changes. The signal handler
188    * can use gtk_print_job_get_status() to obtain the new status.
189    *
190    * Since: 2.10
191    */
192   signals[STATUS_CHANGED] =
193     g_signal_new (I_("status-changed"),
194                   G_TYPE_FROM_CLASS (class),
195                   G_SIGNAL_RUN_LAST,
196                   G_STRUCT_OFFSET (GtkPrintJobClass, status_changed),
197                   NULL, NULL,
198                   g_cclosure_marshal_VOID__VOID,
199                   G_TYPE_NONE, 0);
200 }
201
202 static void
203 gtk_print_job_init (GtkPrintJob *job)
204 {
205   GtkPrintJobPrivate *priv;
206
207   priv = job->priv = GTK_PRINT_JOB_GET_PRIVATE (job);
208
209   priv->spool_io = NULL;
210
211   priv->title = g_strdup ("");
212   priv->surface = NULL;
213   priv->backend = NULL;
214   priv->printer = NULL;
215
216   priv->printer_set = FALSE;
217   priv->settings_set = FALSE;
218   priv->page_setup_set = FALSE;
219   priv->status = GTK_PRINT_STATUS_INITIAL;
220   priv->track_print_status = FALSE;
221
222   priv->print_pages = GTK_PRINT_PAGES_ALL;
223   priv->page_ranges = NULL;
224   priv->num_page_ranges = 0;
225   priv->collate = FALSE;
226   priv->reverse = FALSE;
227   priv->num_copies = 1;
228   priv->scale = 1.0;
229   priv->page_set = GTK_PAGE_SET_ALL;
230   priv->rotate_to_orientation = FALSE;
231   priv->number_up = 1;
232   priv->number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
233 }
234
235
236 static GObject*
237 gtk_print_job_constructor (GType                  type,
238                            guint                  n_construct_properties,
239                            GObjectConstructParam *construct_params)
240 {
241   GtkPrintJob *job;
242   GtkPrintJobPrivate *priv;
243   GObject *object;
244
245   object =
246     G_OBJECT_CLASS (gtk_print_job_parent_class)->constructor (type,
247                                                               n_construct_properties,
248                                                               construct_params);
249
250   job = GTK_PRINT_JOB (object);
251
252   priv = job->priv;
253   g_assert (priv->printer_set &&
254             priv->settings_set &&
255             priv->page_setup_set);
256   
257   _gtk_printer_prepare_for_print (priv->printer,
258                                   job,
259                                   priv->settings,
260                                   priv->page_setup);
261
262   return object;
263 }
264
265
266 static void
267 gtk_print_job_finalize (GObject *object)
268 {
269   GtkPrintJob *job = GTK_PRINT_JOB (object);
270   GtkPrintJobPrivate *priv = job->priv;
271
272   if (priv->spool_io != NULL)
273     {
274       g_io_channel_unref (priv->spool_io);
275       priv->spool_io = NULL;
276     }
277
278   if (priv->backend)
279     g_object_unref (priv->backend);
280
281   if (priv->printer)
282     g_object_unref (priv->printer);
283
284   if (priv->surface)
285     cairo_surface_destroy (priv->surface);
286
287   if (priv->settings)
288     g_object_unref (priv->settings);
289
290   if (priv->page_setup)
291     g_object_unref (priv->page_setup);
292
293   g_free (priv->page_ranges);
294   priv->page_ranges = NULL;
295
296   g_free (priv->title);
297   priv->title = NULL;
298
299   G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize (object);
300 }
301
302 /**
303  * gtk_print_job_new:
304  * @title: the job title
305  * @printer: a #GtkPrinter
306  * @settings: a #GtkPrintSettings
307  * @page_setup: a #GtkPageSetup
308  *
309  * Creates a new #GtkPrintJob.
310  *
311  * Return value: a new #GtkPrintJob
312  *
313  * Since: 2.10
314  **/
315 GtkPrintJob *
316 gtk_print_job_new (const gchar      *title,
317                    GtkPrinter       *printer,
318                    GtkPrintSettings *settings,
319                    GtkPageSetup     *page_setup)
320 {
321   GObject *result;
322   result = g_object_new (GTK_TYPE_PRINT_JOB,
323                          "title", title,
324                          "printer", printer,
325                          "settings", settings,
326                          "page-setup", page_setup,
327                          NULL);
328   return (GtkPrintJob *) result;
329 }
330
331 /**
332  * gtk_print_job_get_settings:
333  * @job: a #GtkPrintJob
334  * 
335  * Gets the #GtkPrintSettings of the print job.
336  * 
337  * Return value: (transfer none): the settings of @job
338  *
339  * Since: 2.10
340  */
341 GtkPrintSettings *
342 gtk_print_job_get_settings (GtkPrintJob *job)
343 {
344   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
345   
346   return job->priv->settings;
347 }
348
349 /**
350  * gtk_print_job_get_printer:
351  * @job: a #GtkPrintJob
352  * 
353  * Gets the #GtkPrinter of the print job.
354  * 
355  * Return value: (transfer none): the printer of @job
356  *
357  * Since: 2.10
358  */
359 GtkPrinter *
360 gtk_print_job_get_printer (GtkPrintJob *job)
361 {
362   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
363   
364   return job->priv->printer;
365 }
366
367 /**
368  * gtk_print_job_get_title:
369  * @job: a #GtkPrintJob
370  * 
371  * Gets the job title.
372  * 
373  * Return value: the title of @job
374  *
375  * Since: 2.10
376  */
377 const gchar *
378 gtk_print_job_get_title (GtkPrintJob *job)
379 {
380   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
381   
382   return job->priv->title;
383 }
384
385 /**
386  * gtk_print_job_get_status:
387  * @job: a #GtkPrintJob
388  * 
389  * Gets the status of the print job.
390  * 
391  * Return value: the status of @job
392  *
393  * Since: 2.10
394  */
395 GtkPrintStatus
396 gtk_print_job_get_status (GtkPrintJob *job)
397 {
398   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), GTK_PRINT_STATUS_FINISHED);
399   
400   return job->priv->status;
401 }
402
403 void
404 gtk_print_job_set_status (GtkPrintJob   *job,
405                           GtkPrintStatus status)
406 {
407   GtkPrintJobPrivate *priv;
408
409   g_return_if_fail (GTK_IS_PRINT_JOB (job));
410
411   priv = job->priv;
412
413   if (priv->status == status)
414     return;
415
416   priv->status = status;
417   g_signal_emit (job, signals[STATUS_CHANGED], 0);
418 }
419
420 /**
421  * gtk_print_job_set_source_file:
422  * @job: a #GtkPrintJob
423  * @filename: (type filename): the file to be printed
424  * @error: return location for errors
425  * 
426  * Make the #GtkPrintJob send an existing document to the 
427  * printing system. The file can be in any format understood
428  * by the platforms printing system (typically PostScript,
429  * but on many platforms PDF may work too). See 
430  * gtk_printer_accepts_pdf() and gtk_printer_accepts_ps().
431  * 
432  * Returns: %FALSE if an error occurred
433  *
434  * Since: 2.10
435  **/
436 gboolean
437 gtk_print_job_set_source_file (GtkPrintJob *job,
438                                const gchar *filename,
439                                GError     **error)
440 {
441   GtkPrintJobPrivate *priv;
442   GError *tmp_error;
443
444   tmp_error = NULL;
445
446   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
447
448   priv = job->priv;
449
450   priv->spool_io = g_io_channel_new_file (filename, "r", &tmp_error);
451
452   if (tmp_error == NULL)
453     g_io_channel_set_encoding (priv->spool_io, NULL, &tmp_error);
454
455   if (tmp_error != NULL)
456     {
457       g_propagate_error (error, tmp_error);
458       return FALSE;
459     }
460
461   return TRUE;
462 }
463
464 /**
465  * gtk_print_job_get_surface:
466  * @job: a #GtkPrintJob
467  * @error: (allow-none): return location for errors, or %NULL
468  * 
469  * Gets a cairo surface onto which the pages of
470  * the print job should be rendered.
471  * 
472  * Return value: (transfer none): the cairo surface of @job
473  *
474  * Since: 2.10
475  **/
476 cairo_surface_t *
477 gtk_print_job_get_surface (GtkPrintJob  *job,
478                            GError      **error)
479 {
480   GtkPrintJobPrivate *priv;
481   gchar *filename;
482   gdouble width, height;
483   GtkPaperSize *paper_size;
484   int fd;
485   GError *tmp_error;
486
487   tmp_error = NULL;
488
489   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
490
491   priv = job->priv;
492
493   if (priv->surface)
494     return priv->surface;
495  
496   g_return_val_if_fail (priv->spool_io == NULL, NULL);
497  
498   fd = g_file_open_tmp ("gtkprint_XXXXXX", 
499                          &filename, 
500                          &tmp_error);
501   if (fd == -1)
502     {
503       g_free (filename);
504       g_propagate_error (error, tmp_error);
505       return NULL;
506     }
507
508   fchmod (fd, S_IRUSR | S_IWUSR);
509   
510 #ifdef G_ENABLE_DEBUG 
511   /* If we are debugging printing don't delete the tmp files */
512   if (!(gtk_get_debug_flags () & GTK_DEBUG_PRINTING))
513 #endif /* G_ENABLE_DEBUG */
514   g_unlink (filename);
515   g_free (filename);
516
517   paper_size = gtk_page_setup_get_paper_size (priv->page_setup);
518   width = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
519   height = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
520  
521   priv->spool_io = g_io_channel_unix_new (fd);
522   g_io_channel_set_close_on_unref (priv->spool_io, TRUE);
523   g_io_channel_set_encoding (priv->spool_io, NULL, &tmp_error);
524   
525   if (tmp_error != NULL)
526     {
527       g_io_channel_unref (priv->spool_io);
528       priv->spool_io = NULL;
529       g_propagate_error (error, tmp_error);
530       return NULL;
531     }
532
533   priv->surface = _gtk_printer_create_cairo_surface (priv->printer,
534                                                      priv->settings,
535                                                      width, height,
536                                                      priv->spool_io);
537   
538   return priv->surface;
539 }
540
541 /**
542  * gtk_print_job_set_track_print_status:
543  * @job: a #GtkPrintJob
544  * @track_status: %TRUE to track status after printing
545  * 
546  * If track_status is %TRUE, the print job will try to continue report
547  * on the status of the print job in the printer queues and printer. This
548  * can allow your application to show things like "out of paper" issues,
549  * and when the print job actually reaches the printer.
550  * 
551  * This function is often implemented using some form of polling, so it should
552  * not be enabled unless needed.
553  *
554  * Since: 2.10
555  */
556 void
557 gtk_print_job_set_track_print_status (GtkPrintJob *job,
558                                       gboolean     track_status)
559 {
560   GtkPrintJobPrivate *priv;
561
562   g_return_if_fail (GTK_IS_PRINT_JOB (job));
563
564   priv = job->priv;
565
566   track_status = track_status != FALSE;
567
568   if (priv->track_print_status != track_status)
569     {
570       priv->track_print_status = track_status;
571       
572       g_object_notify (G_OBJECT (job), "track-print-status");
573     }
574 }
575
576 /**
577  * gtk_print_job_get_track_print_status:
578  * @job: a #GtkPrintJob
579  *
580  * Returns wheter jobs will be tracked after printing.
581  * For details, see gtk_print_job_set_track_print_status().
582  *
583  * Return value: %TRUE if print job status will be reported after printing
584  *
585  * Since: 2.10
586  */
587 gboolean
588 gtk_print_job_get_track_print_status (GtkPrintJob *job)
589 {
590   GtkPrintJobPrivate *priv;
591
592   g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
593
594   priv = job->priv;
595   
596   return priv->track_print_status;
597 }
598
599 static void
600 gtk_print_job_set_property (GObject      *object,
601                             guint         prop_id,
602                             const GValue *value,
603                             GParamSpec   *pspec)
604
605 {
606   GtkPrintJob *job = GTK_PRINT_JOB (object);
607   GtkPrintJobPrivate *priv = job->priv;
608   GtkPrintSettings *settings;
609
610   switch (prop_id)
611     {
612     case PROP_TITLE:
613       g_free (priv->title);
614       priv->title = g_value_dup_string (value);
615       break;
616     
617     case PROP_PRINTER:
618       priv->printer = GTK_PRINTER (g_value_dup_object (value));
619       priv->printer_set = TRUE;
620       priv->backend = g_object_ref (gtk_printer_get_backend (priv->printer));
621       break;
622
623     case PROP_PAGE_SETUP:
624       priv->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
625       priv->page_setup_set = TRUE;
626       break;
627       
628     case PROP_SETTINGS:
629       /* We save a copy of the settings since we modify
630        * if when preparing the printer job. */
631       settings = GTK_PRINT_SETTINGS (g_value_get_object (value));
632       priv->settings = gtk_print_settings_copy (settings);
633       priv->settings_set = TRUE;
634       break;
635
636     case PROP_TRACK_PRINT_STATUS:
637       gtk_print_job_set_track_print_status (job, g_value_get_boolean (value));
638       break;
639
640     default:
641       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
642       break;
643     }
644 }
645
646 static void
647 gtk_print_job_get_property (GObject    *object,
648                             guint       prop_id,
649                             GValue     *value,
650                             GParamSpec *pspec)
651 {
652   GtkPrintJob *job = GTK_PRINT_JOB (object);
653   GtkPrintJobPrivate *priv = job->priv;
654
655   switch (prop_id)
656     {
657     case PROP_TITLE:
658       g_value_set_string (value, priv->title);
659       break;
660     case PROP_PRINTER:
661       g_value_set_object (value, priv->printer);
662       break;
663     case PROP_SETTINGS:
664       g_value_set_object (value, priv->settings);
665       break;
666     case PROP_PAGE_SETUP:
667       g_value_set_object (value, priv->page_setup);
668       break;
669     case PROP_TRACK_PRINT_STATUS:
670       g_value_set_boolean (value, priv->track_print_status);
671       break;
672     default:
673       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
674       break;
675     }
676 }
677
678 /**
679  * gtk_print_job_send:
680  * @job: a GtkPrintJob
681  * @callback: function to call when the job completes or an error occurs
682  * @user_data: user data that gets passed to @callback
683  * @dnotify: destroy notify for @user_data
684  * 
685  * Sends the print job off to the printer.  
686  * 
687  * Since: 2.10
688  **/
689 void
690 gtk_print_job_send (GtkPrintJob             *job,
691                     GtkPrintJobCompleteFunc  callback,
692                     gpointer                 user_data,
693                     GDestroyNotify           dnotify)
694 {
695   GtkPrintJobPrivate *priv;
696
697   g_return_if_fail (GTK_IS_PRINT_JOB (job));
698
699   priv = job->priv;
700   g_return_if_fail (priv->spool_io != NULL);
701   
702   gtk_print_job_set_status (job, GTK_PRINT_STATUS_SENDING_DATA);
703   
704   g_io_channel_seek_position (priv->spool_io, 0, G_SEEK_SET, NULL);
705   
706   gtk_print_backend_print_stream (priv->backend, job,
707                                   priv->spool_io,
708                                   callback, user_data, dnotify);
709 }
710
711 /**
712  * gtk_print_job_get_pages:
713  * @job: a #GtkPrintJob
714  *
715  * Gets the #GtkPrintPages setting for this job.
716  *
717  * Returns: the #GtkPrintPages setting
718  *
719  * Since: 3.0
720  */
721 GtkPrintPages
722 gtk_print_job_get_pages (GtkPrintJob *job)
723 {
724   return job->priv->print_pages;
725 }
726
727 /**
728  * gtk_print_job_set_pages:
729  * @job: a #GtkPrintJob
730  * @pages: the #GtkPrintPages setting
731  *
732  * Sets the #GtkPrintPages setting for this job.
733  *
734  * Since: 3.0
735  */
736 void
737 gtk_print_job_set_pages (GtkPrintJob   *job,
738                          GtkPrintPages  pages)
739 {
740   job->priv->print_pages = pages;
741 }
742
743 /**
744  * gtk_print_job_get_page_ranges:
745  * @job: a #GtkPrintJob
746  * @n_ranges: (out): return location for the number of ranges
747  *
748  * Gets the page ranges for this job.
749  *
750  * Returns: (array length=n_ranges) (transfer none): a pointer to an
751  * array of #GtkPageRange structs
752  *
753  * Since: 3.0
754  */
755 GtkPageRange *
756 gtk_print_job_get_page_ranges (GtkPrintJob *job,
757                                gint        *n_ranges)
758 {
759   *n_ranges = job->priv->num_page_ranges;
760   return job->priv->page_ranges;
761 }
762
763 /**
764  * gtk_print_job_set_page_ranges:
765  * @job: a #GtkPrintJob
766  * @ranges: (array length=n_ranges): pointer to an array of
767  *    #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_collate:
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 }