2006-04-21 15:09:32 +00:00
|
|
|
|
/* GtkPrinter
|
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
#include "gtkprivate.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
|
|
|
|
#include "gtkprintjob.h"
|
2010-05-16 00:11:16 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* GtkPrinter:
|
2010-05-16 00:11:16 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* A `GtkPrinter` object represents a printer.
|
2010-05-16 00:11:16 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* You only need to deal directly with printers if you use the
|
|
|
|
|
* non-portable [class@Gtk.PrintUnixDialog] API.
|
|
|
|
|
*
|
|
|
|
|
* A `GtkPrinter` allows to get status information about the printer,
|
2010-05-16 00:11:16 +00:00
|
|
|
|
* such as its description, its location, the number of queued jobs,
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* etc. Most importantly, a `GtkPrinter` object can be used to create
|
|
|
|
|
* a [class@Gtk.PrintJob] object, which lets you print to the printer.
|
2010-05-16 00:11:16 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void gtk_printer_finalize (GObject *object);
|
|
|
|
|
|
|
|
|
|
struct _GtkPrinterPrivate
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *name;
|
|
|
|
|
char *location;
|
|
|
|
|
char *description;
|
|
|
|
|
char *icon_name;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
guint is_active : 1;
|
|
|
|
|
guint is_paused : 1;
|
|
|
|
|
guint is_accepting_jobs : 1;
|
|
|
|
|
guint is_new : 1;
|
|
|
|
|
guint is_virtual : 1;
|
|
|
|
|
guint is_default : 1;
|
|
|
|
|
guint has_details : 1;
|
|
|
|
|
guint accepts_pdf : 1;
|
|
|
|
|
guint accepts_ps : 1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *state_message;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int job_count;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
GtkPrintBackend *backend;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
DETAILS_ACQUIRED,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_NAME,
|
|
|
|
|
PROP_BACKEND,
|
|
|
|
|
PROP_IS_VIRTUAL,
|
|
|
|
|
PROP_STATE_MESSAGE,
|
|
|
|
|
PROP_LOCATION,
|
|
|
|
|
PROP_ICON_NAME,
|
2006-06-12 17:45:49 +00:00
|
|
|
|
PROP_JOB_COUNT,
|
|
|
|
|
PROP_ACCEPTS_PDF,
|
2008-07-15 17:34:34 +00:00
|
|
|
|
PROP_ACCEPTS_PS,
|
|
|
|
|
PROP_PAUSED,
|
|
|
|
|
PROP_ACCEPTING_JOBS
|
2006-04-21 15:09:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
|
|
static void gtk_printer_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_printer_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkPrinter, gtk_printer, G_TYPE_OBJECT)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_printer_class_init (GtkPrinterClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
object_class = (GObjectClass *) class;
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gtk_printer_finalize;
|
|
|
|
|
|
|
|
|
|
object_class->set_property = gtk_printer_set_property;
|
|
|
|
|
object_class->get_property = gtk_printer_get_property;
|
|
|
|
|
|
2021-02-27 15:54:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:name: (attributes org.gtk.Property.get=gtk_printer_get_name)
|
|
|
|
|
*
|
|
|
|
|
* The name of the printer.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_NAME,
|
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
|
P_("Name"),
|
|
|
|
|
P_("Name of the printer"),
|
2007-12-28 17:29:53 +00:00
|
|
|
|
"",
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:backend: (attributes org.gtk.Property.get=gtk_printer_get_backend)
|
|
|
|
|
*
|
|
|
|
|
* The backend for the printer.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_BACKEND,
|
|
|
|
|
g_param_spec_object ("backend",
|
|
|
|
|
P_("Backend"),
|
|
|
|
|
P_("Backend for the printer"),
|
|
|
|
|
GTK_TYPE_PRINT_BACKEND,
|
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:is-virtual: (attributes org.gtk.Property.get=gtk_printer_is_virtual)
|
|
|
|
|
*
|
|
|
|
|
* %FALSE if this represents a real hardware device.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_IS_VIRTUAL,
|
|
|
|
|
g_param_spec_boolean ("is-virtual",
|
|
|
|
|
P_("Is Virtual"),
|
2006-04-24 03:47:22 +00:00
|
|
|
|
P_("FALSE if this represents a real hardware printer"),
|
2006-04-21 15:09:32 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:accepts-pdf: (attributes org.gtk.Property.get=gtk_printer_accepts_pdf)
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if this printer can accept PDF.
|
|
|
|
|
*/
|
2006-06-12 17:45:49 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_ACCEPTS_PDF,
|
|
|
|
|
g_param_spec_boolean ("accepts-pdf",
|
|
|
|
|
P_("Accepts PDF"),
|
|
|
|
|
P_("TRUE if this printer can accept PDF"),
|
2010-12-28 14:48:02 +00:00
|
|
|
|
FALSE,
|
2006-06-12 17:45:49 +00:00
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:accepts-ps: (attributes org.gtk.Property.get=gtk_printer_accepts_ps)
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if this printer can accept PostScript.
|
|
|
|
|
*/
|
2006-06-12 17:45:49 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_ACCEPTS_PS,
|
|
|
|
|
g_param_spec_boolean ("accepts-ps",
|
|
|
|
|
P_("Accepts PostScript"),
|
|
|
|
|
P_("TRUE if this printer can accept PostScript"),
|
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:state-message: (attributes org.gtk.Property.get=gtk_printer_get_state_message)
|
|
|
|
|
*
|
|
|
|
|
* String giving the current status of the printer.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_STATE_MESSAGE,
|
|
|
|
|
g_param_spec_string ("state-message",
|
|
|
|
|
P_("State Message"),
|
|
|
|
|
P_("String giving the current state of the printer"),
|
2007-12-28 17:29:53 +00:00
|
|
|
|
"",
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GTK_PARAM_READABLE));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:location: (attributes org.gtk.Property.get=gtk_printer_get_location)
|
|
|
|
|
*
|
|
|
|
|
* Information about the location of the printer.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_LOCATION,
|
|
|
|
|
g_param_spec_string ("location",
|
|
|
|
|
P_("Location"),
|
|
|
|
|
P_("The location of the printer"),
|
2007-12-28 17:29:53 +00:00
|
|
|
|
"",
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GTK_PARAM_READABLE));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:icon-name: (attributes org.gtk.Property.get=gtk_printer_get_icon_name)
|
|
|
|
|
*
|
|
|
|
|
* Icon name to use for the printer.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_ICON_NAME,
|
|
|
|
|
g_param_spec_string ("icon-name",
|
|
|
|
|
P_("Icon Name"),
|
|
|
|
|
P_("The icon name to use for the printer"),
|
2019-12-22 23:09:07 +00:00
|
|
|
|
"printer",
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GTK_PARAM_READABLE));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter:job-count: (attributes org.gtk.Property.get=gtk_printer_get_job_count)
|
|
|
|
|
*
|
|
|
|
|
* Number of jobs queued in the printer.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_JOB_COUNT,
|
|
|
|
|
g_param_spec_int ("job-count",
|
|
|
|
|
P_("Job Count"),
|
|
|
|
|
P_("Number of jobs queued in the printer"),
|
|
|
|
|
0,
|
|
|
|
|
G_MAXINT,
|
|
|
|
|
0,
|
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* GtkPrinter:paused: (attributes org.gtk.Property.get=gtk_printer_is_paused)
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if this printer is paused.
|
2008-07-15 17:34:34 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* A paused printer still accepts jobs, but it does
|
2008-07-15 17:34:34 +00:00
|
|
|
|
* not print them.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_PAUSED,
|
|
|
|
|
g_param_spec_boolean ("paused",
|
|
|
|
|
P_("Paused Printer"),
|
|
|
|
|
P_("TRUE if this printer is paused"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* GtkPrinter:accepting-jobs: (attributes org.gtk.Property.get=gtk_printer_is_accepting_jobs)
|
2008-07-15 17:34:34 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* %TRUE if the printer is accepting jobs.
|
2018-02-05 19:13:20 +00:00
|
|
|
|
*/
|
2008-07-15 17:34:34 +00:00
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
|
PROP_ACCEPTING_JOBS,
|
|
|
|
|
g_param_spec_boolean ("accepting-jobs",
|
|
|
|
|
P_("Accepting Jobs"),
|
|
|
|
|
P_("TRUE if this printer is accepting new jobs"),
|
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrinter::details-acquired:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @printer: the `GtkPrinter` on which the signal is emitted
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* @success: %TRUE if the details were successfully acquired
|
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Emitted in response to a request for detailed information
|
|
|
|
|
* about a printer from the print backend.
|
|
|
|
|
*
|
|
|
|
|
* The @success parameter indicates if the information was
|
|
|
|
|
* actually obtained.
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
signals[DETAILS_ACQUIRED] =
|
2006-05-16 16:13:48 +00:00
|
|
|
|
g_signal_new (I_("details-acquired"),
|
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkPrinterClass, details_acquired),
|
|
|
|
|
NULL, NULL,
|
2019-05-31 03:56:50 +00:00
|
|
|
|
NULL,
|
2006-05-16 16:13:48 +00:00
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_printer_init (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->name = NULL;
|
|
|
|
|
priv->location = NULL;
|
|
|
|
|
priv->description = NULL;
|
2014-10-04 16:19:15 +00:00
|
|
|
|
priv->icon_name = g_strdup ("printer");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->is_active = TRUE;
|
2008-07-15 17:34:34 +00:00
|
|
|
|
priv->is_paused = FALSE;
|
|
|
|
|
priv->is_accepting_jobs = TRUE;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->is_new = TRUE;
|
|
|
|
|
priv->has_details = FALSE;
|
2010-12-28 14:48:02 +00:00
|
|
|
|
priv->accepts_pdf = FALSE;
|
2006-06-12 17:45:49 +00:00
|
|
|
|
priv->accepts_ps = TRUE;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
|
|
|
|
priv->state_message = NULL;
|
|
|
|
|
priv->job_count = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_printer_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkPrinter *printer = GTK_PRINTER (object);
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_free (priv->name);
|
|
|
|
|
g_free (priv->location);
|
|
|
|
|
g_free (priv->description);
|
|
|
|
|
g_free (priv->state_message);
|
|
|
|
|
g_free (priv->icon_name);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
|
if (priv->backend)
|
|
|
|
|
g_object_unref (priv->backend);
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_printer_parent_class)->finalize (object);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_printer_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkPrinter *printer = GTK_PRINTER (object);
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_NAME:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->name = g_value_dup_string (value);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_BACKEND:
|
2006-05-04 13:43:32 +00:00
|
|
|
|
priv->backend = GTK_PRINT_BACKEND (g_value_dup_object (value));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_IS_VIRTUAL:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->is_virtual = g_value_get_boolean (value);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-06-12 17:45:49 +00:00
|
|
|
|
case PROP_ACCEPTS_PDF:
|
|
|
|
|
priv->accepts_pdf = g_value_get_boolean (value);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ACCEPTS_PS:
|
|
|
|
|
priv->accepts_ps = 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_printer_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkPrinter *printer = GTK_PRINTER (object);
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_NAME:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->name)
|
|
|
|
|
g_value_set_string (value, priv->name);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2008-02-12 15:41:30 +00:00
|
|
|
|
g_value_set_static_string (value, "");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_BACKEND:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_value_set_object (value, priv->backend);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_STATE_MESSAGE:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->state_message)
|
|
|
|
|
g_value_set_string (value, priv->state_message);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2008-02-12 15:41:30 +00:00
|
|
|
|
g_value_set_static_string (value, "");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_LOCATION:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->location)
|
|
|
|
|
g_value_set_string (value, priv->location);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2008-02-12 15:41:30 +00:00
|
|
|
|
g_value_set_static_string (value, "");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_ICON_NAME:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->icon_name)
|
|
|
|
|
g_value_set_string (value, priv->icon_name);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2019-12-22 23:09:07 +00:00
|
|
|
|
g_value_set_static_string (value, "printer");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_JOB_COUNT:
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_value_set_int (value, priv->job_count);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2006-06-12 17:45:49 +00:00
|
|
|
|
case PROP_IS_VIRTUAL:
|
|
|
|
|
g_value_set_boolean (value, priv->is_virtual);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ACCEPTS_PDF:
|
|
|
|
|
g_value_set_boolean (value, priv->accepts_pdf);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ACCEPTS_PS:
|
|
|
|
|
g_value_set_boolean (value, priv->accepts_ps);
|
|
|
|
|
break;
|
2008-07-15 17:34:34 +00:00
|
|
|
|
case PROP_PAUSED:
|
|
|
|
|
g_value_set_boolean (value, priv->is_paused);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ACCEPTING_JOBS:
|
|
|
|
|
g_value_set_boolean (value, priv->is_accepting_jobs);
|
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_new:
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* @name: the name of the printer
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @backend: a `GtkPrintBackend`
|
2006-05-02 13:12:11 +00:00
|
|
|
|
* @virtual_: whether the printer is virtual
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Creates a new `GtkPrinter`.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Returns: a new `GtkPrinter`
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrinter *
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_printer_new (const char *name,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintBackend *backend,
|
2006-05-02 13:12:11 +00:00
|
|
|
|
gboolean virtual_)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
GObject *result;
|
|
|
|
|
|
|
|
|
|
result = g_object_new (GTK_TYPE_PRINTER,
|
|
|
|
|
"name", name,
|
|
|
|
|
"backend", backend,
|
2006-05-02 13:12:11 +00:00
|
|
|
|
"is-virtual", virtual_,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
return (GtkPrinter *) result;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_get_backend: (attributes org.gtk.Method.get_property=backend)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Returns the backend of the printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): the backend of @printer
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintBackend *
|
|
|
|
|
gtk_printer_get_backend (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->backend;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_get_name: (attributes org.gtk.Method.get_property=name)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Returns the name of the printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the name of @printer
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_get_name (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->name;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_get_description:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Gets the description of the printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the description of @printer
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_get_description (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->description;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_printer_set_description (GtkPrinter *printer,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *description)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
2010-01-08 16:42:34 +00:00
|
|
|
|
if (g_strcmp0 (priv->description, description) == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_free (priv->description);
|
|
|
|
|
priv->description = g_strdup (description);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_get_state_message: (attributes org.gtk.Method.get_property=state-message)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Returns the state message describing the current state
|
|
|
|
|
* of the printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the state message of @printer
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_get_state_message (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->state_message;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_printer_set_state_message (GtkPrinter *printer,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *message)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
2010-01-08 16:42:34 +00:00
|
|
|
|
if (g_strcmp0 (priv->state_message, message) == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_free (priv->state_message);
|
|
|
|
|
priv->state_message = g_strdup (message);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_notify (G_OBJECT (printer), "state-message");
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_get_location: (attributes org.gtk.Method.get_property=location)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2007-05-26 07:13:52 +00:00
|
|
|
|
* Returns a description of the location of the printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the location of @printer
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_get_location (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->location;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_printer_set_location (GtkPrinter *printer,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *location)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
2010-01-08 16:42:34 +00:00
|
|
|
|
if (g_strcmp0 (priv->location, location) == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_free (priv->location);
|
|
|
|
|
priv->location = g_strdup (location);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_notify (G_OBJECT (printer), "location");
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-26 08:07:37 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_get_icon_name: (attributes org.gtk.Method.get_property=icon-name)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Gets the name of the icon to use for the printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the icon name for @printer
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_get_icon_name (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->icon_name;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gtk_printer_set_icon_name (GtkPrinter *printer,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *icon)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
g_free (priv->icon_name);
|
|
|
|
|
priv->icon_name = g_strdup (icon);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_notify (G_OBJECT (printer), "icon-name");
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_get_job_count: (attributes org.gtk.Method.get_property=job-count)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Gets the number of jobs currently queued on the printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the number of jobs on @printer
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2021-02-27 15:54:24 +00:00
|
|
|
|
int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_get_job_count (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), 0);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->job_count;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_set_job_count (GtkPrinter *printer,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int count)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
if (priv->job_count == count)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
|
priv->job_count = count;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (printer), "job-count");
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-29 04:42:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_has_details:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2007-04-29 04:42:13 +00:00
|
|
|
|
* Returns whether the printer details are available.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer details are available
|
2007-04-29 04:42:13 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
2007-04-29 04:42:13 +00:00
|
|
|
|
gtk_printer_has_details (GtkPrinter *printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2007-04-29 04:42:13 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->has_details;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_printer_set_has_details (GtkPrinter *printer,
|
2019-05-26 20:46:58 +00:00
|
|
|
|
gboolean val)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
|
|
|
|
priv->has_details = val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_is_active:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
|
|
|
|
* Returns whether the printer is currently active (i.e.
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* accepts new jobs).
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer is active
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_is_active (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->is_active;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_printer_set_is_active (GtkPrinter *printer,
|
|
|
|
|
gboolean val)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
priv->is_active = val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_is_paused: (attributes org.gtk.Method.get_property=paused)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2008-07-15 17:34:34 +00:00
|
|
|
|
* Returns whether the printer is currently paused.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2008-07-15 17:34:34 +00:00
|
|
|
|
* A paused printer still accepts jobs, but it is not
|
|
|
|
|
* printing them.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer is paused
|
2008-07-15 17:34:34 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_is_paused (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->is_paused;
|
2008-07-15 17:34:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_set_is_paused (GtkPrinter *printer,
|
|
|
|
|
gboolean val)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2008-07-15 17:34:34 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
|
|
|
|
if (val == priv->is_paused)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
priv->is_paused = val;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_is_accepting_jobs: (attributes org.gtk.Method.get_property=accepting-jobs)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2008-07-15 17:34:34 +00:00
|
|
|
|
* Returns whether the printer is accepting jobs
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer is accepting jobs
|
2008-07-15 17:34:34 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_is_accepting_jobs (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->is_accepting_jobs;
|
2008-07-15 17:34:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_set_is_accepting_jobs (GtkPrinter *printer,
|
|
|
|
|
gboolean val)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2008-07-15 17:34:34 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
|
|
|
|
if (val == priv->is_accepting_jobs)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
priv->is_accepting_jobs = val;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_is_virtual: (attributes org.gtk.Method.get_property=is-virtual)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Returns whether the printer is virtual (i.e. does not
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* represent actual printer hardware, but something like
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* a CUPS class).
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer is virtual
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_is_virtual (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->is_virtual;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-06-29 09:18:07 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_accepts_pdf: (attributes org.gtk.Method.get_property=accepts-pdf)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the printer accepts input in
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* PDF format.
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer accepts PDF
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*/
|
2021-02-27 15:54:24 +00:00
|
|
|
|
gboolean
|
2006-06-12 17:45:49 +00:00
|
|
|
|
gtk_printer_accepts_pdf (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-06-12 17:45:49 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->accepts_pdf;
|
2006-06-12 17:45:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 05:34:49 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_printer_set_accepts_pdf (GtkPrinter *printer,
|
|
|
|
|
gboolean val)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2010-12-29 05:34:49 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
priv->accepts_pdf = val;
|
2010-12-29 05:34:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-06-29 09:18:07 +00:00
|
|
|
|
/**
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* gtk_printer_accepts_ps: (attributes org.gtk.Method.get_property=accepts-ps)
|
|
|
|
|
* @printer: a `GtkPrinter`
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the printer accepts input in
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* PostScript format.
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer accepts PostScript
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*/
|
2021-02-27 15:54:24 +00:00
|
|
|
|
gboolean
|
2006-06-12 17:45:49 +00:00
|
|
|
|
gtk_printer_accepts_ps (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-06-12 17:45:49 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->accepts_ps;
|
2006-06-12 17:45:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 05:34:49 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_printer_set_accepts_ps (GtkPrinter *printer,
|
|
|
|
|
gboolean val)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2010-12-29 05:34:49 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
priv->accepts_ps = val;
|
2010-12-29 05:34:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_is_new (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->is_new;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_printer_set_is_new (GtkPrinter *printer,
|
|
|
|
|
gboolean val)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
priv->is_new = val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_is_default:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
|
* Returns whether the printer is the default printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @printer is the default
|
2006-04-24 03:47:22 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_is_default (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
return priv->is_default;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_printer_set_is_default (GtkPrinter *printer,
|
2006-04-24 03:47:22 +00:00
|
|
|
|
gboolean val)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
priv->is_default = val;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-04-29 04:42:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_request_details:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
|
|
|
|
* Requests the printer details.
|
|
|
|
|
*
|
|
|
|
|
* When the details are available, the
|
|
|
|
|
* [signal@Gtk.Printer::details-acquired] signal
|
|
|
|
|
* will be emitted on @printer.
|
2007-04-29 04:42:13 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
2007-04-29 04:42:13 +00:00
|
|
|
|
gtk_printer_request_details (GtkPrinter *printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2007-04-29 04:42:13 +00:00
|
|
|
|
GtkPrintBackendClass *backend_class;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
2006-05-22 12:53:13 +00:00
|
|
|
|
backend_class->printer_request_details (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GtkPrinterOptionSet *
|
2006-06-19 05:09:49 +00:00
|
|
|
|
_gtk_printer_get_options (GtkPrinter *printer,
|
|
|
|
|
GtkPrintSettings *settings,
|
|
|
|
|
GtkPageSetup *page_setup,
|
|
|
|
|
GtkPrintCapabilities capabilities)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
|
|
|
|
|
2006-06-19 05:09:49 +00:00
|
|
|
|
return backend_class->printer_get_options (printer, settings, page_setup, capabilities);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_gtk_printer_mark_conflicts (GtkPrinter *printer,
|
|
|
|
|
GtkPrinterOptionSet *options)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
|
return backend_class->printer_mark_conflicts (printer, options);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gtk_printer_get_settings_from_options (GtkPrinter *printer,
|
|
|
|
|
GtkPrinterOptionSet *options,
|
|
|
|
|
GtkPrintSettings *settings)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
|
|
|
|
|
2006-05-22 12:53:13 +00:00
|
|
|
|
backend_class->printer_get_settings_from_options (printer, options, settings);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2006-04-24 03:47:22 +00:00
|
|
|
|
_gtk_printer_prepare_for_print (GtkPrinter *printer,
|
|
|
|
|
GtkPrintJob *print_job,
|
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
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
|
|
|
|
|
2006-05-22 12:53:13 +00:00
|
|
|
|
backend_class->printer_prepare_for_print (printer, print_job, settings, page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cairo_surface_t *
|
2006-06-16 18:29:09 +00:00
|
|
|
|
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
|
|
|
|
GtkPrintSettings *settings,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double width,
|
|
|
|
|
double height,
|
2006-06-21 18:16:58 +00:00
|
|
|
|
GIOChannel *cache_io)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2006-06-16 18:29:09 +00:00
|
|
|
|
return backend_class->printer_create_cairo_surface (printer, settings,
|
2006-06-21 18:16:58 +00:00
|
|
|
|
width, height, cache_io);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-12-24 13:16:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_list_papers:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
*
|
2007-04-29 04:42:13 +00:00
|
|
|
|
* Lists all the paper sizes @printer supports.
|
2009-12-10 10:23:40 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* This will return and empty list unless the printer’s details
|
|
|
|
|
* are available, see [method@Gtk.Printer.has_details] and
|
|
|
|
|
* [method@Gtk.Printer.request_details].
|
|
|
|
|
*
|
|
|
|
|
* Returns: (element-type GtkPageSetup) (transfer full): a newly
|
|
|
|
|
* allocated list of newly allocated `GtkPageSetup`s.
|
2006-12-24 13:16:05 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GList *
|
2006-12-24 13:16:05 +00:00
|
|
|
|
gtk_printer_list_papers (GtkPrinter *printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2006-12-24 13:16:05 +00:00
|
|
|
|
GtkPrintBackendClass *backend_class;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
2006-05-04 13:43:32 +00:00
|
|
|
|
return backend_class->printer_list_papers (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-21 02:17:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_get_default_page_size:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
2008-02-06 22:58:47 +00:00
|
|
|
|
*
|
2008-05-21 02:17:30 +00:00
|
|
|
|
* Returns default page size of @printer.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): a newly allocated `GtkPageSetup` with default page size
|
|
|
|
|
* of the printer.
|
2008-05-21 02:17:30 +00:00
|
|
|
|
*/
|
2021-02-27 15:54:24 +00:00
|
|
|
|
GtkPageSetup *
|
2008-05-21 02:17:30 +00:00
|
|
|
|
gtk_printer_get_default_page_size (GtkPrinter *printer)
|
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2008-05-21 02:17:30 +00:00
|
|
|
|
GtkPrintBackendClass *backend_class;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
2021-02-27 15:54:24 +00:00
|
|
|
|
|
2008-05-21 02:17:30 +00:00
|
|
|
|
return backend_class->printer_get_default_page_size (printer);
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-06 22:58:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_get_hard_margins:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
2011-01-18 09:10:30 +00:00
|
|
|
|
* @top: (out): a location to store the top margin in
|
|
|
|
|
* @bottom: (out): a location to store the bottom margin in
|
|
|
|
|
* @left: (out): a location to store the left margin in
|
|
|
|
|
* @right: (out): a location to store the right margin in
|
2008-02-06 22:58:47 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Retrieve the hard margins of @printer.
|
|
|
|
|
*
|
|
|
|
|
* These are the margins that define the area at the borders
|
|
|
|
|
* of the paper that the printer cannot print to.
|
2008-02-06 22:58:47 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Note: This will not succeed unless the printer’s details are
|
|
|
|
|
* available, see [method@Gtk.Printer.has_details] and
|
|
|
|
|
* [method@Gtk.Printer.request_details].
|
2008-02-06 22:58:47 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE iff the hard margins were retrieved
|
2008-02-06 22:58:47 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_get_hard_margins (GtkPrinter *printer,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double *top,
|
|
|
|
|
double *bottom,
|
|
|
|
|
double *left,
|
|
|
|
|
double *right)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2008-02-06 22:58:47 +00:00
|
|
|
|
return backend_class->printer_get_hard_margins (printer, top, bottom, left, right);
|
2006-05-04 13:43:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-12 09:31:37 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_get_hard_margins_for_paper_size:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
|
|
|
|
* @paper_size: a `GtkPaperSize`
|
2018-04-12 09:31:37 +00:00
|
|
|
|
* @top: (out): a location to store the top margin in
|
|
|
|
|
* @bottom: (out): a location to store the bottom margin in
|
|
|
|
|
* @left: (out): a location to store the left margin in
|
|
|
|
|
* @right: (out): a location to store the right margin in
|
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Retrieve the hard margins of @printer for @paper_size.
|
|
|
|
|
*
|
|
|
|
|
* These are the margins that define the area at the borders
|
|
|
|
|
* of the paper that the printer cannot print to.
|
2018-04-12 09:31:37 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Note: This will not succeed unless the printer’s details are
|
|
|
|
|
* available, see [method@Gtk.Printer.has_details] and
|
|
|
|
|
* [method@Gtk.Printer.request_details].
|
2018-04-12 09:31:37 +00:00
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE iff the hard margins were retrieved
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_printer_get_hard_margins_for_paper_size (GtkPrinter *printer,
|
|
|
|
|
GtkPaperSize *paper_size,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double *top,
|
|
|
|
|
double *bottom,
|
|
|
|
|
double *left,
|
|
|
|
|
double *right)
|
2018-04-12 09:31:37 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
|
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
2018-04-12 09:31:37 +00:00
|
|
|
|
|
|
|
|
|
return backend_class->printer_get_hard_margins_for_paper_size (printer, paper_size, top, bottom, left, right);
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-30 19:12:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_get_capabilities:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @printer: a `GtkPrinter`
|
2007-04-30 19:12:00 +00:00
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Returns the printer’s capabilities.
|
2007-04-30 19:12:00 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* This is useful when you’re using `GtkPrintUnixDialog`’s
|
|
|
|
|
* manual-capabilities setting and need to know which settings
|
|
|
|
|
* the printer can handle and which you must handle yourself.
|
2007-04-30 19:12:00 +00:00
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* This will return 0 unless the printer’s details are
|
|
|
|
|
* available, see [method@Gtk.Printer.has_details] and
|
|
|
|
|
* [method@Gtk.Printer.request_details].
|
2008-02-06 22:58:47 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the printer’s capabilities
|
2007-04-30 19:12:00 +00:00
|
|
|
|
*/
|
2006-05-24 10:50:57 +00:00
|
|
|
|
GtkPrintCapabilities
|
2007-04-30 19:12:00 +00:00
|
|
|
|
gtk_printer_get_capabilities (GtkPrinter *printer)
|
2006-05-24 10:50:57 +00:00
|
|
|
|
{
|
2019-05-26 20:46:58 +00:00
|
|
|
|
GtkPrinterPrivate *priv = gtk_printer_get_instance_private (printer);
|
2007-04-30 19:12:00 +00:00
|
|
|
|
GtkPrintBackendClass *backend_class;
|
2006-05-24 10:50:57 +00:00
|
|
|
|
|
2007-04-30 19:12:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), 0);
|
|
|
|
|
|
2019-05-26 20:46:58 +00:00
|
|
|
|
backend_class = GTK_PRINT_BACKEND_GET_CLASS (priv->backend);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
return backend_class->printer_get_capabilities (printer);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-29 09:18:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_printer_compare:
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* @a: a `GtkPrinter`
|
|
|
|
|
* @b: another `GtkPrinter`
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*
|
|
|
|
|
* Compares two printers.
|
2021-02-27 15:54:24 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: 0 if the printer match, a negative value if @a < @b,
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* or a positive value if @a > @b
|
2006-06-29 09:18:07 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2006-06-29 09:18:07 +00:00
|
|
|
|
gtk_printer_compare (GtkPrinter *a,
|
|
|
|
|
GtkPrinter *b)
|
2006-05-04 13:43:32 +00:00
|
|
|
|
{
|
|
|
|
|
const char *name_a, *name_b;
|
|
|
|
|
|
|
|
|
|
g_assert (GTK_IS_PRINTER (a) && GTK_IS_PRINTER (b));
|
|
|
|
|
|
|
|
|
|
name_a = gtk_printer_get_name (a);
|
|
|
|
|
name_b = gtk_printer_get_name (b);
|
|
|
|
|
if (name_a == NULL && name_b == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
else if (name_a == NULL)
|
|
|
|
|
return G_MAXINT;
|
|
|
|
|
else if (name_b == NULL)
|
|
|
|
|
return G_MININT;
|
|
|
|
|
else
|
|
|
|
|
return g_ascii_strcasecmp (name_a, name_b);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-06-19 22:18:38 +00:00
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
GList *backends;
|
|
|
|
|
GtkPrinterFunc func;
|
|
|
|
|
gpointer data;
|
|
|
|
|
GDestroyNotify destroy;
|
|
|
|
|
GMainLoop *loop;
|
|
|
|
|
} PrinterList;
|
|
|
|
|
|
|
|
|
|
static void list_done_cb (GtkPrintBackend *backend,
|
|
|
|
|
PrinterList *printer_list);
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
stop_enumeration (PrinterList *printer_list)
|
|
|
|
|
{
|
|
|
|
|
GList *list, *next;
|
|
|
|
|
GtkPrintBackend *backend;
|
|
|
|
|
|
|
|
|
|
for (list = printer_list->backends; list; list = next)
|
|
|
|
|
{
|
|
|
|
|
next = list->next;
|
|
|
|
|
backend = GTK_PRINT_BACKEND (list->data);
|
|
|
|
|
list_done_cb (backend, printer_list);
|
|
|
|
|
}
|
2006-06-25 08:24:34 +00:00
|
|
|
|
}
|
2006-06-19 22:18:38 +00:00
|
|
|
|
|
2006-06-25 08:24:34 +00:00
|
|
|
|
static void
|
|
|
|
|
free_printer_list (PrinterList *printer_list)
|
|
|
|
|
{
|
2006-06-19 22:18:38 +00:00
|
|
|
|
if (printer_list->destroy)
|
|
|
|
|
printer_list->destroy (printer_list->data);
|
|
|
|
|
|
|
|
|
|
if (printer_list->loop)
|
|
|
|
|
{
|
|
|
|
|
g_main_loop_quit (printer_list->loop);
|
|
|
|
|
g_main_loop_unref (printer_list->loop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (printer_list);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-25 08:24:34 +00:00
|
|
|
|
static gboolean
|
2006-06-19 22:18:38 +00:00
|
|
|
|
list_added_cb (GtkPrintBackend *backend,
|
|
|
|
|
GtkPrinter *printer,
|
|
|
|
|
PrinterList *printer_list)
|
|
|
|
|
{
|
|
|
|
|
if (printer_list->func (printer, printer_list->data))
|
2006-06-25 08:24:34 +00:00
|
|
|
|
{
|
|
|
|
|
stop_enumeration (printer_list);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2006-06-19 22:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-17 22:07:10 +00:00
|
|
|
|
static void
|
|
|
|
|
backend_status_changed (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintBackend *backend = GTK_PRINT_BACKEND (object);
|
|
|
|
|
PrinterList *printer_list = data;
|
|
|
|
|
GtkPrintBackendStatus status;
|
|
|
|
|
|
|
|
|
|
g_object_get (backend, "status", &status, NULL);
|
|
|
|
|
|
|
|
|
|
if (status == GTK_PRINT_BACKEND_STATUS_UNAVAILABLE)
|
|
|
|
|
list_done_cb (backend, printer_list);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-26 11:29:46 +00:00
|
|
|
|
static gboolean
|
2012-03-15 11:10:52 +00:00
|
|
|
|
list_printers_remove_backend (PrinterList *printer_list,
|
|
|
|
|
GtkPrintBackend *backend)
|
2006-06-19 22:18:38 +00:00
|
|
|
|
{
|
|
|
|
|
printer_list->backends = g_list_remove (printer_list->backends, backend);
|
|
|
|
|
gtk_print_backend_destroy (backend);
|
|
|
|
|
g_object_unref (backend);
|
|
|
|
|
|
|
|
|
|
if (printer_list->backends == NULL)
|
2014-03-26 11:29:46 +00:00
|
|
|
|
{
|
|
|
|
|
free_printer_list (printer_list);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2006-06-19 22:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 11:10:52 +00:00
|
|
|
|
static void
|
|
|
|
|
list_done_cb (GtkPrintBackend *backend,
|
|
|
|
|
PrinterList *printer_list)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (backend, list_added_cb, printer_list);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (backend, list_done_cb, printer_list);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (backend, backend_status_changed, printer_list);
|
|
|
|
|
|
|
|
|
|
list_printers_remove_backend(printer_list, backend);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-25 08:24:34 +00:00
|
|
|
|
static gboolean
|
2006-06-19 22:18:38 +00:00
|
|
|
|
list_printers_init (PrinterList *printer_list,
|
|
|
|
|
GtkPrintBackend *backend)
|
|
|
|
|
{
|
2006-06-25 08:24:34 +00:00
|
|
|
|
GList *list, *node;
|
2008-09-17 22:07:10 +00:00
|
|
|
|
GtkPrintBackendStatus status;
|
2006-06-19 22:18:38 +00:00
|
|
|
|
|
|
|
|
|
list = gtk_print_backend_get_printer_list (backend);
|
|
|
|
|
|
|
|
|
|
for (node = list; node != NULL; node = node->next)
|
2006-06-25 08:24:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (list_added_cb (backend, node->data, printer_list))
|
|
|
|
|
{
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-06-19 22:18:38 +00:00
|
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
|
2008-09-17 22:07:10 +00:00
|
|
|
|
g_object_get (backend, "status", &status, NULL);
|
|
|
|
|
|
|
|
|
|
if (status == GTK_PRINT_BACKEND_STATUS_UNAVAILABLE ||
|
|
|
|
|
gtk_print_backend_printer_list_is_done (backend))
|
2014-03-26 11:29:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (list_printers_remove_backend (printer_list, backend))
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2006-06-19 22:18:38 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_signal_connect (backend, "printer-added",
|
|
|
|
|
(GCallback) list_added_cb,
|
|
|
|
|
printer_list);
|
|
|
|
|
g_signal_connect (backend, "printer-list-done",
|
|
|
|
|
(GCallback) list_done_cb,
|
|
|
|
|
printer_list);
|
2008-09-17 22:07:10 +00:00
|
|
|
|
g_signal_connect (backend, "notify::status",
|
|
|
|
|
(GCallback) backend_status_changed,
|
|
|
|
|
printer_list);
|
2006-06-19 22:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-06-25 08:24:34 +00:00
|
|
|
|
return FALSE;
|
2006-06-19 22:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_enumerate_printers:
|
|
|
|
|
* @func: a function to call for each printer
|
|
|
|
|
* @data: user data to pass to @func
|
|
|
|
|
* @destroy: function to call if @data is no longer needed
|
|
|
|
|
* @wait: if %TRUE, wait in a recursive mainloop until
|
|
|
|
|
* all printers are enumerated; otherwise return early
|
|
|
|
|
*
|
2021-02-27 15:54:24 +00:00
|
|
|
|
* Calls a function for all `GtkPrinter`s.
|
|
|
|
|
*
|
2006-06-22 02:29:37 +00:00
|
|
|
|
* If @func returns %TRUE, the enumeration is stopped.
|
2006-06-19 22:18:38 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_enumerate_printers (GtkPrinterFunc func,
|
|
|
|
|
gpointer data,
|
|
|
|
|
GDestroyNotify destroy,
|
|
|
|
|
gboolean wait)
|
|
|
|
|
{
|
|
|
|
|
PrinterList *printer_list;
|
2006-06-21 17:14:05 +00:00
|
|
|
|
GList *node, *next;
|
2006-06-19 22:18:38 +00:00
|
|
|
|
GtkPrintBackend *backend;
|
|
|
|
|
|
|
|
|
|
printer_list = g_new0 (PrinterList, 1);
|
|
|
|
|
|
|
|
|
|
printer_list->func = func;
|
|
|
|
|
printer_list->data = data;
|
|
|
|
|
printer_list->destroy = destroy;
|
|
|
|
|
|
|
|
|
|
if (g_module_supported ())
|
|
|
|
|
printer_list->backends = gtk_print_backend_load_modules ();
|
2006-06-30 13:20:15 +00:00
|
|
|
|
|
|
|
|
|
if (printer_list->backends == NULL)
|
|
|
|
|
{
|
|
|
|
|
free_printer_list (printer_list);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-06-19 22:18:38 +00:00
|
|
|
|
|
|
|
|
|
for (node = printer_list->backends; node != NULL; node = next)
|
|
|
|
|
{
|
|
|
|
|
next = node->next;
|
|
|
|
|
backend = GTK_PRINT_BACKEND (node->data);
|
2006-06-25 08:24:34 +00:00
|
|
|
|
if (list_printers_init (printer_list, backend))
|
|
|
|
|
return;
|
2006-06-19 22:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wait && printer_list->backends)
|
|
|
|
|
{
|
|
|
|
|
printer_list->loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
g_main_loop_run (printer_list->loop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-30 19:12:00 +00:00
|
|
|
|
GType
|
|
|
|
|
gtk_print_capabilities_get_type (void)
|
|
|
|
|
{
|
|
|
|
|
static GType etype = 0;
|
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (etype == 0))
|
|
|
|
|
{
|
|
|
|
|
static const GFlagsValue values[] = {
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_PAGE_SET, "GTK_PRINT_CAPABILITY_PAGE_SET", "page-set" },
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_COPIES, "GTK_PRINT_CAPABILITY_COPIES", "copies" },
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_COLLATE, "GTK_PRINT_CAPABILITY_COLLATE", "collate" },
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_REVERSE, "GTK_PRINT_CAPABILITY_REVERSE", "reverse" },
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_SCALE, "GTK_PRINT_CAPABILITY_SCALE", "scale" },
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_GENERATE_PDF, "GTK_PRINT_CAPABILITY_GENERATE_PDF", "generate-pdf" },
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_GENERATE_PS, "GTK_PRINT_CAPABILITY_GENERATE_PS", "generate-ps" },
|
|
|
|
|
{ GTK_PRINT_CAPABILITY_PREVIEW, "GTK_PRINT_CAPABILITY_PREVIEW", "preview" },
|
2007-05-28 10:41:09 +00:00
|
|
|
|
{ GTK_PRINT_CAPABILITY_NUMBER_UP, "GTK_PRINT_CAPABILITY_NUMBER_UP", "number-up"},
|
2008-08-21 10:25:27 +00:00
|
|
|
|
{ GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT, "GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT", "number-up-layout" },
|
2007-04-30 19:12:00 +00:00
|
|
|
|
{ 0, NULL, NULL }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
etype = g_flags_register_static (I_("GtkPrintCapabilities"), values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return etype;
|
|
|
|
|
}
|