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
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
|
|
|
#include "gtkprinter.h"
|
|
|
|
#include "gtkprinter-private.h"
|
|
|
|
#include "gtkprintbackend.h"
|
|
|
|
#include "gtkprintjob.h"
|
|
|
|
#include "gtkalias.h"
|
|
|
|
|
|
|
|
#define GTK_PRINTER_GET_PRIVATE(o) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINTER, GtkPrinterPrivate))
|
|
|
|
|
|
|
|
static void gtk_printer_finalize (GObject *object);
|
|
|
|
|
|
|
|
struct _GtkPrinterPrivate
|
|
|
|
{
|
|
|
|
gchar *name;
|
|
|
|
gchar *location;
|
|
|
|
gchar *description;
|
|
|
|
gchar *icon_name;
|
|
|
|
|
|
|
|
guint is_active: 1;
|
|
|
|
guint is_new: 1;
|
|
|
|
guint is_virtual : 1;
|
|
|
|
guint is_default : 1;
|
|
|
|
guint has_details: 1;
|
|
|
|
|
|
|
|
gchar *state_message;
|
|
|
|
gint job_count;
|
|
|
|
|
|
|
|
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,
|
|
|
|
PROP_JOB_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2006-05-14 04:25:34 +00:00
|
|
|
G_DEFINE_TYPE (GtkPrinter, gtk_printer, G_TYPE_OBJECT)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
safe_strcmp (const char *a, const char *b)
|
|
|
|
{
|
|
|
|
if (a == b)
|
|
|
|
return 0;
|
|
|
|
if (a == NULL)
|
|
|
|
return -1;
|
|
|
|
if (b == NULL)
|
|
|
|
return 1;
|
|
|
|
return strcmp (a, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
g_type_class_add_private (class, sizeof (GtkPrinterPrivate));
|
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
PROP_NAME,
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
P_("Name"),
|
|
|
|
P_("Name of the printer"),
|
|
|
|
NULL,
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
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));
|
|
|
|
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));
|
|
|
|
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"),
|
|
|
|
NULL,
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (class),
|
|
|
|
PROP_LOCATION,
|
|
|
|
g_param_spec_string ("location",
|
|
|
|
P_("Location"),
|
|
|
|
P_("The location of the printer"),
|
|
|
|
NULL,
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
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"),
|
|
|
|
NULL,
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
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));
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
/**
|
|
|
|
* GtkPrinter::details-acquired:
|
|
|
|
* @printer: the #GtkPrinter on which the signal is emitted
|
|
|
|
* @success: %TRUE if the details were successfully acquired
|
|
|
|
*
|
|
|
|
* Gets 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.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
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,
|
|
|
|
g_cclosure_marshal_VOID__BOOLEAN,
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_printer_init (GtkPrinter *printer)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv = printer->priv = GTK_PRINTER_GET_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;
|
|
|
|
priv->icon_name = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->is_active = TRUE;
|
|
|
|
priv->is_new = TRUE;
|
|
|
|
priv->has_details = FALSE;
|
|
|
|
|
|
|
|
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);
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv = printer->priv;
|
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);
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv = printer->priv;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv = printer->priv;
|
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
|
|
|
|
g_value_set_string (value, "");
|
|
|
|
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
|
|
|
|
g_value_set_string (value, "");
|
|
|
|
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
|
|
|
|
g_value_set_string (value, "");
|
|
|
|
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
|
|
|
|
g_value_set_string (value, "");
|
|
|
|
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;
|
|
|
|
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
|
|
|
|
* @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
|
|
|
*
|
|
|
|
* Creates a new #GtkPrinter.
|
|
|
|
*
|
|
|
|
* Return value: a new #GtkPrinter
|
|
|
|
*
|
2006-04-24 03:47:22 +00:00
|
|
|
* Since: 2.10
|
2006-04-21 15:09:32 +00:00
|
|
|
**/
|
|
|
|
GtkPrinter *
|
2006-04-24 03:47:22 +00:00
|
|
|
gtk_printer_new (const gchar *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
|
|
|
/**
|
|
|
|
* gtk_printer_get_backend:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Returns the backend of the printer.
|
|
|
|
*
|
|
|
|
* Return value: the backend of @printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrintBackend *
|
|
|
|
gtk_printer_get_backend (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
|
|
return printer->priv->backend;
|
|
|
|
}
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
/**
|
|
|
|
* gtk_printer_get_name:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Returns the name of the printer.
|
|
|
|
*
|
|
|
|
* Return value: the name of @printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar *
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_get_name (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
|
|
return printer->priv->name;
|
|
|
|
}
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
/**
|
|
|
|
* gtk_printer_get_description:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Gets the description of the printer.
|
|
|
|
*
|
|
|
|
* Return value: the description of @printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar *
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_get_description (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
|
|
return printer->priv->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2006-04-24 03:47:22 +00:00
|
|
|
gtk_printer_set_description (GtkPrinter *printer,
|
|
|
|
const gchar *description)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv;
|
|
|
|
|
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
|
|
|
priv = printer->priv;
|
|
|
|
|
|
|
|
if (safe_strcmp (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
|
|
|
/**
|
|
|
|
* gtk_printer_get_state_message:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Returns the state message describing the current state
|
|
|
|
* of the printer.
|
|
|
|
*
|
|
|
|
* Return value: the state message of @printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar *
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_get_state_message (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
|
|
return printer->priv->state_message;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2006-04-24 03:47:22 +00:00
|
|
|
gtk_printer_set_state_message (GtkPrinter *printer,
|
|
|
|
const gchar *message)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv;
|
|
|
|
|
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
|
|
|
priv = printer->priv;
|
|
|
|
|
|
|
|
if (safe_strcmp (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
|
|
|
/**
|
|
|
|
* gtk_printer_get_location:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Returns a description of the location of the printer.
|
|
|
|
*
|
|
|
|
* Return value: the location of @printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar *
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_get_location (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
|
|
return printer->priv->location;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2006-04-24 03:47:22 +00:00
|
|
|
gtk_printer_set_location (GtkPrinter *printer,
|
|
|
|
const gchar *location)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv;
|
|
|
|
|
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
|
|
|
priv = printer->priv;
|
|
|
|
|
|
|
|
if (safe_strcmp (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;
|
|
|
|
}
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
/**
|
|
|
|
* gtk_printer_get_icon_name:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Gets the name of the icon to use for the printer.
|
|
|
|
*
|
|
|
|
* Return value: the icon name for @printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar *
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_get_icon_name (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
|
|
|
|
|
|
|
return printer->priv->icon_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-24 03:47:22 +00:00
|
|
|
gtk_printer_set_icon_name (GtkPrinter *printer,
|
|
|
|
const gchar *icon)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv;
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv = printer->priv;
|
|
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* gtk_printer_get_job_count:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Gets the number of jobs currently queued on the printer.
|
|
|
|
*
|
|
|
|
* Return value: the number of jobs on @printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
gint
|
|
|
|
gtk_printer_get_job_count (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), 0);
|
|
|
|
|
|
|
|
return printer->priv->job_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gtk_printer_set_job_count (GtkPrinter *printer,
|
2006-04-24 03:47:22 +00:00
|
|
|
gint count)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrinterPrivate *priv;
|
|
|
|
|
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
|
|
|
priv = printer->priv;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gtk_printer_has_details (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
return printer->priv->has_details;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_printer_set_has_details (GtkPrinter *printer,
|
|
|
|
gboolean val)
|
|
|
|
{
|
|
|
|
printer->priv->has_details = val;
|
|
|
|
}
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
/**
|
|
|
|
* gtk_printer_is_active:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Returns whether the printer is currently active (i.e.
|
|
|
|
* accepts new jobs).
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if @printer is active
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
gboolean
|
|
|
|
gtk_printer_is_active (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
|
|
return printer->priv->is_active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_printer_set_is_active (GtkPrinter *printer,
|
|
|
|
gboolean val)
|
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
printer->priv->is_active = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
/**
|
|
|
|
* gtk_printer_is_virtual:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Returns whether the printer is virtual (i.e. does not
|
|
|
|
* represent actual printer hardware, but something like
|
|
|
|
* a CUPS class).
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if @printer is virtual
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
gboolean
|
|
|
|
gtk_printer_is_virtual (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
|
|
|
|
|
|
|
return printer->priv->is_virtual;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gtk_printer_is_new (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
|
|
return printer->priv->is_new;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_printer_set_is_new (GtkPrinter *printer,
|
|
|
|
gboolean val)
|
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
printer->priv->is_new = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-24 03:47:22 +00:00
|
|
|
/**
|
|
|
|
* gtk_printer_is_default:
|
|
|
|
* @printer: a #GtkPrinter
|
|
|
|
*
|
|
|
|
* Returns whether the printer is the default printer.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if @printer is the default
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
gboolean
|
|
|
|
gtk_printer_is_default (GtkPrinter *printer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
|
|
|
|
|
|
|
return printer->priv->is_default;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2006-04-24 03:47:22 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINTER (printer));
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
printer->priv->is_default = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_printer_request_details (GtkPrinter *printer)
|
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->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-04-24 03:47:22 +00:00
|
|
|
_gtk_printer_get_options (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
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
|
|
|
|
return backend_class->printer_get_options (printer, settings, page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gtk_printer_mark_conflicts (GtkPrinter *printer,
|
|
|
|
GtkPrinterOptionSet *options)
|
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
|
|
|
|
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)
|
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->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
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->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 *
|
|
|
|
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
2006-04-24 03:47:22 +00:00
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
gint cache_fd)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
return backend_class->printer_create_cairo_surface (printer, width, height, cache_fd);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
_gtk_printer_list_papers (GtkPrinter *printer)
|
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
return backend_class->printer_list_papers (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-24 03:47:22 +00:00
|
|
|
_gtk_printer_get_hard_margins (GtkPrinter *printer,
|
|
|
|
gdouble *top,
|
|
|
|
gdouble *bottom,
|
|
|
|
gdouble *left,
|
|
|
|
gdouble *right)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
backend_class->printer_get_hard_margins (printer, top, bottom, left, right);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gtk_printer_compare (GtkPrinter *a, GtkPrinter *b)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#define __GTK_PRINTER_C__
|
|
|
|
#include "gtkaliasdef.c"
|