Clean up APIs: Make async a setting instead of separate calls. Combine
2006-06-07 Alexander Larsson <alexl@redhat.com> * gtk/gtk.symbols: * gtk/gtkprintoperation-private.h: * gtk/gtkprintoperation-unix.c: * gtk/gtkprintoperation.[ch]: Clean up APIs: Make async a setting instead of separate calls. Combine settings like show_dialog, show_preview and pdf_target into an action enum that you pass to gtk_print_dialog_run(). * tests/print-editor.c: * tests/testnouiprint.c: * tests/testprint.c: * demos/gtk-demo/printing.c: Update to new APIs
This commit is contained in:
committed by
Alexander Larsson
parent
36f7ed300a
commit
9bea38595f
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
|||||||
|
2006-06-07 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtk.symbols:
|
||||||
|
* gtk/gtkprintoperation-private.h:
|
||||||
|
* gtk/gtkprintoperation-unix.c:
|
||||||
|
* gtk/gtkprintoperation.[ch]:
|
||||||
|
Clean up APIs:
|
||||||
|
Make async a setting instead of separate calls.
|
||||||
|
Combine settings like show_dialog, show_preview and pdf_target into
|
||||||
|
an action enum that you pass to gtk_print_dialog_run().
|
||||||
|
|
||||||
|
* tests/print-editor.c:
|
||||||
|
* tests/testnouiprint.c:
|
||||||
|
* tests/testprint.c:
|
||||||
|
* demos/gtk-demo/printing.c:
|
||||||
|
Update to new APIs
|
||||||
|
|
||||||
2006-06-07 Bastien Nocera <hadess@hadess.net>
|
2006-06-07 Bastien Nocera <hadess@hadess.net>
|
||||||
|
|
||||||
* configure.in: Update the ATK requirements (#344148)
|
* configure.in: Update the ATK requirements (#344148)
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
2006-06-07 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtk.symbols:
|
||||||
|
* gtk/gtkprintoperation-private.h:
|
||||||
|
* gtk/gtkprintoperation-unix.c:
|
||||||
|
* gtk/gtkprintoperation.[ch]:
|
||||||
|
Clean up APIs:
|
||||||
|
Make async a setting instead of separate calls.
|
||||||
|
Combine settings like show_dialog, show_preview and pdf_target into
|
||||||
|
an action enum that you pass to gtk_print_dialog_run().
|
||||||
|
|
||||||
|
* tests/print-editor.c:
|
||||||
|
* tests/testnouiprint.c:
|
||||||
|
* tests/testprint.c:
|
||||||
|
* demos/gtk-demo/printing.c:
|
||||||
|
Update to new APIs
|
||||||
|
|
||||||
2006-06-07 Bastien Nocera <hadess@hadess.net>
|
2006-06-07 Bastien Nocera <hadess@hadess.net>
|
||||||
|
|
||||||
* configure.in: Update the ATK requirements (#344148)
|
* configure.in: Update the ATK requirements (#344148)
|
||||||
|
|||||||
@ -156,7 +156,7 @@ do_printing (GtkWidget *do_widget)
|
|||||||
g_signal_connect (G_OBJECT (operation), "end-print",
|
g_signal_connect (G_OBJECT (operation), "end-print",
|
||||||
G_CALLBACK (end_print), data);
|
G_CALLBACK (end_print), data);
|
||||||
|
|
||||||
gtk_print_operation_run (operation, GTK_WINDOW (do_widget), &error);
|
gtk_print_operation_run (operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW (do_widget), &error);
|
||||||
|
|
||||||
g_object_unref (operation);
|
g_object_unref (operation);
|
||||||
|
|
||||||
|
|||||||
@ -2697,14 +2697,12 @@ gtk_print_operation_set_n_pages
|
|||||||
gtk_print_operation_set_current_page
|
gtk_print_operation_set_current_page
|
||||||
gtk_print_operation_set_use_full_page
|
gtk_print_operation_set_use_full_page
|
||||||
gtk_print_operation_set_unit
|
gtk_print_operation_set_unit
|
||||||
gtk_print_operation_set_show_dialog
|
|
||||||
gtk_print_operation_set_pdf_target
|
gtk_print_operation_set_pdf_target
|
||||||
gtk_print_operation_set_track_print_status
|
gtk_print_operation_set_track_print_status
|
||||||
gtk_print_operation_set_show_progress
|
gtk_print_operation_set_show_progress
|
||||||
gtk_print_operation_set_show_preview
|
|
||||||
gtk_print_operation_set_custom_tab_label
|
gtk_print_operation_set_custom_tab_label
|
||||||
|
gtk_print_operation_get_error
|
||||||
gtk_print_operation_run
|
gtk_print_operation_run
|
||||||
gtk_print_operation_run_async
|
|
||||||
gtk_print_operation_get_status
|
gtk_print_operation_get_status
|
||||||
gtk_print_operation_get_status_string
|
gtk_print_operation_get_status_string
|
||||||
gtk_print_operation_is_finished
|
gtk_print_operation_is_finished
|
||||||
|
|||||||
@ -27,7 +27,9 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
struct _GtkPrintOperationPrivate
|
struct _GtkPrintOperationPrivate
|
||||||
{
|
{
|
||||||
|
GtkPrintOperationAction action;
|
||||||
GtkPrintStatus status;
|
GtkPrintStatus status;
|
||||||
|
GError *error;
|
||||||
gchar *status_string;
|
gchar *status_string;
|
||||||
GtkPageSetup *default_page_setup;
|
GtkPageSetup *default_page_setup;
|
||||||
GtkPrintSettings *print_settings;
|
GtkPrintSettings *print_settings;
|
||||||
@ -37,11 +39,10 @@ struct _GtkPrintOperationPrivate
|
|||||||
GtkUnit unit;
|
GtkUnit unit;
|
||||||
gchar *pdf_target;
|
gchar *pdf_target;
|
||||||
guint use_full_page : 1;
|
guint use_full_page : 1;
|
||||||
guint show_dialog : 1;
|
|
||||||
guint show_preview : 1;
|
|
||||||
guint track_print_status : 1;
|
guint track_print_status : 1;
|
||||||
guint show_progress : 1;
|
guint show_progress : 1;
|
||||||
guint cancelled : 1;
|
guint cancelled : 1;
|
||||||
|
guint allow_async : 1;
|
||||||
guint is_sync : 1;
|
guint is_sync : 1;
|
||||||
|
|
||||||
guint print_pages_idle_id;
|
guint print_pages_idle_id;
|
||||||
@ -84,13 +85,15 @@ struct _GtkPrintOperationPrivate
|
|||||||
|
|
||||||
typedef void (* GtkPrintOperationPrintFunc) (GtkPrintOperation *op,
|
typedef void (* GtkPrintOperationPrintFunc) (GtkPrintOperation *op,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
gboolean is_preview);
|
gboolean do_print,
|
||||||
|
GtkPrintOperationResult result);
|
||||||
|
|
||||||
GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
|
GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
|
||||||
|
gboolean show_dialog,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
gboolean *do_print,
|
gboolean *do_print);
|
||||||
GError **error);
|
|
||||||
void _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
|
void _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
|
||||||
|
gboolean show_dialog,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GtkPrintOperationPrintFunc print_cb);
|
GtkPrintOperationPrintFunc print_cb);
|
||||||
void _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
void _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
||||||
|
|||||||
@ -350,7 +350,6 @@ typedef struct
|
|||||||
{
|
{
|
||||||
GtkPrintOperation *op;
|
GtkPrintOperation *op;
|
||||||
gboolean do_print;
|
gboolean do_print;
|
||||||
GError **error;
|
|
||||||
GtkPrintOperationResult result;
|
GtkPrintOperationResult result;
|
||||||
GtkPrintOperationPrintFunc print_cb;
|
GtkPrintOperationPrintFunc print_cb;
|
||||||
GDestroyNotify destroy;
|
GDestroyNotify destroy;
|
||||||
@ -391,7 +390,7 @@ finish_print (PrintResponseData *rdata,
|
|||||||
GtkPrintOperationUnix *op_unix;
|
GtkPrintOperationUnix *op_unix;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
op_unix = g_new0 (GtkPrintOperationUnix, 1);
|
op_unix = g_new0 (GtkPrintOperationUnix, 1);
|
||||||
priv->platform_data = op_unix;
|
priv->platform_data = op_unix;
|
||||||
priv->free_platform_data = (GDestroyNotify) op_unix_free;
|
priv->free_platform_data = (GDestroyNotify) op_unix_free;
|
||||||
op_unix->parent = rdata->parent;
|
op_unix->parent = rdata->parent;
|
||||||
@ -404,9 +403,10 @@ finish_print (PrintResponseData *rdata,
|
|||||||
op_unix->job = job;
|
op_unix->job = job;
|
||||||
gtk_print_job_set_track_print_status (job, priv->track_print_status);
|
gtk_print_job_set_track_print_status (job, priv->track_print_status);
|
||||||
|
|
||||||
op_unix->surface = gtk_print_job_get_surface (job, rdata->error);
|
op_unix->surface = gtk_print_job_get_surface (job, &priv->error);
|
||||||
if (op_unix->surface == NULL)
|
if (op_unix->surface == NULL)
|
||||||
{
|
{
|
||||||
|
rdata->result = GTK_PRINT_OPERATION_RESULT_ERROR;
|
||||||
rdata->do_print = FALSE;
|
rdata->do_print = FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -435,12 +435,7 @@ finish_print (PrintResponseData *rdata,
|
|||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (rdata->print_cb)
|
if (rdata->print_cb)
|
||||||
{
|
rdata->print_cb (op, rdata->do_print, rdata->parent, rdata->result);
|
||||||
if (rdata->do_print)
|
|
||||||
rdata->print_cb (op, rdata->parent, is_preview);
|
|
||||||
else
|
|
||||||
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rdata->destroy)
|
if (rdata->destroy)
|
||||||
rdata->destroy (rdata);
|
rdata->destroy (rdata);
|
||||||
@ -504,10 +499,7 @@ found_printer (GtkPrinter *printer,
|
|||||||
|
|
||||||
if (printer != NULL)
|
if (printer != NULL)
|
||||||
{
|
{
|
||||||
if (priv->show_preview)
|
rdata->result = GTK_PRINT_OPERATION_RESULT_APPLY;
|
||||||
rdata->result = GTK_PRINT_OPERATION_RESULT_PREVIEW;
|
|
||||||
else
|
|
||||||
rdata->result = GTK_PRINT_OPERATION_RESULT_APPLY;
|
|
||||||
|
|
||||||
rdata->do_print = TRUE;
|
rdata->do_print = TRUE;
|
||||||
|
|
||||||
@ -536,6 +528,7 @@ found_printer (GtkPrinter *printer,
|
|||||||
|
|
||||||
void
|
void
|
||||||
_gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
|
_gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
|
||||||
|
gboolean show_dialog,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GtkPrintOperationPrintFunc print_cb)
|
GtkPrintOperationPrintFunc print_cb)
|
||||||
{
|
{
|
||||||
@ -547,13 +540,12 @@ _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation
|
|||||||
rdata->op = g_object_ref (op);
|
rdata->op = g_object_ref (op);
|
||||||
rdata->do_print = FALSE;
|
rdata->do_print = FALSE;
|
||||||
rdata->result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
rdata->result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
||||||
rdata->error = NULL;
|
|
||||||
rdata->print_cb = print_cb;
|
rdata->print_cb = print_cb;
|
||||||
rdata->parent = parent;
|
rdata->parent = parent;
|
||||||
rdata->loop = NULL;
|
rdata->loop = NULL;
|
||||||
rdata->destroy = print_response_data_free;
|
rdata->destroy = print_response_data_free;
|
||||||
|
|
||||||
if (op->priv->show_dialog)
|
if (show_dialog)
|
||||||
{
|
{
|
||||||
pd = get_print_dialog (op, parent);
|
pd = get_print_dialog (op, parent);
|
||||||
gtk_window_set_modal (GTK_WINDOW (pd), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (pd), TRUE);
|
||||||
@ -608,9 +600,9 @@ _gtk_print_operation_platform_backend_resize_preview_surface (GtkPrintOperation
|
|||||||
|
|
||||||
GtkPrintOperationResult
|
GtkPrintOperationResult
|
||||||
_gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
|
_gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
|
||||||
|
gboolean show_dialog,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
gboolean *do_print,
|
gboolean *do_print)
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
GtkWidget *pd;
|
GtkWidget *pd;
|
||||||
PrintResponseData rdata;
|
PrintResponseData rdata;
|
||||||
@ -620,13 +612,12 @@ _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
|
|||||||
rdata.op = op;
|
rdata.op = op;
|
||||||
rdata.do_print = FALSE;
|
rdata.do_print = FALSE;
|
||||||
rdata.result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
rdata.result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
||||||
rdata.error = error;
|
|
||||||
rdata.print_cb = NULL;
|
rdata.print_cb = NULL;
|
||||||
rdata.destroy = NULL;
|
rdata.destroy = NULL;
|
||||||
rdata.parent = parent;
|
rdata.parent = parent;
|
||||||
rdata.loop = NULL;
|
rdata.loop = NULL;
|
||||||
|
|
||||||
if (op->priv->show_dialog)
|
if (show_dialog)
|
||||||
{
|
{
|
||||||
pd = get_print_dialog (op, parent);
|
pd = get_print_dialog (op, parent);
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
#define GTK_PRINT_OPERATION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationPrivate))
|
#define GTK_PRINT_OPERATION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationPrivate))
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
DONE,
|
||||||
BEGIN_PRINT,
|
BEGIN_PRINT,
|
||||||
PAGINATE,
|
PAGINATE,
|
||||||
REQUEST_PAGE_SETUP,
|
REQUEST_PAGE_SETUP,
|
||||||
@ -59,9 +60,8 @@ enum {
|
|||||||
PROP_USE_FULL_PAGE,
|
PROP_USE_FULL_PAGE,
|
||||||
PROP_TRACK_PRINT_STATUS,
|
PROP_TRACK_PRINT_STATUS,
|
||||||
PROP_UNIT,
|
PROP_UNIT,
|
||||||
PROP_SHOW_DIALOG,
|
|
||||||
PROP_SHOW_PREVIEW,
|
|
||||||
PROP_SHOW_PROGRESS,
|
PROP_SHOW_PROGRESS,
|
||||||
|
PROP_ALLOW_ASYNC,
|
||||||
PROP_PDF_TARGET,
|
PROP_PDF_TARGET,
|
||||||
PROP_STATUS,
|
PROP_STATUS,
|
||||||
PROP_STATUS_STRING,
|
PROP_STATUS_STRING,
|
||||||
@ -128,6 +128,9 @@ gtk_print_operation_finalize (GObject *object)
|
|||||||
if (priv->show_progress_timeout_id > 0)
|
if (priv->show_progress_timeout_id > 0)
|
||||||
g_source_remove (priv->show_progress_timeout_id);
|
g_source_remove (priv->show_progress_timeout_id);
|
||||||
|
|
||||||
|
if (priv->error)
|
||||||
|
g_error_free (priv->error);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_print_operation_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gtk_print_operation_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +149,6 @@ gtk_print_operation_init (GtkPrintOperation *operation)
|
|||||||
priv->nr_of_pages = -1;
|
priv->nr_of_pages = -1;
|
||||||
priv->current_page = -1;
|
priv->current_page = -1;
|
||||||
priv->use_full_page = FALSE;
|
priv->use_full_page = FALSE;
|
||||||
priv->show_dialog = TRUE;
|
|
||||||
priv->show_preview = FALSE;
|
|
||||||
priv->show_progress = FALSE;
|
priv->show_progress = FALSE;
|
||||||
priv->pdf_target = NULL;
|
priv->pdf_target = NULL;
|
||||||
priv->track_print_status = FALSE;
|
priv->track_print_status = FALSE;
|
||||||
@ -183,6 +184,9 @@ preview_iface_end_preview (GtkPrintOperationPreview *preview)
|
|||||||
g_main_loop_quit (op->priv->rloop);
|
g_main_loop_quit (op->priv->rloop);
|
||||||
|
|
||||||
op->priv->end_run (op, op->priv->is_sync, TRUE);
|
op->priv->end_run (op, op->priv->is_sync, TRUE);
|
||||||
|
|
||||||
|
g_signal_emit (op, signals[DONE], 0,
|
||||||
|
GTK_PRINT_OPERATION_RESULT_APPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -282,11 +286,8 @@ gtk_print_operation_set_property (GObject *object,
|
|||||||
case PROP_UNIT:
|
case PROP_UNIT:
|
||||||
gtk_print_operation_set_unit (op, g_value_get_enum (value));
|
gtk_print_operation_set_unit (op, g_value_get_enum (value));
|
||||||
break;
|
break;
|
||||||
case PROP_SHOW_DIALOG:
|
case PROP_ALLOW_ASYNC:
|
||||||
gtk_print_operation_set_show_dialog (op, g_value_get_boolean (value));
|
gtk_print_operation_set_allow_async (op, g_value_get_boolean (value));
|
||||||
break;
|
|
||||||
case PROP_SHOW_PREVIEW:
|
|
||||||
gtk_print_operation_set_show_preview (op, g_value_get_boolean (value));
|
|
||||||
break;
|
break;
|
||||||
case PROP_SHOW_PROGRESS:
|
case PROP_SHOW_PROGRESS:
|
||||||
gtk_print_operation_set_show_progress (op, g_value_get_boolean (value));
|
gtk_print_operation_set_show_progress (op, g_value_get_boolean (value));
|
||||||
@ -338,11 +339,8 @@ gtk_print_operation_get_property (GObject *object,
|
|||||||
case PROP_UNIT:
|
case PROP_UNIT:
|
||||||
g_value_set_enum (value, priv->unit);
|
g_value_set_enum (value, priv->unit);
|
||||||
break;
|
break;
|
||||||
case PROP_SHOW_DIALOG:
|
case PROP_ALLOW_ASYNC:
|
||||||
g_value_set_boolean (value, priv->show_dialog);
|
g_value_set_boolean (value, priv->allow_async);
|
||||||
break;
|
|
||||||
case PROP_SHOW_PREVIEW:
|
|
||||||
g_value_set_boolean (value, priv->show_preview);
|
|
||||||
break;
|
break;
|
||||||
case PROP_SHOW_PROGRESS:
|
case PROP_SHOW_PROGRESS:
|
||||||
g_value_set_boolean (value, priv->show_progress);
|
g_value_set_boolean (value, priv->show_progress);
|
||||||
@ -547,6 +545,31 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
|
|||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof (GtkPrintOperationPrivate));
|
g_type_class_add_private (gobject_class, sizeof (GtkPrintOperationPrivate));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkPrintOperation::done:
|
||||||
|
* @operation: the #GtkPrintOperation on which the signal was emitted
|
||||||
|
* @result: the result of the print operation
|
||||||
|
*
|
||||||
|
* Gets emitted when the print operation run has finished doing
|
||||||
|
* everything required for printing. @result gives you information
|
||||||
|
* about what happened during the run. If @result is
|
||||||
|
* GTK_PRINT_OPERATION_RESULT_ERROR then you can call
|
||||||
|
* gtk_print_operation_get_error() for more information.
|
||||||
|
*
|
||||||
|
* If you enabled print status tracking then gtk_print_operation_is_finished()
|
||||||
|
* may still return false after this was emitted.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
*/
|
||||||
|
signals[DONE] =
|
||||||
|
g_signal_new (I_("done"),
|
||||||
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (GtkPrintOperationClass, done),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__INT,
|
||||||
|
G_TYPE_NONE, 1, G_TYPE_INT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkPrintOperation::begin-print:
|
* GtkPrintOperation::begin-print:
|
||||||
* @operation: the #GtkPrintOperation on which the signal was emitted
|
* @operation: the #GtkPrintOperation on which the signal was emitted
|
||||||
@ -980,38 +1003,6 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
|
|||||||
GTK_UNIT_PIXEL,
|
GTK_UNIT_PIXEL,
|
||||||
GTK_PARAM_READWRITE));
|
GTK_PARAM_READWRITE));
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GtkPrintOperation:show-dialog:
|
|
||||||
*
|
|
||||||
* Determines whether calling gtk_print_operation_run() will present
|
|
||||||
* a print dialog to the user, or just print to the default printer.
|
|
||||||
*
|
|
||||||
* Since: 2.10
|
|
||||||
*/
|
|
||||||
g_object_class_install_property (gobject_class,
|
|
||||||
PROP_SHOW_DIALOG,
|
|
||||||
g_param_spec_boolean ("show-dialog",
|
|
||||||
P_("Show Dialog"),
|
|
||||||
P_("TRUE if gtk_print_operation_run() should show the print dialog."),
|
|
||||||
TRUE,
|
|
||||||
GTK_PARAM_READWRITE));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GtkPrintOperation:show-preview:
|
|
||||||
*
|
|
||||||
* Determines whether calling gtk_print_operation_run() will present
|
|
||||||
* the print preview to the user.
|
|
||||||
*
|
|
||||||
* Since: 2.10
|
|
||||||
*/
|
|
||||||
g_object_class_install_property (gobject_class,
|
|
||||||
PROP_SHOW_PREVIEW,
|
|
||||||
g_param_spec_boolean ("show-preview",
|
|
||||||
P_("Show Preview"),
|
|
||||||
P_("TRUE if gtk_print_operation_run() should show the print preview."),
|
|
||||||
TRUE,
|
|
||||||
GTK_PARAM_READWRITE));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkPrintOperation:show-progress:
|
* GtkPrintOperation:show-progress:
|
||||||
@ -1028,7 +1019,24 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
|
|||||||
P_("TRUE if a progress dialog is shown while printing."),
|
P_("TRUE if a progress dialog is shown while printing."),
|
||||||
FALSE,
|
FALSE,
|
||||||
GTK_PARAM_READWRITE));
|
GTK_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkPrintOperation:allow-async:
|
||||||
|
*
|
||||||
|
* Determines whether the print operation may run asynchronous or not.
|
||||||
|
* Some systems don't support asynchronous printing, but those that do
|
||||||
|
* will return GTK_PRINT_OPERATION_RESULT_IN_PROGRESS as the status, and
|
||||||
|
* emit the done signal when the operation is actually done.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ALLOW_ASYNC,
|
||||||
|
g_param_spec_boolean ("allow-async",
|
||||||
|
P_("Allow Async"),
|
||||||
|
P_("TRUE if print process may run asynchronous."),
|
||||||
|
FALSE,
|
||||||
|
GTK_PARAM_READWRITE));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkPrintOperation:pdf-target:
|
* GtkPrintOperation:pdf-target:
|
||||||
@ -1548,6 +1556,10 @@ gtk_print_operation_get_status_string (GtkPrintOperation *op)
|
|||||||
* is finished, either successfully (%GTK_PRINT_STATUS_FINISHED)
|
* is finished, either successfully (%GTK_PRINT_STATUS_FINISHED)
|
||||||
* or unsuccessfully (%GTK_PRINT_STATUS_FINISHED_ABORTED).
|
* or unsuccessfully (%GTK_PRINT_STATUS_FINISHED_ABORTED).
|
||||||
*
|
*
|
||||||
|
* Note: when you enable print status tracking the print operation
|
||||||
|
* can be in a non-finished state even after done has been called, as
|
||||||
|
* the operation status then tracks the print job status on the printer.
|
||||||
|
*
|
||||||
* Return value: %TRUE, if the print operation is finished.
|
* Return value: %TRUE, if the print operation is finished.
|
||||||
*
|
*
|
||||||
* Since: 2.10
|
* Since: 2.10
|
||||||
@ -1565,67 +1577,6 @@ gtk_print_operation_is_finished (GtkPrintOperation *op)
|
|||||||
priv->status == GTK_PRINT_STATUS_FINISHED;
|
priv->status == GTK_PRINT_STATUS_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_print_operation_set_show_dialog:
|
|
||||||
* @op: a #GtkPrintOperation
|
|
||||||
* @show_dialog: %TRUE to show the print dialog
|
|
||||||
*
|
|
||||||
* Sets whether calling gtk_print_operation_run() will present
|
|
||||||
* a print dialog to the user, or just print to the default printer.
|
|
||||||
*
|
|
||||||
* Since: 2.10
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gtk_print_operation_set_show_dialog (GtkPrintOperation *op,
|
|
||||||
gboolean show_dialog)
|
|
||||||
{
|
|
||||||
GtkPrintOperationPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
|
|
||||||
|
|
||||||
priv = op->priv;
|
|
||||||
|
|
||||||
show_dialog = show_dialog != FALSE;
|
|
||||||
|
|
||||||
if (priv->show_dialog != show_dialog)
|
|
||||||
{
|
|
||||||
priv->show_dialog = show_dialog;
|
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (op), "show-dialog");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_print_operation_set_show_preview:
|
|
||||||
* @op: a #GtkPrintOperation
|
|
||||||
* @show_preview: %TRUE to show the print preview
|
|
||||||
*
|
|
||||||
* Sets whether calling gtk_print_operation_run() will present
|
|
||||||
* the print preview to the user.
|
|
||||||
*
|
|
||||||
* Since: 2.10
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gtk_print_operation_set_show_preview (GtkPrintOperation *op,
|
|
||||||
gboolean show_preview)
|
|
||||||
{
|
|
||||||
GtkPrintOperationPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
|
|
||||||
|
|
||||||
priv = op->priv;
|
|
||||||
|
|
||||||
show_preview = show_preview != FALSE;
|
|
||||||
|
|
||||||
if (priv->show_preview != show_preview)
|
|
||||||
{
|
|
||||||
priv->show_preview = show_preview;
|
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (op), "show-preview");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_print_operation_set_show_progress:
|
* gtk_print_operation_set_show_progress:
|
||||||
* @op: a #GtkPrintOperation
|
* @op: a #GtkPrintOperation
|
||||||
@ -1656,6 +1607,27 @@ gtk_print_operation_set_show_progress (GtkPrintOperation *op,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_print_operation_set_allow_async (GtkPrintOperation *op,
|
||||||
|
gboolean allow_async)
|
||||||
|
{
|
||||||
|
GtkPrintOperationPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
|
||||||
|
|
||||||
|
priv = op->priv;
|
||||||
|
|
||||||
|
allow_async = allow_async != FALSE;
|
||||||
|
|
||||||
|
if (priv->allow_async != allow_async)
|
||||||
|
{
|
||||||
|
priv->allow_async = allow_async;
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (op), "allow-async");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_print_operation_set_custom_tag_label:
|
* gtk_print_operation_set_custom_tag_label:
|
||||||
* @op: a #GtkPrintOperation
|
* @op: a #GtkPrintOperation
|
||||||
@ -1801,18 +1773,21 @@ pdf_end_run (GtkPrintOperation *op,
|
|||||||
static GtkPrintOperationResult
|
static GtkPrintOperationResult
|
||||||
run_pdf (GtkPrintOperation *op,
|
run_pdf (GtkPrintOperation *op,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
gboolean *do_print,
|
gboolean *do_print)
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
GtkPrintOperationPrivate *priv = op->priv;
|
GtkPrintOperationPrivate *priv = op->priv;
|
||||||
GtkPageSetup *page_setup;
|
GtkPageSetup *page_setup;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
double width, height;
|
double width, height;
|
||||||
/* This will be overwritten later by the non-default size, but
|
|
||||||
we need to pass some size: */
|
priv->print_context = _gtk_print_context_new (op);
|
||||||
|
|
||||||
page_setup = create_page_setup (op);
|
page_setup = create_page_setup (op);
|
||||||
|
_gtk_print_context_set_page_setup (priv->print_context, page_setup);
|
||||||
|
|
||||||
|
/* This will be overwritten later by the non-default size, but
|
||||||
|
we need to pass some size: */
|
||||||
width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
|
width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
|
||||||
height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
|
height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
|
||||||
g_object_unref (page_setup);
|
g_object_unref (page_setup);
|
||||||
@ -1939,11 +1914,17 @@ print_pages_idle_done (gpointer user_data)
|
|||||||
if (data->progress)
|
if (data->progress)
|
||||||
gtk_widget_destroy (data->progress);
|
gtk_widget_destroy (data->progress);
|
||||||
|
|
||||||
g_object_unref (data->op);
|
if (priv->rloop && !data->is_preview)
|
||||||
|
|
||||||
if (priv->rloop && !data->is_preview)
|
|
||||||
g_main_loop_quit (priv->rloop);
|
g_main_loop_quit (priv->rloop);
|
||||||
|
|
||||||
|
if (!data->is_preview)
|
||||||
|
g_signal_emit (data->op, signals[DONE], 0,
|
||||||
|
priv->cancelled ?
|
||||||
|
GTK_PRINT_OPERATION_RESULT_CANCEL :
|
||||||
|
GTK_PRINT_OPERATION_RESULT_APPLY);
|
||||||
|
|
||||||
|
g_object_unref (data->op);
|
||||||
|
|
||||||
g_free (data);
|
g_free (data);
|
||||||
|
|
||||||
GDK_THREADS_LEAVE ();
|
GDK_THREADS_LEAVE ();
|
||||||
@ -2194,16 +2175,23 @@ show_progress_timeout (PrintPagesData *data)
|
|||||||
static void
|
static void
|
||||||
print_pages (GtkPrintOperation *op,
|
print_pages (GtkPrintOperation *op,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
gboolean is_preview)
|
gboolean do_print,
|
||||||
|
GtkPrintOperationResult result)
|
||||||
{
|
{
|
||||||
GtkPrintOperationPrivate *priv = op->priv;
|
GtkPrintOperationPrivate *priv = op->priv;
|
||||||
PrintPagesData *data;
|
PrintPagesData *data;
|
||||||
|
|
||||||
|
if (!do_print) {
|
||||||
|
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL);
|
||||||
|
g_signal_emit (op, signals[DONE], 0, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_PREPARING, NULL);
|
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_PREPARING, NULL);
|
||||||
|
|
||||||
data = g_new0 (PrintPagesData, 1);
|
data = g_new0 (PrintPagesData, 1);
|
||||||
data->op = g_object_ref (op);
|
data->op = g_object_ref (op);
|
||||||
data->is_preview = is_preview;
|
data->is_preview = (result == GTK_PRINT_OPERATION_RESULT_PREVIEW);
|
||||||
|
|
||||||
if (priv->show_progress)
|
if (priv->show_progress)
|
||||||
{
|
{
|
||||||
@ -2224,7 +2212,7 @@ print_pages (GtkPrintOperation *op,
|
|||||||
data->progress = progress;
|
data->progress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_preview)
|
if (data->is_preview)
|
||||||
{
|
{
|
||||||
gboolean handled;
|
gboolean handled;
|
||||||
|
|
||||||
@ -2259,10 +2247,8 @@ print_pages (GtkPrintOperation *op,
|
|||||||
print_pages_idle,
|
print_pages_idle,
|
||||||
data,
|
data,
|
||||||
print_pages_idle_done);
|
print_pages_idle_done);
|
||||||
|
|
||||||
/* Recursive main loop to make sure we don't exit
|
/* Recursive main loop to make sure we don't exit on sync operations */
|
||||||
* on sync operations
|
|
||||||
*/
|
|
||||||
if (priv->is_sync)
|
if (priv->is_sync)
|
||||||
{
|
{
|
||||||
priv->rloop = g_main_loop_new (NULL, FALSE);
|
priv->rloop = g_main_loop_new (NULL, FALSE);
|
||||||
@ -2276,9 +2262,32 @@ print_pages (GtkPrintOperation *op,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_print_operation_get_error:
|
||||||
|
* @op: a #GtkPrintOperation
|
||||||
|
*
|
||||||
|
* Call this when the result of a print operation is
|
||||||
|
* GTK_PRINT_OPERATION_RESULT_ERROR, either as returned by gtk_print_operation_run (),
|
||||||
|
* or in the ::done signal handler. The returned #GError will contain more details
|
||||||
|
* on what went wrong.
|
||||||
|
*
|
||||||
|
* Return value: a GError representing the error, or NULL
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
**/
|
||||||
|
GError *
|
||||||
|
gtk_print_operation_get_error (GtkPrintOperation *op)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), NULL);
|
||||||
|
|
||||||
|
return op->priv->error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_print_operation_run:
|
* gtk_print_operation_run:
|
||||||
* @op: a #GtkPrintOperation
|
* @op: a #GtkPrintOperation
|
||||||
|
* @action: the action to start
|
||||||
* @parent: Transient parent of the dialog, or %NULL
|
* @parent: Transient parent of the dialog, or %NULL
|
||||||
* @error: Return location for errors, or %NULL
|
* @error: Return location for errors, or %NULL
|
||||||
*
|
*
|
||||||
@ -2286,11 +2295,16 @@ print_pages (GtkPrintOperation *op,
|
|||||||
* print settings in the print dialog, and then print the
|
* print settings in the print dialog, and then print the
|
||||||
* document.
|
* document.
|
||||||
*
|
*
|
||||||
* Note that this function does not return until the rendering of all
|
* Normally that this function does not return until the rendering of all
|
||||||
* pages is complete. You can connect to the ::status-changed signal on
|
* pages is complete. You can connect to the ::status-changed signal on
|
||||||
* @op to obtain some information about the progress of the print operation.
|
* @op to obtain some information about the progress of the print operation.
|
||||||
* Furthermore, it may use a recursive mainloop to show the print dialog.
|
* Furthermore, it may use a recursive mainloop to show the print dialog.
|
||||||
* See gtk_print_operation_run_async() if this is a problem.
|
*
|
||||||
|
* If you call gtk_print_operation_set_allow_async () or set the allow-async
|
||||||
|
* property the operation will run asyncronously if this is supported on the
|
||||||
|
* platform. The ::done signal will be emitted with the operation results when
|
||||||
|
* the operation is done (i.e. when the dialog is canceled, or when the print
|
||||||
|
* succeeds or fails).
|
||||||
*
|
*
|
||||||
* <informalexample><programlisting>
|
* <informalexample><programlisting>
|
||||||
* if (settings != NULL)
|
* if (settings != NULL)
|
||||||
@ -2304,7 +2318,7 @@ print_pages (GtkPrintOperation *op,
|
|||||||
* g_signal_connect (print, "draw-page",
|
* g_signal_connect (print, "draw-page",
|
||||||
* G_CALLBACK (draw_page), &data);
|
* G_CALLBACK (draw_page), &data);
|
||||||
*
|
*
|
||||||
* res = gtk_print_operation_run (print, parent, &error);
|
* res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, parent, &error);
|
||||||
*
|
*
|
||||||
* if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
* if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
||||||
* {
|
* {
|
||||||
@ -2331,85 +2345,78 @@ print_pages (GtkPrintOperation *op,
|
|||||||
* %GTK_PRINT_OPERATION_RESULT_APPLY indicates that the printing was
|
* %GTK_PRINT_OPERATION_RESULT_APPLY indicates that the printing was
|
||||||
* completed successfully. In this case, it is a good idea to obtain
|
* completed successfully. In this case, it is a good idea to obtain
|
||||||
* the used print settings with gtk_print_operation_get_print_settings()
|
* the used print settings with gtk_print_operation_get_print_settings()
|
||||||
* and store them for reuse with the next print operation.
|
* and store them for reuse with the next print operation. A value of
|
||||||
|
* %GTK_PRINT_OPERATION_RESULT_IN_PROGRESS means the operation is running
|
||||||
|
* asynchronously, and will emit the ::done signal when done.
|
||||||
*
|
*
|
||||||
* Since: 2.10
|
* Since: 2.10
|
||||||
**/
|
**/
|
||||||
GtkPrintOperationResult
|
GtkPrintOperationResult
|
||||||
gtk_print_operation_run (GtkPrintOperation *op,
|
gtk_print_operation_run (GtkPrintOperation *op,
|
||||||
|
GtkPrintOperationAction action,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GError **error)
|
GError **opt_error)
|
||||||
{
|
{
|
||||||
GtkPrintOperationPrivate *priv;
|
GtkPrintOperationPrivate *priv;
|
||||||
GtkPrintOperationResult result;
|
GtkPrintOperationResult result;
|
||||||
|
GtkPageSetup *page_setup;
|
||||||
gboolean do_print;
|
gboolean do_print;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op),
|
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op),
|
||||||
GTK_PRINT_OPERATION_RESULT_ERROR);
|
GTK_PRINT_OPERATION_RESULT_ERROR);
|
||||||
|
|
||||||
priv = op->priv;
|
priv = op->priv;
|
||||||
priv->is_sync = TRUE;
|
|
||||||
|
|
||||||
if (priv->pdf_target != NULL)
|
do_print = FALSE;
|
||||||
result = run_pdf (op, parent, &do_print, error);
|
priv->error = NULL;
|
||||||
else
|
priv->action = action;
|
||||||
result = _gtk_print_operation_platform_backend_run_dialog (op,
|
|
||||||
parent,
|
|
||||||
&do_print,
|
|
||||||
error);
|
|
||||||
if (do_print)
|
|
||||||
print_pages (op, parent, result == GTK_PRINT_OPERATION_RESULT_PREVIEW);
|
|
||||||
else
|
|
||||||
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL);
|
|
||||||
|
|
||||||
return result;
|
if (priv->print_settings == NULL)
|
||||||
}
|
priv->print_settings = gtk_print_settings_new ();
|
||||||
|
|
||||||
/**
|
if (action == GTK_PRINT_OPERATION_ACTION_EXPORT)
|
||||||
* gtk_print_operation_run_async:
|
|
||||||
* @op: a #GtkPrintOperation
|
|
||||||
* @parent: Transient parent of the dialog, or %NULL
|
|
||||||
*
|
|
||||||
* Runs the print operation, by first letting the user modify
|
|
||||||
* print settings in the print dialog, and then print the
|
|
||||||
* document.
|
|
||||||
*
|
|
||||||
* In contrast to gtk_print_operation_run(), this function returns after
|
|
||||||
* showing the print dialog on platforms that support this, and handles
|
|
||||||
* the printing by connecting a signal handler to the ::response signal
|
|
||||||
* of the dialog.
|
|
||||||
*
|
|
||||||
* If you use this function, it is recommended that you store the modified
|
|
||||||
* #GtkPrintSettings in a ::begin-print or ::end-print signal handler.
|
|
||||||
*
|
|
||||||
* Since: 2.10
|
|
||||||
**/
|
|
||||||
void
|
|
||||||
gtk_print_operation_run_async (GtkPrintOperation *op,
|
|
||||||
GtkWindow *parent)
|
|
||||||
{
|
|
||||||
GtkPrintOperationPrivate *priv;
|
|
||||||
gboolean do_print;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
|
|
||||||
|
|
||||||
priv = op->priv;
|
|
||||||
priv->is_sync = FALSE;
|
|
||||||
|
|
||||||
if (priv->pdf_target != NULL)
|
|
||||||
{
|
{
|
||||||
run_pdf (op, parent, &do_print, NULL);
|
priv->is_sync = TRUE;
|
||||||
if (do_print)
|
g_return_val_if_fail (priv->pdf_target != NULL, GTK_PRINT_OPERATION_RESULT_ERROR);
|
||||||
print_pages (op, parent, FALSE);
|
result = run_pdf (op, parent, &do_print);
|
||||||
else
|
}
|
||||||
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL);
|
else if (action == GTK_PRINT_OPERATION_ACTION_PREVIEW)
|
||||||
|
{
|
||||||
|
priv->print_context = _gtk_print_context_new (op);
|
||||||
|
page_setup = create_page_setup (op);
|
||||||
|
_gtk_print_context_set_page_setup (priv->print_context, page_setup);
|
||||||
|
g_object_unref (page_setup);
|
||||||
|
do_print = TRUE;
|
||||||
|
result = GTK_PRINT_OPERATION_RESULT_PREVIEW;
|
||||||
|
|
||||||
|
priv->is_sync = !priv->allow_async;
|
||||||
|
}
|
||||||
|
else if (priv->allow_async)
|
||||||
|
{
|
||||||
|
priv->is_sync = FALSE;
|
||||||
|
_gtk_print_operation_platform_backend_run_dialog_async (op,
|
||||||
|
action == GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
|
||||||
|
parent,
|
||||||
|
print_pages);
|
||||||
|
result = GTK_PRINT_OPERATION_RESULT_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_gtk_print_operation_platform_backend_run_dialog_async (op,
|
{
|
||||||
parent,
|
priv->is_sync = TRUE;
|
||||||
print_pages);
|
result = _gtk_print_operation_platform_backend_run_dialog (op,
|
||||||
}
|
action == GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
|
||||||
|
parent,
|
||||||
|
&do_print);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != GTK_PRINT_OPERATION_RESULT_IN_PROGRESS)
|
||||||
|
print_pages (op, parent, do_print, result);
|
||||||
|
|
||||||
|
if (priv->error && opt_error)
|
||||||
|
*opt_error = g_error_copy (priv->error);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_print_operation_cancel:
|
* gtk_print_operation_cancel:
|
||||||
|
|||||||
@ -56,6 +56,22 @@ typedef enum {
|
|||||||
GTK_PRINT_STATUS_FINISHED_ABORTED
|
GTK_PRINT_STATUS_FINISHED_ABORTED
|
||||||
} GtkPrintStatus;
|
} GtkPrintStatus;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GTK_PRINT_OPERATION_RESULT_ERROR,
|
||||||
|
GTK_PRINT_OPERATION_RESULT_APPLY,
|
||||||
|
GTK_PRINT_OPERATION_RESULT_CANCEL,
|
||||||
|
GTK_PRINT_OPERATION_RESULT_PREVIEW,
|
||||||
|
GTK_PRINT_OPERATION_RESULT_IN_PROGRESS
|
||||||
|
} GtkPrintOperationResult;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
|
||||||
|
GTK_PRINT_OPERATION_ACTION_PRINT,
|
||||||
|
GTK_PRINT_OPERATION_ACTION_PREVIEW,
|
||||||
|
GTK_PRINT_OPERATION_ACTION_EXPORT,
|
||||||
|
} GtkPrintOperationAction;
|
||||||
|
|
||||||
|
|
||||||
struct _GtkPrintOperation
|
struct _GtkPrintOperation
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
@ -67,6 +83,8 @@ struct _GtkPrintOperationClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
void (*done) (GtkPrintOperation *operation,
|
||||||
|
GtkPrintOperationResult result);
|
||||||
void (*begin_print) (GtkPrintOperation *operation,
|
void (*begin_print) (GtkPrintOperation *operation,
|
||||||
GtkPrintContext *context);
|
GtkPrintContext *context);
|
||||||
gboolean (*paginate) (GtkPrintOperation *operation,
|
gboolean (*paginate) (GtkPrintOperation *operation,
|
||||||
@ -102,13 +120,6 @@ struct _GtkPrintOperationClass
|
|||||||
void (*_gtk_reserved7) (void);
|
void (*_gtk_reserved7) (void);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GTK_PRINT_OPERATION_RESULT_ERROR,
|
|
||||||
GTK_PRINT_OPERATION_RESULT_APPLY,
|
|
||||||
GTK_PRINT_OPERATION_RESULT_CANCEL,
|
|
||||||
GTK_PRINT_OPERATION_RESULT_PREVIEW
|
|
||||||
} GtkPrintOperationResult;
|
|
||||||
|
|
||||||
#define GTK_PRINT_ERROR gtk_print_error_quark ()
|
#define GTK_PRINT_ERROR gtk_print_error_quark ()
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -138,23 +149,21 @@ void gtk_print_operation_set_use_full_page (GtkPrintOper
|
|||||||
gboolean full_page);
|
gboolean full_page);
|
||||||
void gtk_print_operation_set_unit (GtkPrintOperation *op,
|
void gtk_print_operation_set_unit (GtkPrintOperation *op,
|
||||||
GtkUnit unit);
|
GtkUnit unit);
|
||||||
void gtk_print_operation_set_show_dialog (GtkPrintOperation *op,
|
|
||||||
gboolean show_dialog);
|
|
||||||
void gtk_print_operation_set_show_preview (GtkPrintOperation *op,
|
|
||||||
gboolean show_preview);
|
|
||||||
void gtk_print_operation_set_pdf_target (GtkPrintOperation *op,
|
void gtk_print_operation_set_pdf_target (GtkPrintOperation *op,
|
||||||
const gchar *filename);
|
const gchar *filename);
|
||||||
void gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
|
void gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
|
||||||
gboolean track_status);
|
gboolean track_status);
|
||||||
void gtk_print_operation_set_show_progress (GtkPrintOperation *op,
|
void gtk_print_operation_set_show_progress (GtkPrintOperation *op,
|
||||||
gboolean show_progress);
|
gboolean show_progress);
|
||||||
|
void gtk_print_operation_set_allow_async (GtkPrintOperation *op,
|
||||||
|
gboolean allow_async);
|
||||||
void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op,
|
void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op,
|
||||||
const gchar *label);
|
const gchar *label);
|
||||||
GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
|
GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
|
||||||
|
GtkPrintOperationAction action,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GError **error);
|
GError **error);
|
||||||
void gtk_print_operation_run_preview (GtkPrintOperation *op,
|
GError * gtk_print_operation_get_error (GtkPrintOperation *op);
|
||||||
GtkWindow *parent);
|
|
||||||
GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op);
|
GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op);
|
||||||
G_CONST_RETURN gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op);
|
G_CONST_RETURN gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op);
|
||||||
gboolean gtk_print_operation_is_finished (GtkPrintOperation *op);
|
gboolean gtk_print_operation_is_finished (GtkPrintOperation *op);
|
||||||
|
|||||||
@ -603,18 +603,57 @@ do_preview (GtkPrintOperation *op,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME had to move this to the heap, since previewing
|
static void
|
||||||
* returns too early from the sync api
|
print_done (GtkPrintOperation *op,
|
||||||
*/
|
GtkPrintOperationResult res,
|
||||||
PrintData *print_data;
|
PrintData *print_data)
|
||||||
|
{
|
||||||
|
GError *error;
|
||||||
|
|
||||||
|
if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
||||||
|
{
|
||||||
|
|
||||||
|
GtkWidget *error_dialog;
|
||||||
|
|
||||||
|
error = gtk_print_operation_get_error (op);
|
||||||
|
|
||||||
|
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||||
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
GTK_MESSAGE_ERROR,
|
||||||
|
GTK_BUTTONS_CLOSE,
|
||||||
|
"Error printing file:\n%s",
|
||||||
|
error ? error->message : "no details");
|
||||||
|
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||||
|
gtk_widget_show (error_dialog);
|
||||||
|
}
|
||||||
|
else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
|
||||||
|
{
|
||||||
|
if (settings != NULL)
|
||||||
|
g_object_unref (settings);
|
||||||
|
settings = g_object_ref (gtk_print_operation_get_print_settings (op));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (print_data->text);
|
||||||
|
g_free (print_data->font);
|
||||||
|
g_free (print_data);
|
||||||
|
|
||||||
|
if (!gtk_print_operation_is_finished (op))
|
||||||
|
{
|
||||||
|
g_object_ref (op);
|
||||||
|
active_prints = g_list_append (active_prints, op);
|
||||||
|
update_statusbar ();
|
||||||
|
|
||||||
|
/* This ref is unref:ed when we get the final state change */
|
||||||
|
g_signal_connect (op, "status_changed",
|
||||||
|
G_CALLBACK (status_changed_cb), NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_print (GtkAction *action)
|
do_print (GtkAction *action)
|
||||||
{
|
{
|
||||||
GtkWidget *error_dialog;
|
|
||||||
GtkPrintOperation *print;
|
GtkPrintOperation *print;
|
||||||
GtkPrintOperationResult res;
|
PrintData *print_data;
|
||||||
GError *error;
|
|
||||||
|
|
||||||
print_data = g_new0 (PrintData, 1);
|
print_data = g_new0 (PrintData, 1);
|
||||||
|
|
||||||
@ -637,49 +676,16 @@ do_print (GtkAction *action)
|
|||||||
g_signal_connect (print, "custom_widget_apply", G_CALLBACK (custom_widget_apply), print_data);
|
g_signal_connect (print, "custom_widget_apply", G_CALLBACK (custom_widget_apply), print_data);
|
||||||
g_signal_connect (print, "preview", G_CALLBACK (do_preview), print_data);
|
g_signal_connect (print, "preview", G_CALLBACK (do_preview), print_data);
|
||||||
|
|
||||||
error = NULL;
|
g_signal_connect (print, "done", G_CALLBACK (print_done), print_data);
|
||||||
|
|
||||||
#if 1
|
gtk_print_operation_set_pdf_target (print, "test.pdf");
|
||||||
res = gtk_print_operation_run (print, GTK_WINDOW (main_window), &error);
|
|
||||||
|
|
||||||
if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
#if 0
|
||||||
{
|
gtk_print_operation_set_allow_async (print, TRUE);
|
||||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_ERROR,
|
|
||||||
GTK_BUTTONS_CLOSE,
|
|
||||||
"Error printing file:\n%s",
|
|
||||||
error ? error->message : "no details");
|
|
||||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
|
||||||
gtk_widget_show (error_dialog);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
|
|
||||||
{
|
|
||||||
if (settings != NULL)
|
|
||||||
g_object_unref (settings);
|
|
||||||
settings = g_object_ref (gtk_print_operation_get_print_settings (print));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gtk_print_operation_is_finished (print))
|
|
||||||
{
|
|
||||||
g_object_ref (print);
|
|
||||||
active_prints = g_list_append (active_prints, print);
|
|
||||||
update_statusbar ();
|
|
||||||
|
|
||||||
/* This ref is unref:ed when we get the final state change */
|
|
||||||
g_signal_connect (print, "status_changed",
|
|
||||||
G_CALLBACK (status_changed_cb), NULL);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
gtk_print_operation_run_async (print, GTK_WINDOW (main_window));
|
|
||||||
#endif
|
#endif
|
||||||
|
gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PREVIEW, GTK_WINDOW (main_window), NULL);
|
||||||
|
|
||||||
g_object_unref (print);
|
g_object_unref (print);
|
||||||
#if 0
|
|
||||||
g_free (print_data.text);
|
|
||||||
g_free (print_data.font);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@ -99,9 +99,8 @@ main (int argc, char **argv)
|
|||||||
gtk_print_operation_set_print_settings (print, settings);
|
gtk_print_operation_set_print_settings (print, settings);
|
||||||
gtk_print_operation_set_n_pages (print, 1);
|
gtk_print_operation_set_n_pages (print, 1);
|
||||||
gtk_print_operation_set_unit (print, GTK_UNIT_MM);
|
gtk_print_operation_set_unit (print, GTK_UNIT_MM);
|
||||||
gtk_print_operation_set_show_dialog (print, FALSE);
|
|
||||||
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
|
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
|
||||||
res = gtk_print_operation_run (print, NULL, NULL);
|
res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT, NULL, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,13 +111,13 @@ main (int argc, char **argv)
|
|||||||
gtk_print_operation_set_pdf_target (print, "test.pdf");
|
gtk_print_operation_set_pdf_target (print, "test.pdf");
|
||||||
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
|
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
|
||||||
g_signal_connect (print, "request_page_setup", G_CALLBACK (request_page_setup), NULL);
|
g_signal_connect (print, "request_page_setup", G_CALLBACK (request_page_setup), NULL);
|
||||||
res = gtk_print_operation_run (print, NULL, NULL);
|
res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
|
||||||
|
|
||||||
/* Test subclassing of GtkPrintOperation */
|
/* Test subclassing of GtkPrintOperation */
|
||||||
print_file = test_print_file_operation_new ("testprint.c");
|
print_file = test_print_file_operation_new ("testprint.c");
|
||||||
test_print_file_operation_set_font_size (print_file, 12.0);
|
test_print_file_operation_set_font_size (print_file, 12.0);
|
||||||
gtk_print_operation_set_pdf_target (GTK_PRINT_OPERATION (print_file), "test2.pdf");
|
gtk_print_operation_set_pdf_target (GTK_PRINT_OPERATION (print_file), "test2.pdf");
|
||||||
res = gtk_print_operation_run (GTK_PRINT_OPERATION (print_file), NULL, NULL);
|
res = gtk_print_operation_run (GTK_PRINT_OPERATION (print_file), GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user