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-01-19 00:00:34 +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"
|
2019-05-26 20:29:57 +00:00
|
|
|
|
#include "gtkprinterprivate.h"
|
2019-05-26 21:57:23 +00:00
|
|
|
|
#include "gtkprintbackendprivate.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
#ifndef O_BINARY
|
|
|
|
|
#define O_BINARY 0
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-05-26 21:51:24 +00:00
|
|
|
|
typedef struct _GtkPrintJobClass GtkPrintJobClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkPrintJob
|
|
|
|
|
{
|
|
|
|
|
GObject parent_instance;
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
struct _GtkPrintJobClass
|
|
|
|
|
{
|
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
|
|
|
|
|
void (*status_changed) (GtkPrintJob *job);
|
|
|
|
|
};
|
|
|
|
|
|
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 };
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
G_DEFINE_TYPE (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.
|
|
|
|
|
*/
|
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,
|
2019-05-29 20:48:33 +00:00
|
|
|
|
NULL,
|
2006-05-16 16:13:48 +00:00
|
|
|
|
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
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->spool_io = NULL;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->title = g_strdup ("");
|
|
|
|
|
job->surface = NULL;
|
|
|
|
|
job->backend = NULL;
|
|
|
|
|
job->printer = NULL;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->printer_set = FALSE;
|
|
|
|
|
job->settings_set = FALSE;
|
|
|
|
|
job->page_setup_set = FALSE;
|
|
|
|
|
job->status = GTK_PRINT_STATUS_INITIAL;
|
|
|
|
|
job->track_print_status = FALSE;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->print_pages = GTK_PRINT_PAGES_ALL;
|
|
|
|
|
job->page_ranges = NULL;
|
|
|
|
|
job->num_page_ranges = 0;
|
|
|
|
|
job->collate = FALSE;
|
|
|
|
|
job->reverse = FALSE;
|
|
|
|
|
job->num_copies = 1;
|
|
|
|
|
job->scale = 1.0;
|
|
|
|
|
job->page_set = GTK_PAGE_SET_ALL;
|
|
|
|
|
job->rotate_to_orientation = FALSE;
|
|
|
|
|
job->number_up = 1;
|
|
|
|
|
job->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);
|
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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_assert (job->printer_set &&
|
|
|
|
|
job->settings_set &&
|
|
|
|
|
job->page_setup_set);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
_gtk_printer_prepare_for_print (job->printer,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
job,
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->settings,
|
|
|
|
|
job->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);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->surface)
|
|
|
|
|
cairo_surface_destroy (job->surface);
|
2012-10-03 17:24:52 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->backend)
|
|
|
|
|
g_object_unref (job->backend);
|
2012-10-03 17:24:52 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->spool_io != NULL)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_io_channel_unref (job->spool_io);
|
|
|
|
|
job->spool_io = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->printer)
|
|
|
|
|
g_object_unref (job->printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->settings)
|
|
|
|
|
g_object_unref (job->settings);
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->page_setup)
|
|
|
|
|
g_object_unref (job->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_free (job->page_ranges);
|
|
|
|
|
job->page_ranges = NULL;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_free (job->title);
|
|
|
|
|
job->title = NULL;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
**/
|
|
|
|
|
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
|
|
|
|
*/
|
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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->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
|
|
|
|
*/
|
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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->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
|
|
|
|
*/
|
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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->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
|
|
|
|
*/
|
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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->status;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_status (GtkPrintJob *job,
|
|
|
|
|
GtkPrintStatus status)
|
|
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_JOB (job));
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->status == status)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->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
|
|
|
|
|
**/
|
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-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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->spool_io = g_io_channel_new_file (filename, "r", &tmp_error);
|
2006-06-21 18:16:58 +00:00
|
|
|
|
|
|
|
|
|
if (tmp_error == NULL)
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_io_channel_set_encoding (job->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
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->spool_io = g_io_channel_unix_new (fd);
|
|
|
|
|
if (g_io_channel_set_encoding (job->spool_io, NULL, error) != G_IO_STATUS_NORMAL)
|
2016-07-04 04:04:38 +00:00
|
|
|
|
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
|
|
|
|
**/
|
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
|
|
|
|
{
|
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);
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->surface)
|
|
|
|
|
return job->surface;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_return_val_if_fail (job->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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
paper_size = gtk_page_setup_get_paper_size (job->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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->spool_io = g_io_channel_unix_new (fd);
|
|
|
|
|
g_io_channel_set_close_on_unref (job->spool_io, TRUE);
|
|
|
|
|
g_io_channel_set_encoding (job->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)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_io_channel_unref (job->spool_io);
|
|
|
|
|
job->spool_io = NULL;
|
2006-06-21 18:16:58 +00:00
|
|
|
|
g_propagate_error (error, tmp_error);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->surface = _gtk_printer_create_cairo_surface (job->printer,
|
|
|
|
|
job->settings,
|
2006-06-12 04:39:55 +00:00
|
|
|
|
width, height,
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->spool_io);
|
2006-06-21 18:16:58 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->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.
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_JOB (job));
|
|
|
|
|
|
2006-06-12 04:39:55 +00:00
|
|
|
|
track_status = track_status != FALSE;
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
if (job->track_print_status != track_status)
|
2006-06-12 04:39:55 +00:00
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->track_print_status = track_status;
|
2006-06-12 04:39:55 +00:00
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_track_print_status (GtkPrintJob *job)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
|
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->track_print_status;
|
2006-05-15 16:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
GtkPrintSettings *settings;
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_TITLE:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_free (job->title);
|
|
|
|
|
job->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:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->printer = GTK_PRINTER (g_value_dup_object (value));
|
|
|
|
|
job->printer_set = TRUE;
|
|
|
|
|
job->backend = g_object_ref (gtk_printer_get_backend (job->printer));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_PAGE_SETUP:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
|
|
|
|
|
job->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));
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->settings = gtk_print_settings_copy (settings);
|
|
|
|
|
job->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);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_TITLE:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_value_set_string (value, job->title);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_PRINTER:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_value_set_object (value, job->printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_SETTINGS:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_value_set_object (value, job->settings);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_PAGE_SETUP:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_value_set_object (value, job->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-20 20:58:08 +00:00
|
|
|
|
case PROP_TRACK_PRINT_STATUS:
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_value_set_boolean (value, job->track_print_status);
|
2006-06-20 20:58:08 +00:00
|
|
|
|
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
|
2020-01-13 01:26:50 +00:00
|
|
|
|
* @user_data: (closure): user data that gets passed to @callback
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* @dnotify: destroy notify for @user_data
|
|
|
|
|
*
|
|
|
|
|
* Sends the print job off to the printer.
|
|
|
|
|
**/
|
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-06-21 18:16:58 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_JOB (job));
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_return_if_fail (job->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
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_io_channel_seek_position (job->spool_io, 0, G_SEEK_SET, NULL);
|
2006-06-21 18:16:58 +00:00
|
|
|
|
|
2020-03-28 19:55:15 +00:00
|
|
|
|
gtk_print_backend_print_stream (job->backend, job,
|
|
|
|
|
job->spool_io,
|
2006-06-21 18:16:58 +00:00
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
GtkPrintPages
|
|
|
|
|
gtk_print_job_get_pages (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->print_pages;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_pages:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @pages: the #GtkPrintPages setting
|
|
|
|
|
*
|
|
|
|
|
* Sets the #GtkPrintPages setting for this job.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_pages (GtkPrintJob *job,
|
|
|
|
|
GtkPrintPages pages)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->print_pages = pages;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
GtkPageRange *
|
|
|
|
|
gtk_print_job_get_page_ranges (GtkPrintJob *job,
|
|
|
|
|
gint *n_ranges)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
*n_ranges = job->num_page_ranges;
|
|
|
|
|
return job->page_ranges;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_page_ranges (GtkPrintJob *job,
|
|
|
|
|
GtkPageRange *ranges,
|
|
|
|
|
gint n_ranges)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
g_free (job->page_ranges);
|
|
|
|
|
job->page_ranges = ranges;
|
|
|
|
|
job->num_page_ranges = n_ranges;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_page_set:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the #GtkPageSet setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #GtkPageSet setting
|
|
|
|
|
*/
|
|
|
|
|
GtkPageSet
|
|
|
|
|
gtk_print_job_get_page_set (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->page_set;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_page_set:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @page_set: a #GtkPageSet setting
|
|
|
|
|
*
|
|
|
|
|
* Sets the #GtkPageSet setting for this job.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_page_set (GtkPrintJob *job,
|
|
|
|
|
GtkPageSet page_set)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->page_set = page_set;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_num_copies:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the number of copies of this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of copies
|
|
|
|
|
*/
|
|
|
|
|
gint
|
|
|
|
|
gtk_print_job_get_num_copies (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->num_copies;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_num_copies:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @num_copies: the number of copies
|
|
|
|
|
*
|
|
|
|
|
* Sets the number of copies for this job.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_num_copies (GtkPrintJob *job,
|
|
|
|
|
gint num_copies)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->num_copies = num_copies;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_scale:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the scale for this job (where 1.0 means unscaled).
|
|
|
|
|
*
|
|
|
|
|
* Returns: the scale
|
|
|
|
|
*/
|
|
|
|
|
gdouble
|
|
|
|
|
gtk_print_job_get_scale (GtkPrintJob *job)
|
|
|
|
|
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->scale;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_scale:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @scale: the scale
|
|
|
|
|
*
|
|
|
|
|
* Sets the scale for this job (where 1.0 means unscaled).
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_scale (GtkPrintJob *job,
|
|
|
|
|
gdouble scale)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->scale = scale;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_n_up:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the n-up setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the n-up setting
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gtk_print_job_get_n_up (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->number_up;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_n_up:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @n_up: the n-up value
|
|
|
|
|
*
|
|
|
|
|
* Sets the n-up setting for this job.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_n_up (GtkPrintJob *job,
|
|
|
|
|
guint n_up)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->number_up = n_up;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_n_up_layout:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets the n-up layout setting for this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the n-up layout
|
|
|
|
|
*/
|
|
|
|
|
GtkNumberUpLayout
|
|
|
|
|
gtk_print_job_get_n_up_layout (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->number_up_layout;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_n_up_layout (GtkPrintJob *job,
|
|
|
|
|
GtkNumberUpLayout layout)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->number_up_layout = layout;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_rotate:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets whether the job is printed rotated.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the job is printed rotated
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_rotate (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->rotate_to_orientation;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_rotate:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @rotate: whether to print rotated
|
|
|
|
|
*
|
|
|
|
|
* Sets whether this job is printed rotated.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_rotate (GtkPrintJob *job,
|
|
|
|
|
gboolean rotate)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->rotate_to_orientation = rotate;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_collate:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets whether this job is printed collated.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the job is printed collated
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_collate (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->collate;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
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.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_collate (GtkPrintJob *job,
|
|
|
|
|
gboolean collate)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->collate = collate;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_get_reverse:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
*
|
|
|
|
|
* Gets whether this job is printed reversed.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the job is printed reversed.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_get_reverse (GtkPrintJob *job)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
return job->reverse;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_print_job_set_reverse:
|
|
|
|
|
* @job: a #GtkPrintJob
|
|
|
|
|
* @reverse: whether the job is printed reversed
|
|
|
|
|
*
|
|
|
|
|
* Sets whether this job is printed reversed.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_reverse (GtkPrintJob *job,
|
|
|
|
|
gboolean reverse)
|
|
|
|
|
{
|
2020-03-28 19:55:15 +00:00
|
|
|
|
job->reverse = reverse;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
}
|