Commit 809c8d56 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Use gtk_printer_accepts_ps here.

2006-06-12  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkprintunixdialog.c (is_printer_active): Use
	gtk_printer_accepts_ps here.

	* modules/printbackends/pdf/gtkprintbackendpdf.c (gtk_print_backend_pdf_init):
	Mark the virtual "Print to PDF" printer as not accepting PS.

	* gtk/gtk.symbols:
	* gtk/gtkprinter.h:
	* gtk/gtkprinter.c: Add two new properties accepts-pdf and
	accepts-ps (with getters) to allow learning supported formats.
parent c6d1d9dd
2006-06-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintunixdialog.c (is_printer_active): Use
gtk_printer_accepts_ps here.
* modules/printbackends/pdf/gtkprintbackendpdf.c (gtk_print_backend_pdf_init):
Mark the virtual "Print to PDF" printer as not accepting PS.
* gtk/gtk.symbols:
* gtk/gtkprinter.h:
* gtk/gtkprinter.c: Add two new properties accepts-pdf and
accepts-ps (with getters) to allow learning supported formats.
* gtk/gtkprintjob.h: Add a GTK_PRINT_CAPABILITY_GENERATE_PDF
capability.
......
2006-06-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintunixdialog.c (is_printer_active): Use
gtk_printer_accepts_ps here.
* modules/printbackends/pdf/gtkprintbackendpdf.c (gtk_print_backend_pdf_init):
Mark the virtual "Print to PDF" printer as not accepting PS.
* gtk/gtk.symbols:
* gtk/gtkprinter.h:
* gtk/gtkprinter.c: Add two new properties accepts-pdf and
accepts-ps (with getters) to allow learning supported formats.
* gtk/gtkprintjob.h: Add a GTK_PRINT_CAPABILITY_GENERATE_PDF
capability.
......
......@@ -2594,6 +2594,8 @@ gtk_printer_get_location
gtk_printer_get_icon_name
gtk_printer_get_job_count
gtk_printer_is_virtual
gtk_printer_accepts_pdf
gtk_printer_accepts_ps
gtk_printer_compare
#endif
#endif
......
......@@ -43,11 +43,13 @@ struct _GtkPrinterPrivate
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;
guint is_active : 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;
gchar *state_message;
gint job_count;
......@@ -68,7 +70,9 @@ enum {
PROP_STATE_MESSAGE,
PROP_LOCATION,
PROP_ICON_NAME,
PROP_JOB_COUNT
PROP_JOB_COUNT,
PROP_ACCEPTS_PDF,
PROP_ACCEPTS_PS
};
static guint signals[LAST_SIGNAL] = { 0 };
......@@ -130,6 +134,20 @@ gtk_printer_class_init (GtkPrinterClass *class)
P_("FALSE if this represents a real hardware printer"),
FALSE,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
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"),
TRUE,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
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));
g_object_class_install_property (G_OBJECT_CLASS (class),
PROP_STATE_MESSAGE,
g_param_spec_string ("state-message",
......@@ -197,6 +215,8 @@ gtk_printer_init (GtkPrinter *printer)
priv->is_active = TRUE;
priv->is_new = TRUE;
priv->has_details = FALSE;
priv->accepts_pdf = TRUE;
priv->accepts_ps = TRUE;
priv->state_message = NULL;
priv->job_count = 0;
......@@ -243,6 +263,14 @@ gtk_printer_set_property (GObject *object,
priv->is_virtual = g_value_get_boolean (value);
break;
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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -290,6 +318,15 @@ gtk_printer_get_property (GObject *object,
case PROP_JOB_COUNT:
g_value_set_int (value, priv->job_count);
break;
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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -607,6 +644,22 @@ gtk_printer_is_virtual (GtkPrinter *printer)
return printer->priv->is_virtual;
}
gboolean
gtk_printer_accepts_pdf (GtkPrinter *printer)
{
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
return printer->priv->accepts_pdf;
}
gboolean
gtk_printer_accepts_ps (GtkPrinter *printer)
{
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
return printer->priv->accepts_ps;
}
gboolean
gtk_printer_is_new (GtkPrinter *printer)
{
......
......@@ -77,6 +77,8 @@ gint gtk_printer_get_job_count (GtkPrinter *printer
gboolean gtk_printer_is_active (GtkPrinter *printer);
gboolean gtk_printer_is_virtual (GtkPrinter *printer);
gboolean gtk_printer_is_default (GtkPrinter *printer);
gboolean gtk_printer_accepts_pdf (GtkPrinter *printer);
gboolean gtk_printer_accepts_ps (GtkPrinter *printer);
gint gtk_printer_compare (GtkPrinter *a,
GtkPrinter *b);
......
......@@ -586,17 +586,12 @@ is_printer_active (GtkTreeModel *model,
if (result)
{
/* FIXME needs some printer capabilities
*/
if ((priv->manual_capabilities & GTK_PRINT_CAPABILITY_GENERATE_PDF) == 0 &&
strcmp (gtk_printer_get_name (printer), _("Print to PDF")) == 0)
result = FALSE;
g_print ("testing printer \"%s\" result %d\n",
gtk_printer_get_name (printer), result);
if ((priv->manual_capabilities & GTK_PRINT_CAPABILITY_GENERATE_PDF) == 0)
result = gtk_printer_accepts_ps (printer);
}
g_object_unref (printer);
return result;
}
......@@ -2753,3 +2748,4 @@ gtk_print_unix_dialog_set_manual_capabilities (GtkPrintUnixDialog *dialog,
#define __GTK_PRINT_UNIX_DIALOG_C__
#include "gtkaliasdef.c"
......@@ -338,9 +338,12 @@ gtk_print_backend_pdf_init (GtkPrintBackendPdf *backend)
{
GtkPrinter *printer;
printer = gtk_printer_new (_("Print to PDF"),
GTK_PRINT_BACKEND (backend),
TRUE);
printer = g_object_new (GTK_TYPE_PRINTER,
"name", _("Print to PDF"),
"backend", backend,
"is-virtual", TRUE,
"accepts-ps", FALSE,
NULL);
gtk_printer_set_has_details (printer, TRUE);
gtk_printer_set_icon_name (printer, "floppy");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment