Commit 3f529199 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Added gtk_print_job_set/get_track_print_status

2006-05-15  Alexander Larsson  <alexl@redhat.com>

	* gtk/gtkprintjob.[ch]:
	Added gtk_print_job_set/get_track_print_status

	* gtk/gtkprintoperation-private.h:
	* gtk/gtkprintoperation.[ch]:
	Add gtk_print_operation_set_track_print_status.

	* gtk/gtkprintoperation-unix.c:
	Implement track_print_status on unix

	* gtk/gtkprintoperation-win32.c:
	Implement track_print_status on win32

	* gtk/gtk.symbols:
	Added symbols

	* modules/printbackends/cups/gtkprintbackendcups.c:
	Implement track_print_status for cups

	* tests/print-editor.c:
	Test track_print_status.
parent 9dc49c45
2006-05-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtkprintjob.[ch]:
Added gtk_print_job_set/get_track_print_status
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation.[ch]:
Add gtk_print_operation_set_track_print_status.
* gtk/gtkprintoperation-unix.c:
Implement track_print_status on unix
* gtk/gtkprintoperation-win32.c:
Implement track_print_status on win32
* gtk/gtk.symbols:
Added symbols
* modules/printbackends/cups/gtkprintbackendcups.c:
Implement track_print_status for cups
* tests/print-editor.c:
Test track_print_status.
2006-05-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintoperation.c: Do page rendering in an idle when
......
2006-05-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtkprintjob.[ch]:
Added gtk_print_job_set/get_track_print_status
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation.[ch]:
Add gtk_print_operation_set_track_print_status.
* gtk/gtkprintoperation-unix.c:
Implement track_print_status on unix
* gtk/gtkprintoperation-win32.c:
Implement track_print_status on win32
* gtk/gtk.symbols:
Added symbols
* modules/printbackends/cups/gtkprintbackendcups.c:
Implement track_print_status for cups
* tests/print-editor.c:
Test track_print_status.
2006-05-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintoperation.c: Do page rendering in an idle when
......
......@@ -2673,6 +2673,8 @@ gtk_print_job_set_status
gtk_print_job_set_source_file
gtk_print_job_get_surface
gtk_print_job_send
gtk_print_job_set_track_print_status
gtk_print_job_get_track_print_status
#endif
#endif
#endif
......@@ -2693,6 +2695,7 @@ gtk_print_operation_set_use_full_page
gtk_print_operation_set_unit
gtk_print_operation_set_show_dialog
gtk_print_operation_set_pdf_target
gtk_print_operation_set_track_print_status
gtk_print_operation_run
gtk_print_operation_run_async
gtk_print_operation_get_status
......
......@@ -55,9 +55,10 @@ struct _GtkPrintJobPrivate
GtkPrintSettings *settings;
GtkPageSetup *page_setup;
gint printer_set : 1;
gint page_setup_set : 1;
gint settings_set : 1;
guint printer_set : 1;
guint page_setup_set : 1;
guint settings_set : 1;
guint track_print_status : 1;
};
......@@ -180,7 +181,8 @@ gtk_print_job_init (GtkPrintJob *job)
priv->settings_set = FALSE;
priv->page_setup_set = FALSE;
priv->status = GTK_PRINT_STATUS_INITIAL;
priv->track_print_status = FALSE;
job->print_pages = GTK_PRINT_PAGES_ALL;
job->page_ranges = NULL;
job->num_page_ranges = 0;
......@@ -473,6 +475,57 @@ gtk_print_job_get_surface (GtkPrintJob *job,
return priv->surface;
}
/**
* gtk_print_job_set_track_print_status:
* @job: a #GtkPrintJob
* @track_status: %TRUE to track status after printing
*
* If track_status is %TRUE, the print job will try to continue report
* on the status of the print job in the printer queues and printer. This
* can allow your application to show things like "out of paper" issues,
* and when the print job actually reaches the printer.
*
* This function is often implemented using some form of polling, so it should
* not be enabled unless needed.
*
* Since: 2.10
*/
void
gtk_print_job_set_track_print_status (GtkPrintJob *job,
gboolean track_status)
{
GtkPrintJobPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_JOB (job));
priv = job->priv;
priv->track_print_status = track_status;
}
/**
* gtk_print_job_get_track_print_status:
* @job: a #GtkPrintJob
*
* Returns wheter jobs will be tracked after printing.
* For details, see gtk_print_job_set_track_print_status().
*
* Return value: %TRUE if print job status will be reported after printing
*
* Since: 2.10
*/
gboolean
gtk_print_job_get_track_print_status (GtkPrintJob *job)
{
GtkPrintJobPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
priv = job->priv;
return priv->track_print_status;
}
static void
gtk_print_job_set_property (GObject *object,
guint prop_id,
......
......@@ -82,25 +82,28 @@ struct _GtkPrintJobClass
};
GType gtk_print_job_get_type (void) G_GNUC_CONST;
GtkPrintJob *gtk_print_job_new (const gchar *title,
GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
GtkPrintSettings *gtk_print_job_get_settings (GtkPrintJob *job);
GtkPrinter *gtk_print_job_get_printer (GtkPrintJob *job);
G_CONST_RETURN gchar *gtk_print_job_get_title (GtkPrintJob *job);
GtkPrintStatus gtk_print_job_get_status (GtkPrintJob *job);
gboolean gtk_print_job_set_source_file (GtkPrintJob *job,
const gchar *filename,
GError **error);
cairo_surface_t *gtk_print_job_get_surface (GtkPrintJob *job,
GError **error);
gboolean gtk_print_job_send (GtkPrintJob *job,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify,
GError **error);
GtkPrintJob *gtk_print_job_new (const gchar *title,
GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
GtkPrintSettings *gtk_print_job_get_settings (GtkPrintJob *job);
GtkPrinter *gtk_print_job_get_printer (GtkPrintJob *job);
G_CONST_RETURN gchar *gtk_print_job_get_title (GtkPrintJob *job);
GtkPrintStatus gtk_print_job_get_status (GtkPrintJob *job);
gboolean gtk_print_job_set_source_file (GtkPrintJob *job,
const gchar *filename,
GError **error);
cairo_surface_t *gtk_print_job_get_surface (GtkPrintJob *job,
GError **error);
void gtk_print_job_set_track_print_status (GtkPrintJob *job,
gboolean track_status);
gboolean gtk_print_job_get_track_print_status (GtkPrintJob *job);
gboolean gtk_print_job_send (GtkPrintJob *job,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify,
GError **error);
G_END_DECLS
......
......@@ -37,6 +37,7 @@ struct _GtkPrintOperationPrivate
gboolean use_full_page;
GtkUnit unit;
gboolean show_dialog;
gboolean track_print_status;
char *pdf_target;
/* Data for the print job: */
......
......@@ -233,7 +233,9 @@ finish_print (PrintResponseData *rdata,
printer,
settings,
page_setup);
gtk_print_job_set_track_print_status (op_unix->job, priv->track_print_status);
rdata->op->priv->surface = gtk_print_job_get_surface (op_unix->job, rdata->error);
if (op->priv->surface == NULL)
{
......
......@@ -471,11 +471,15 @@ win32_end_run (GtkPrintOperation *op)
HANDLE printerHandle = 0;
EndDoc (op_win32->hdc);
devnames = GlobalLock (op_win32->devnames);
if (!OpenPrinterW (((gunichar2 *)devnames) + devnames->wDeviceOffset,
&printerHandle, NULL))
printerHandle = 0;
GlobalUnlock (op_win32->devnames);
if (op->track_print_status)
{
devnames = GlobalLock (op_win32->devnames);
if (!OpenPrinterW (((gunichar2 *)devnames) + devnames->wDeviceOffset,
&printerHandle, NULL))
printerHandle = 0;
GlobalUnlock (op_win32->devnames);
}
GlobalFree(op_win32->devmode);
GlobalFree(op_win32->devnames);
......
......@@ -46,6 +46,7 @@ enum {
PROP_N_PAGES,
PROP_CURRENT_PAGE,
PROP_USE_FULL_PAGE,
PROP_TRACK_PRINT_STATUS,
PROP_UNIT,
PROP_SHOW_DIALOG,
PROP_PDF_TARGET,
......@@ -118,6 +119,7 @@ gtk_print_operation_init (GtkPrintOperation *operation)
priv->use_full_page = FALSE;
priv->show_dialog = TRUE;
priv->pdf_target = NULL;
priv->track_print_status = FALSE;
priv->unit = GTK_UNIT_PIXEL;
......@@ -153,6 +155,9 @@ gtk_print_operation_set_property (GObject *object,
case PROP_USE_FULL_PAGE:
gtk_print_operation_set_use_full_page (op, g_value_get_boolean (value));
break;
case PROP_TRACK_PRINT_STATUS:
gtk_print_operation_set_track_print_status (op, g_value_get_boolean (value));
break;
case PROP_UNIT:
gtk_print_operation_set_unit (op, g_value_get_enum (value));
break;
......@@ -197,6 +202,9 @@ gtk_print_operation_get_property (GObject *object,
case PROP_USE_FULL_PAGE:
g_value_set_boolean (value, priv->use_full_page);
break;
case PROP_TRACK_PRINT_STATUS:
g_value_set_boolean (value, priv->track_print_status);
break;
case PROP_UNIT:
g_value_set_enum (value, priv->unit);
break;
......@@ -470,6 +478,26 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
GTK_PARAM_READWRITE));
/**
* GtkPrintOperation:track-print-status:
*
* If %TRUE, the print operation will try to continue report on the status of
* the print job in the printer queues and printer. This can allow your
* application to show things like "out of paper" issues, and when the
* print job actually reaches the printer. However, this is often
* implemented using polling, and should not be enabled unless needed.
*
* Since: 2.10
*/
g_object_class_install_property (gobject_class,
PROP_USE_FULL_PAGE,
g_param_spec_boolean ("track-print-status",
P_("Track Print Status"),
P_("If %TRUE then the print operation will continue to report on the print job status after the print data has been sent to the printer or print server."),
FALSE,
GTK_PARAM_READWRITE));
/**
* GtkPrintOperation:unit:
*
......@@ -870,6 +898,40 @@ gtk_print_operation_set_unit (GtkPrintOperation *op,
}
}
/**
* gtk_print_operation_set_track_print_status:
* @op: a #GtkPrintOperation
* @track_status: %TRUE to track status after printing
*
* If track_status is %TRUE, the print operation will try to continue report
* on the status of the print job in the printer queues and printer. This
* can allow your application to show things like "out of paper" issues,
* and when the print job actually reaches the printer.
*
* This function is often implemented using some form of polling, so it should
* not be enabled unless needed.
*
* Since: 2.10
*/
void
gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
gboolean track_status)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
priv = op->priv;
if (priv->track_print_status != track_status)
{
priv->track_print_status = track_status;
g_object_notify (G_OBJECT (op), "track-print-status");
}
}
void
_gtk_print_operation_set_status (GtkPrintOperation *op,
GtkPrintStatus status,
......
......@@ -128,6 +128,8 @@ void gtk_print_operation_set_show_dialog (GtkPrintOper
gboolean show_dialog);
void gtk_print_operation_set_pdf_target (GtkPrintOperation *op,
const gchar *filename);
void gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
gboolean track_status);
GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
GtkWindow *parent,
GError **error);
......
......@@ -321,15 +321,14 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
if ((attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL)
job_id = attr->values[0].integer;
if (job_id == 0)
gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_FINISHED);
else
{
gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_PENDING);
cups_begin_polling_info (print_backend, ps->job, job_id);
}
}
if (!gtk_print_job_get_track_print_status (ps->job) || job_id == 0)
gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_FINISHED);
else
{
gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_PENDING);
cups_begin_polling_info (print_backend, ps->job, job_id);
}
}
else
gtk_print_job_set_status (ps->job, GTK_PRINT_STATUS_FINISHED_ABORTED);
......
......@@ -404,6 +404,7 @@ do_print (GtkAction *action)
print = gtk_print_operation_new ();
gtk_print_operation_set_track_print_status (print, TRUE);
if (settings != NULL)
gtk_print_operation_set_print_settings (print, settings);
......
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