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
|
|
|
|
/**
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* GtkPrintJob:
|
2011-01-14 23:39:01 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* A `GtkPrintJob` object represents a job that is sent to a printer.
|
2011-01-14 23:39:01 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* You only need to deal directly with print jobs if you use the
|
|
|
|
|
* non-portable [class@Gtk.PrintUnixDialog] API.
|
|
|
|
|
*
|
|
|
|
|
* Use [method@Gtk.PrintJob.get_surface] to obtain the cairo surface
|
|
|
|
|
* onto which the pages must be drawn. Use [method@Gtk.PrintJob.send]
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* to send the finished job to the printer. If you don’t use cairo
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* `GtkPrintJob` also supports printing of manually generated PostScript,
|
|
|
|
|
* via [method@Gtk.PrintJob.set_source_file].
|
2011-01-14 23:39:01 +00:00
|
|
|
|
*/
|
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;
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *title;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
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;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int num_page_ranges;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
GtkPageSet page_set;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int num_copies;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double scale;
|
2010-12-18 22:45:31 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2021-02-27 15:54:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintJob:title: (attributes org.gtk.Property.get=gtk_print_job_get_title)
|
|
|
|
|
*
|
|
|
|
|
* The title of the print job.
|
|
|
|
|
*/
|
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));
|
|
|
|
|
|
2021-02-27 15:54:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintJob:printer: (attributes org.gtk.Property.get=gtk_print_job_get_printer)
|
|
|
|
|
*
|
|
|
|
|
* The printer to send the job to.
|
|
|
|
|
*/
|
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));
|
|
|
|
|
|
2021-02-27 15:54:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintJob:settings: (attributes org.gtk.Property.get=gtk_print_job_get_settings)
|
|
|
|
|
*
|
|
|
|
|
* Printer settings.
|
|
|
|
|
*/
|
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));
|
|
|
|
|
|
2021-02-27 15:54:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintJob:page-setup:
|
|
|
|
|
*
|
|
|
|
|
* Page setup.
|
|
|
|
|
*/
|
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));
|
|
|
|
|
|
2021-02-27 15:54:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintJob:track-print-status: (attributes org.gtk.Property.get=gtk_print_job_get_track_print_status org.gtk.Property.set=gtk_print_job_set_track_print_status)
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if the print job will continue to emit status-changed
|
|
|
|
|
* signals after the print data has been setn to the printer.
|
|
|
|
|
*/
|
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:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @job: the `GtkPrintJob` object on which the signal was emitted
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Emitted when the status of a job changes.
|
|
|
|
|
*
|
|
|
|
|
* The signal handler can use [method@Gtk.PrintJob.get_status]
|
|
|
|
|
* to obtain the new status.
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
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
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
* @settings: a `GtkPrintSettings`
|
|
|
|
|
* @page_setup: a `GtkPageSetup`
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Creates a new `GtkPrintJob`.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Returns: a new `GtkPrintJob`
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintJob *
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_print_job_new (const char *title,
|
2006-04-24 03:47:22 +00:00
|
|
|
|
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
|
|
|
|
/**
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* gtk_print_job_get_settings: (attributes org.gtk.Method.get_property=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
|
|
|
|
/**
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* gtk_print_job_get_printer: (attributes org.gtk.Method.get_property=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
|
|
|
|
/**
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* gtk_print_job_get_title: (attributes org.gtk.Method.get_property=title)
|
|
|
|
|
* @job: a `GtkPrintJob`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Gets the job title.
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the title of @job
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Gets the status of the print job.
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @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
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
|
|
|
|
* 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 [method@Gtk.Printer.accepts_pdf] and
|
|
|
|
|
* [method@Gtk.Printer.accepts_ps].
|
|
|
|
|
*
|
2006-04-25 15:36:54 +00:00
|
|
|
|
* Returns: %FALSE if an error occurred
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_job_set_source_file (GtkPrintJob *job,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *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
|
|
|
|
|
2022-01-12 11:36:44 +00:00
|
|
|
|
if (job->spool_io != NULL)
|
|
|
|
|
g_io_channel_unref (job->spool_io);
|
|
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2016-07-04 04:04:38 +00:00
|
|
|
|
* @fd: a file descriptor
|
|
|
|
|
* @error: return location for errors
|
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* 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 [method@Gtk.Printer.accepts_pdf] and
|
|
|
|
|
* [method@Gtk.Printer.accepts_ps].
|
2016-07-04 04:04:38 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* This is similar to [method@Gtk.PrintJob.set_source_file],
|
2016-07-04 04:04:38 +00:00
|
|
|
|
* 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);
|
|
|
|
|
|
2022-01-12 11:36:44 +00:00
|
|
|
|
if (job->spool_io != NULL)
|
|
|
|
|
g_io_channel_unref (job->spool_io);
|
|
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @error: (nullable): return location for errors
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Gets a cairo surface onto which the pages of
|
|
|
|
|
* the print job should be rendered.
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): the cairo surface of @job
|
2021-02-27 15:54:35 +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
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *filename = NULL;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double 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
|
|
|
|
/**
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* gtk_print_job_set_track_print_status: (attributes org.gtk.Method.set_property=track-print-status)
|
|
|
|
|
* @job: a `GtkPrintJob`
|
2006-05-15 16:22:38 +00:00
|
|
|
|
* @track_status: %TRUE to track status after printing
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
2006-05-15 16:22:38 +00:00
|
|
|
|
* If track_status is %TRUE, the print job will try to continue report
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* on the status of the print job in the printer queues and printer.
|
|
|
|
|
*
|
|
|
|
|
* This can allow your application to show things like “out of paper”
|
|
|
|
|
* issues, 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.
|
2006-05-15 16:22:38 +00:00
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* gtk_print_job_get_track_print_status: (attributes org.gtk.Method.get_property=track-print-status)
|
|
|
|
|
* @job: a `GtkPrintJob`
|
2006-05-15 16:22:38 +00:00
|
|
|
|
*
|
2020-08-21 12:41:13 +00:00
|
|
|
|
* Returns whether jobs will be tracked after printing.
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
|
|
|
|
* For details, see [method@Gtk.PrintJob.set_track_print_status].
|
2006-05-15 16:22:38 +00:00
|
|
|
|
*
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @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
|
2021-02-27 15:54:35 +00:00
|
|
|
|
*
|
|
|
|
|
* 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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Gets the `GtkPrintPages` setting for this job.
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Returns: the `GtkPrintPages` setting
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*/
|
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
|
|
|
|
* @pages: the `GtkPrintPages` setting
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Sets the `GtkPrintPages` setting for this job.
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*/
|
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @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
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* array of `GtkPageRange` structs
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkPageRange *
|
|
|
|
|
gtk_print_job_get_page_ranges (GtkPrintJob *job,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *n_ranges)
|
2010-12-18 22:45:31 +00:00
|
|
|
|
{
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2017-03-24 15:41:47 +00:00
|
|
|
|
* @ranges: (array length=n_ranges) (transfer full): pointer to an array of
|
2021-02-27 15:54:35 +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,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n_ranges)
|
2010-12-18 22:45:31 +00:00
|
|
|
|
{
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Gets the `GtkPageSet` setting for this job.
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Returns: the `GtkPageSet` setting
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*/
|
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
|
|
|
|
* @page_set: a `GtkPageSet` setting
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Sets the `GtkPageSet` setting for this job.
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*/
|
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the number of copies of this job.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of copies
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2010-12-18 22:45:31 +00:00
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @num_copies: the number of copies
|
|
|
|
|
*
|
|
|
|
|
* Sets the number of copies for this job.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_num_copies (GtkPrintJob *job,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int num_copies)
|
2010-12-18 22:45:31 +00:00
|
|
|
|
{
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Gets the scale for this job.
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the scale
|
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2010-12-18 22:45:31 +00:00
|
|
|
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @scale: the scale
|
|
|
|
|
*
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* Sets the scale for this job.
|
|
|
|
|
*
|
|
|
|
|
* 1.0 means unscaled.
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_job_set_scale (GtkPrintJob *job,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double scale)
|
2010-12-18 22:45:31 +00:00
|
|
|
|
{
|
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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* 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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* 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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* 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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* 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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
*
|
|
|
|
|
* 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:
|
2021-02-27 15:54:35 +00:00
|
|
|
|
* @job: a `GtkPrintJob`
|
2010-12-18 22:45:31 +00:00
|
|
|
|
* @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
|
|
|
|
}
|