2006-04-21 15:09:32 +00:00
|
|
|
|
/* GtkPrintJob
|
|
|
|
|
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2011-01-14 23:39:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkprintjob
|
|
|
|
|
* @Title: GtkPrintJob
|
|
|
|
|
* @Short_description: Represents a print job
|
2019-03-13 17:39:33 +00:00
|
|
|
|
* @Include: gtk/gtkunixprint.h
|
2011-01-14 23:39:01 +00:00
|
|
|
|
*
|
|
|
|
|
* A #GtkPrintJob object represents a job that is sent to a
|
|
|
|
|
* printer. You only need to deal directly with print jobs if
|
|
|
|
|
* you use the non-portable #GtkPrintUnixDialog API.
|
|
|
|
|
*
|
|
|
|
|
* Use gtk_print_job_get_surface() to obtain the cairo surface
|
|
|
|
|
* onto which the pages must be drawn. Use gtk_print_job_send()
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* to send the finished job to the printer. If you don’t use cairo
|
2011-01-14 23:39:01 +00:00
|
|
|
|
* #GtkPrintJob also supports printing of manually generated postscript,
|
|
|
|
|
* via gtk_print_job_set_source_file().
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
|
|
|
|
|
#include "gtkprintjob.h"
|
|
|
|
|
#include "gtkprinter.h"
|
2006-06-08 17:01:28 +00:00
|
|
|
|
#include "gtkprinter-private.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include "gtkprintbackend.h"
|
|
|
|
|
|
|
|
|
|
#ifndef O_BINARY
|
|
|
|
|
#define O_BINARY 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
struct _GtkPrintJobPrivate
|
|
|
|
|
{
|
|
|
|
|
gchar *title;
|
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
GIOChannel *spool_io;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
|
|
|
|
|
GtkPrintStatus status;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
GtkPrintBackend *backend;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrinter *printer;
|
|
|
|
|
GtkPrintSettings *settings;
|
|
|
|
|
GtkPageSetup *page_setup;
|
|
|
|
|
|
2010-12-18 22:45:31 +00:00
|
|
|
|
GtkPrintPages print_pages;
|
|
|
|
|
GtkPageRange *page_ranges;
|
|
|
|
|
gint num_page_ranges;
|
|
|
|
|
GtkPageSet page_set;
|
|
|
|
|
gint num_copies;
|
|
|
|
|
gdouble scale;
|
|
|
|
|
guint number_up;
|
|
|
|
|
GtkNumberUpLayout number_up_layout;
|
|
|
|
|
|
|
|
|
|
guint printer_set : 1;
|
|
|
|
|
guint page_setup_set : 1;
|
|
|
|
|
guint settings_set : 1;
|
|
|
|
|
guint track_print_status : 1;
|
|
|
|
|
guint rotate_to_orientation : 1;
|
|
|
|
|
guint collate : 1;
|
|
|
|
|
guint reverse : 1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void gtk_print_job_finalize (GObject *object);
|
|
|
|
|
static void gtk_print_job_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_print_job_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void gtk_print_job_constructed (GObject *object);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
STATUS_CHANGED,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
2006-06-20 20:58:08 +00:00
|
|
|
|
PROP_TITLE,
|
|
|
|
|
PROP_PRINTER,
|
|
|
|
|
PROP_PAGE_SETUP,
|
|
|
|
|
PROP_SETTINGS,
|
|
|
|
|
PROP_TRACK_PRINT_STATUS
|
2006-04-21 15:09:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkPrintJob, gtk_print_job, G_TYPE_OBJECT)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_job_class_init (GtkPrintJobClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
object_class = (GObjectClass *) class;
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gtk_print_job_finalize;
|
2014-06-26 22:22:42 +00:00
|
|
|
|
object_class->constructed = gtk_print_job_constructed;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
object_class->set_property = gtk_print_job_set_property;
|
|
|
|
|
object_class->get_property = gtk_print_job_get_property;
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_TITLE,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_param_spec_string ("title",
|
|
|
|
|
P_("Title"),
|
|
|
|
|
P_("Title of the print job"),
|
|
|
|
|
NULL,
|
|
|
|
|
GTK_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_PRINTER,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_param_spec_object ("printer",
|
|
|
|
|
P_("Printer"),
|
|
|
|
|
P_("Printer to print the job to"),
|
|
|
|
|
GTK_TYPE_PRINTER,
|
|
|
|
|
GTK_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_SETTINGS,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_param_spec_object ("settings",
|
|
|
|
|
P_("Settings"),
|
|
|
|
|
P_("Printer settings"),
|
|
|
|
|
GTK_TYPE_PRINT_SETTINGS,
|
|
|
|
|
GTK_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_PAGE_SETUP,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_param_spec_object ("page-setup",
|
|
|
|
|
P_("Page Setup"),
|
|
|
|
|
P_("Page Setup"),
|
|
|
|
|
GTK_TYPE_PAGE_SETUP,
|
|
|
|
|
GTK_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_TRACK_PRINT_STATUS,
|
|
|
|
|
g_param_spec_boolean ("track-print-status",
|
|
|
|
|
P_("Track Print Status"),
|
|
|
|
|
P_("TRUE if the print job will continue to emit "
|
|
|
|
|
"status-changed signals after the print data "
|
|
|
|
|
"has been sent to the printer or print server."),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintJob::status-changed:
|
|
|
|
|
* @job: the #GtkPrintJob object on which the signal was emitted
|
|
|
|
|
*
|
|
|
|
|
* Gets emitted when the status of a job changes. The signal handler
|
|
|
|
|
* can use gtk_print_job_get_status() to obtain the new status.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
signals[STATUS_CHANGED] =
|
2006-05-16 16:13:48 +00:00
|
|
|
|
g_signal_new (I_("status-changed"),
|
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkPrintJobClass, status_changed),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_init (GtkPrintJob *job)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJobPrivate *priv;
|
2006-04-24 03:47:22 +00:00
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
priv = job->priv = gtk_print_job_get_instance_private (job);
|
2006-04-24 03:47:22 +00:00
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
priv->spool_io = NULL;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
|
|
|
|
priv->title = g_strdup ("");
|
|
|
|
|
priv->surface = NULL;
|
|
|
|
|
priv->backend = NULL;
|
|
|
|
|
priv->printer = NULL;
|
|
|
|
|
|
|
|
|
|
priv->printer_set = FALSE;
|
|
|
|
|
priv->settings_set = FALSE;
|
|
|
|
|
priv->page_setup_set = FALSE;
|
|
|
|
|
priv->status = GTK_PRINT_STATUS_INITIAL;
|
2006-05-15 16:22:38 +00:00
|
|
|
|
priv->track_print_status = FALSE;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
|
|
|
|
priv->print_pages = GTK_PRINT_PAGES_ALL;
|
|
|
|
|
priv->page_ranges = NULL;
|
|
|
|
|
priv->num_page_ranges = 0;
|
|
|
|
|
priv->collate = FALSE;
|
|
|
|
|
priv->reverse = FALSE;
|
|
|
|
|
priv->num_copies = 1;
|
|
|
|
|
priv->scale = 1.0;
|
|
|
|
|
priv->page_set = GTK_PAGE_SET_ALL;
|
|
|
|
|
priv->rotate_to_orientation = FALSE;
|
|
|
|
|
priv->number_up = 1;
|
|
|
|
|
priv->number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_print_job_constructed (GObject *object)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2014-06-26 22:22:42 +00:00
|
|
|
|
GtkPrintJob *job = GTK_PRINT_JOB (object);
|
|
|
|
|
GtkPrintJobPrivate *priv = job->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_print_job_parent_class)->constructed (object);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
|
|
|
|
g_assert (priv->printer_set &&
|
|
|
|
|
priv->settings_set &&
|
|
|
|
|
priv->page_setup_set);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
_gtk_printer_prepare_for_print (priv->printer,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
job,
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->settings,
|
|
|
|
|
priv->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_job_finalize (GObject *object)
|
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJob *job = GTK_PRINT_JOB (object);
|
|
|
|
|
GtkPrintJobPrivate *priv = job->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2012-10-03 17:24:52 +00:00
|
|
|
|
if (priv->surface)
|
|
|
|
|
cairo_surface_destroy (priv->surface);
|
|
|
|
|
|
|
|
|
|
if (priv->backend)
|
|
|
|
|
g_object_unref (priv->backend);
|
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
if (priv->spool_io != NULL)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-06-21 18:16:58 +00:00
|
|
|
|
g_io_channel_unref (priv->spool_io);
|
|
|
|
|
priv->spool_io = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->printer)
|
|
|
|
|
g_object_unref (priv->printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->settings)
|
|
|
|
|
g_object_unref (priv->settings);
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->page_setup)
|
|
|
|
|
g_object_unref (priv->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2010-12-18 22:45:31 +00:00
|
|
|
|
g_free (priv->page_ranges);
|
|
|
|
|
priv->page_ranges = NULL;
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_free (priv->title);
|
|
|
|
|
priv->title = NULL;
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize (object);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_new:
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* @title: the job title
|
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
|
* @settings: a #GtkPrintSettings
|
|
|
|
|
* @page_setup: a #GtkPageSetup
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkPrintJob.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: a new #GtkPrintJob
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Since: 2.10
|
2006-04-21 15:09:32 +00:00
|
|
|
|
**/
|
|
|
|
|
GtkPrintJob *
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_new (const gchar *title,
|
|
|
|
|
GtkPrinter *printer,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintSettings *settings,
|
2006-04-24 03:47:22 +00:00
|
|
|
|
GtkPageSetup *page_setup)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
GObject *result;
|
|
|
|
|
result = g_object_new (GTK_TYPE_PRINT_JOB,
|
|
|
|
|
"title", title,
|
|
|
|
|
"printer", printer,
|
|
|
|
|
"settings", settings,
|
|
|
|
|
"page-setup", page_setup,
|
|
|
|
|
NULL);
|
|
|
|
|
return (GtkPrintJob *) result;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_settings:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the #GtkPrintSettings of the print job.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): the settings of @job
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintSettings *
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_get_settings (GtkPrintJob *job)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
return job->priv->settings;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_printer:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the #GtkPrinter of the print job.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): the printer of @job
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrinter *
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_get_printer (GtkPrintJob *job)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
return job->priv->printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_title:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the job title.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the title of @job
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
2011-06-06 18:13:44 +00:00
|
|
|
|
const gchar *
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_get_title (GtkPrintJob *job)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
return job->priv->title;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_status:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the status of the print job.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the status of @job
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintStatus
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_get_status (GtkPrintJob *job)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), GTK_PRINT_STATUS_FINISHED);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
return job->priv->status;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_status (GtkPrintJob *job,
|
|
|
|
|
GtkPrintStatus status)
|
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJobPrivate *priv;
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_JOB (job));
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv = job->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->status == status)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->status = status;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_signal_emit (job, signals[STATUS_CHANGED], 0);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-25 15:36:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_source_file:
|
|
|
|
|
* @job: a #GtkPrintJob
|
2011-01-18 05:42:31 +00:00
|
|
|
|
* @filename: (type filename): the file to be printed
|
2006-04-25 15:36:54 +00:00
|
|
|
|
* @error: return location for errors
|
|
|
|
|
*
|
|
|
|
|
* Make the #GtkPrintJob send an existing document to the
|
|
|
|
|
* printing system. The file can be in any format understood
|
|
|
|
|
* by the platforms printing system (typically PostScript,
|
2006-06-20 18:22:49 +00:00
|
|
|
|
* but on many platforms PDF may work too). See
|
|
|
|
|
* gtk_printer_accepts_pdf() and gtk_printer_accepts_ps().
|
2006-04-25 15:36:54 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: %FALSE if an error occurred
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_set_source_file (GtkPrintJob *job,
|
2006-04-24 03:47:22 +00:00
|
|
|
|
const gchar *filename,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJobPrivate *priv;
|
2006-06-21 18:16:58 +00:00
|
|
|
|
GError *tmp_error;
|
|
|
|
|
|
|
|
|
|
tmp_error = NULL;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
|
|
|
|
priv = job->priv;
|
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
priv->spool_io = g_io_channel_new_file (filename, "r", &tmp_error);
|
|
|
|
|
|
|
|
|
|
if (tmp_error == NULL)
|
|
|
|
|
g_io_channel_set_encoding (priv->spool_io, NULL, &tmp_error);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
if (tmp_error != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_propagate_error (error, tmp_error);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2006-06-21 18:16:58 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-04 04:04:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_source_fd:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @fd: a file descriptor
|
|
|
|
|
* @error: return location for errors
|
|
|
|
|
*
|
|
|
|
|
* Make the #GtkPrintJob send an existing document to the
|
|
|
|
|
* printing system. The file can be in any format understood
|
|
|
|
|
* by the platforms printing system (typically PostScript,
|
|
|
|
|
* but on many platforms PDF may work too). See
|
|
|
|
|
* gtk_printer_accepts_pdf() and gtk_printer_accepts_ps().
|
|
|
|
|
*
|
|
|
|
|
* This is similar to gtk_print_job_set_source_file(),
|
|
|
|
|
* but takes expects an open file descriptor for the file,
|
|
|
|
|
* instead of a filename.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %FALSE if an error occurred
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.22
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_set_source_fd (GtkPrintJob *job,
|
|
|
|
|
int fd,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
|
|
|
|
|
g_return_val_if_fail (fd >= 0, FALSE);
|
|
|
|
|
|
|
|
|
|
job->priv->spool_io = g_io_channel_unix_new (fd);
|
|
|
|
|
if (g_io_channel_set_encoding (job->priv->spool_io, NULL, error) != G_IO_STATUS_NORMAL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_surface:
|
|
|
|
|
* @job: a #GtkPrintJob
|
2010-02-19 16:53:17 +00:00
|
|
|
|
* @error: (allow-none): return location for errors, or %NULL
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets a cairo surface onto which the pages of
|
|
|
|
|
* the print job should be rendered.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): the cairo surface of @job
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
cairo_surface_t *
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_get_surface (GtkPrintJob *job,
|
|
|
|
|
GError **error)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJobPrivate *priv;
|
2014-03-14 14:36:10 +00:00
|
|
|
|
gchar *filename = NULL;
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gdouble width, height;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPaperSize *paper_size;
|
2006-06-21 18:16:58 +00:00
|
|
|
|
int fd;
|
|
|
|
|
GError *tmp_error;
|
|
|
|
|
|
|
|
|
|
tmp_error = NULL;
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv = job->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->surface)
|
|
|
|
|
return priv->surface;
|
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
g_return_val_if_fail (priv->spool_io == NULL, NULL);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
fd = g_file_open_tmp ("gtkprint_XXXXXX",
|
|
|
|
|
&filename,
|
|
|
|
|
&tmp_error);
|
|
|
|
|
if (fd == -1)
|
|
|
|
|
{
|
2007-04-29 04:58:20 +00:00
|
|
|
|
g_free (filename);
|
2006-06-21 18:16:58 +00:00
|
|
|
|
g_propagate_error (error, tmp_error);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
fchmod (fd, S_IRUSR | S_IWUSR);
|
|
|
|
|
|
2015-09-09 02:48:44 +00:00
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
2006-06-21 18:16:58 +00:00
|
|
|
|
/* If we are debugging printing don't delete the tmp files */
|
2015-09-09 02:48:44 +00:00
|
|
|
|
if (GTK_DEBUG_CHECK (PRINTING)) ;
|
|
|
|
|
else
|
2006-06-21 18:16:58 +00:00
|
|
|
|
#endif /* G_ENABLE_DEBUG */
|
2007-04-30 04:55:25 +00:00
|
|
|
|
g_unlink (filename);
|
2007-04-29 04:58:20 +00:00
|
|
|
|
g_free (filename);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
paper_size = gtk_page_setup_get_paper_size (priv->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
|
|
|
|
|
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
|
2006-06-21 18:16:58 +00:00
|
|
|
|
|
|
|
|
|
priv->spool_io = g_io_channel_unix_new (fd);
|
|
|
|
|
g_io_channel_set_close_on_unref (priv->spool_io, TRUE);
|
|
|
|
|
g_io_channel_set_encoding (priv->spool_io, NULL, &tmp_error);
|
2006-04-24 03:47:22 +00:00
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
if (tmp_error != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_io_channel_unref (priv->spool_io);
|
|
|
|
|
priv->spool_io = NULL;
|
|
|
|
|
g_propagate_error (error, tmp_error);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->surface = _gtk_printer_create_cairo_surface (priv->printer,
|
2006-06-16 22:59:39 +00:00
|
|
|
|
priv->settings,
|
2006-06-12 04:39:55 +00:00
|
|
|
|
width, height,
|
2006-06-21 18:16:58 +00:00
|
|
|
|
priv->spool_io);
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
return priv->surface;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-15 16:22:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_track_print_status:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @track_status: %TRUE to track status after printing
|
|
|
|
|
*
|
|
|
|
|
* If track_status is %TRUE, the print job will try to continue report
|
|
|
|
|
* on the status of the print job in the printer queues and printer. This
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* can allow your application to show things like “out of paper” issues,
|
2006-05-15 16:22:38 +00:00
|
|
|
|
* and when the print job actually reaches the printer.
|
|
|
|
|
*
|
|
|
|
|
* This function is often implemented using some form of polling, so it should
|
|
|
|
|
* not be enabled unless needed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_track_print_status (GtkPrintJob *job,
|
2006-06-12 04:39:55 +00:00
|
|
|
|
gboolean track_status)
|
2006-05-15 16:22:38 +00:00
|
|
|
|
{
|
|
|
|
|
GtkPrintJobPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_JOB (job));
|
|
|
|
|
|
|
|
|
|
priv = job->priv;
|
|
|
|
|
|
2006-06-12 04:39:55 +00:00
|
|
|
|
track_status = track_status != FALSE;
|
|
|
|
|
|
|
|
|
|
if (priv->track_print_status != track_status)
|
|
|
|
|
{
|
|
|
|
|
priv->track_print_status = track_status;
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
g_object_notify (G_OBJECT (job), "track-print-status");
|
2006-06-12 04:39:55 +00:00
|
|
|
|
}
|
2006-05-15 16:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_track_print_status:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Returns wheter jobs will be tracked after printing.
|
|
|
|
|
* For details, see gtk_print_job_set_track_print_status().
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if print job status will be reported after printing
|
2006-05-15 16:22:38 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_track_print_status (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintJobPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = job->priv;
|
|
|
|
|
|
|
|
|
|
return priv->track_print_status;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_print_job_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
GtkPrintJob *job = GTK_PRINT_JOB (object);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJobPrivate *priv = job->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintSettings *settings;
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_TITLE:
|
2008-08-29 18:14:32 +00:00
|
|
|
|
g_free (priv->title);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->title = g_value_dup_string (value);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_PRINTER:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->printer = GTK_PRINTER (g_value_dup_object (value));
|
|
|
|
|
priv->printer_set = TRUE;
|
|
|
|
|
priv->backend = g_object_ref (gtk_printer_get_backend (priv->printer));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_PAGE_SETUP:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
|
|
|
|
|
priv->page_setup_set = TRUE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_SETTINGS:
|
2006-04-21 15:09:32 +00:00
|
|
|
|
/* We save a copy of the settings since we modify
|
|
|
|
|
* if when preparing the printer job. */
|
|
|
|
|
settings = GTK_PRINT_SETTINGS (g_value_get_object (value));
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->settings = gtk_print_settings_copy (settings);
|
|
|
|
|
priv->settings_set = TRUE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_TRACK_PRINT_STATUS:
|
|
|
|
|
gtk_print_job_set_track_print_status (job, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_job_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintJob *job = GTK_PRINT_JOB (object);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJobPrivate *priv = job->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_TITLE:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_value_set_string (value, priv->title);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_PRINTER:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_value_set_object (value, priv->printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_SETTINGS:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_value_set_object (value, priv->settings);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_PAGE_SETUP:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_value_set_object (value, priv->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_TRACK_PRINT_STATUS:
|
|
|
|
|
g_value_set_boolean (value, priv->track_print_status);
|
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_send:
|
|
|
|
|
* @job: a GtkPrintJob
|
2006-07-17 03:06:24 +00:00
|
|
|
|
* @callback: function to call when the job completes or an error occurs
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* @user_data: user data that gets passed to @callback
|
|
|
|
|
* @dnotify: destroy notify for @user_data
|
|
|
|
|
*
|
|
|
|
|
* Sends the print job off to the printer.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
**/
|
2006-06-21 18:16:58 +00:00
|
|
|
|
void
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_print_job_send (GtkPrintJob *job,
|
|
|
|
|
GtkPrintJobCompleteFunc callback,
|
|
|
|
|
gpointer user_data,
|
2006-06-21 18:16:58 +00:00
|
|
|
|
GDestroyNotify dnotify)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
|
GtkPrintJobPrivate *priv;
|
|
|
|
|
|
2006-06-21 18:16:58 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_JOB (job));
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
|
|
|
|
priv = job->priv;
|
2006-06-21 18:16:58 +00:00
|
|
|
|
g_return_if_fail (priv->spool_io != NULL);
|
2006-04-24 03:47:22 +00:00
|
|
|
|
|
|
|
|
|
gtk_print_job_set_status (job, GTK_PRINT_STATUS_SENDING_DATA);
|
2006-06-21 18:16:58 +00:00
|
|
|
|
|
|
|
|
|
g_io_channel_seek_position (priv->spool_io, 0, G_SEEK_SET, NULL);
|
|
|
|
|
|
2006-06-21 05:56:14 +00:00
|
|
|
|
gtk_print_backend_print_stream (priv->backend, job,
|
2006-06-21 18:16:58 +00:00
|
|
|
|
priv->spool_io,
|
|
|
|
|
callback, user_data, dnotify);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_pages:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the #GtkPrintPages setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #GtkPrintPages setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
GtkPrintPages
|
|
|
|
|
gtk_print_job_get_pages (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->print_pages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_pages:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @pages: the #GtkPrintPages setting
|
|
|
|
|
*
|
|
|
|
|
* Sets the #GtkPrintPages setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_pages (GtkPrintJob *job,
|
|
|
|
|
GtkPrintPages pages)
|
|
|
|
|
{
|
|
|
|
|
job->priv->print_pages = pages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_page_ranges:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @n_ranges: (out): return location for the number of ranges
|
|
|
|
|
*
|
|
|
|
|
* Gets the page ranges for this job.
|
|
|
|
|
*
|
2011-01-18 09:10:30 +00:00
|
|
|
|
* Returns: (array length=n_ranges) (transfer none): a pointer to an
|
|
|
|
|
* array of #GtkPageRange structs
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
GtkPageRange *
|
|
|
|
|
gtk_print_job_get_page_ranges (GtkPrintJob *job,
|
|
|
|
|
gint *n_ranges)
|
|
|
|
|
{
|
|
|
|
|
*n_ranges = job->priv->num_page_ranges;
|
|
|
|
|
return job->priv->page_ranges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_page_ranges:
|
|
|
|
|
* @job: a #GtkPrintJob
|
2017-03-24 15:41:47 +00:00
|
|
|
|
* @ranges: (array length=n_ranges) (transfer full): pointer to an array of
|
2011-02-09 04:14:46 +00:00
|
|
|
|
* #GtkPageRange structs
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @n_ranges: the length of the @ranges array
|
|
|
|
|
*
|
|
|
|
|
* Sets the page ranges for this job.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_page_ranges (GtkPrintJob *job,
|
|
|
|
|
GtkPageRange *ranges,
|
|
|
|
|
gint n_ranges)
|
|
|
|
|
{
|
2017-03-24 15:41:47 +00:00
|
|
|
|
g_free (job->priv->page_ranges);
|
2010-12-18 22:45:31 +00:00
|
|
|
|
job->priv->page_ranges = ranges;
|
|
|
|
|
job->priv->num_page_ranges = n_ranges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_page_set:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the #GtkPageSet setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #GtkPageSet setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
GtkPageSet
|
|
|
|
|
gtk_print_job_get_page_set (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->page_set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_page_set:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @page_set: a #GtkPageSet setting
|
|
|
|
|
*
|
|
|
|
|
* Sets the #GtkPageSet setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_page_set (GtkPrintJob *job,
|
|
|
|
|
GtkPageSet page_set)
|
|
|
|
|
{
|
|
|
|
|
job->priv->page_set = page_set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_num_copies:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the number of copies of this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of copies
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
gint
|
|
|
|
|
gtk_print_job_get_num_copies (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->num_copies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_num_copies:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @num_copies: the number of copies
|
|
|
|
|
*
|
|
|
|
|
* Sets the number of copies for this job.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_num_copies (GtkPrintJob *job,
|
|
|
|
|
gint num_copies)
|
|
|
|
|
{
|
|
|
|
|
job->priv->num_copies = num_copies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_scale:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the scale for this job (where 1.0 means unscaled).
|
|
|
|
|
*
|
|
|
|
|
* Returns: the scale
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
gdouble
|
|
|
|
|
gtk_print_job_get_scale (GtkPrintJob *job)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
return job->priv->scale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_scale:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @scale: the scale
|
|
|
|
|
*
|
|
|
|
|
* Sets the scale for this job (where 1.0 means unscaled).
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_scale (GtkPrintJob *job,
|
|
|
|
|
gdouble scale)
|
|
|
|
|
{
|
|
|
|
|
job->priv->scale = scale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_n_up:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the n-up setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the n-up setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gtk_print_job_get_n_up (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->number_up;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_n_up:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @n_up: the n-up value
|
|
|
|
|
*
|
|
|
|
|
* Sets the n-up setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_n_up (GtkPrintJob *job,
|
|
|
|
|
guint n_up)
|
|
|
|
|
{
|
|
|
|
|
job->priv->number_up = n_up;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_n_up_layout:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the n-up layout setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the n-up layout
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
GtkNumberUpLayout
|
|
|
|
|
gtk_print_job_get_n_up_layout (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->number_up_layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_n_up_layout:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @layout: the n-up layout setting
|
|
|
|
|
*
|
|
|
|
|
* Sets the n-up layout setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_n_up_layout (GtkPrintJob *job,
|
|
|
|
|
GtkNumberUpLayout layout)
|
|
|
|
|
{
|
|
|
|
|
job->priv->number_up_layout = layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_rotate:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets whether the job is printed rotated.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the job is printed rotated
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_rotate (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->rotate_to_orientation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_rotate:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @rotate: whether to print rotated
|
|
|
|
|
*
|
|
|
|
|
* Sets whether this job is printed rotated.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_rotate (GtkPrintJob *job,
|
|
|
|
|
gboolean rotate)
|
|
|
|
|
{
|
|
|
|
|
job->priv->rotate_to_orientation = rotate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_collate:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets whether this job is printed collated.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the job is printed collated
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_collate (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->collate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-02-09 04:14:46 +00:00
|
|
|
|
* gtk_print_job_set_collate:
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @collate: whether the job is printed collated
|
|
|
|
|
*
|
|
|
|
|
* Sets whether this job is printed collated.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_collate (GtkPrintJob *job,
|
|
|
|
|
gboolean collate)
|
|
|
|
|
{
|
|
|
|
|
job->priv->collate = collate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_reverse:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets whether this job is printed reversed.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the job is printed reversed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_reverse (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
return job->priv->reverse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_reverse:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @reverse: whether the job is printed reversed
|
|
|
|
|
*
|
|
|
|
|
* Sets whether this job is printed reversed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.0
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_reverse (GtkPrintJob *job,
|
|
|
|
|
gboolean reverse)
|
|
|
|
|
{
|
|
|
|
|
job->priv->reverse = reverse;
|
|
|
|
|
}
|