run the print operation asynchronously.

2006-12-29  Sven Neumann  <sven@gimp.org>

	* plug-ins/print/print.c: run the print operation
asynchronously.
This commit is contained in:
Sven Neumann
2006-12-29 14:26:55 +00:00
committed by Sven Neumann
parent 25cc132bfc
commit dcbbc1abf3
2 changed files with 39 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2006-12-29 Sven Neumann <sven@gimp.org>
* plug-ins/print/print.c: run the print operation asynchronously.
2006-12-29 Michael Natterer <mitch@gimp.org> 2006-12-29 Michael Natterer <mitch@gimp.org>
* app/app_procs.c * app/app_procs.c

View File

@ -59,10 +59,15 @@ static void draw_page (GtkPrintOperation *print,
int page_nr, int page_nr,
PrintData *data); PrintData *data);
static void print_done (GtkPrintOperation *operation,
GtkPrintOperationResult result,
GtkPrintOperationResult *result_ptr);
static GtkWidget * create_custom_widget (GtkPrintOperation *operation, static GtkWidget * create_custom_widget (GtkPrintOperation *operation,
PrintData *data); PrintData *data);
const GimpPlugInInfo PLUG_IN_INFO = const GimpPlugInInfo PLUG_IN_INFO =
{ {
NULL, /* init_proc */ NULL, /* init_proc */
@ -185,17 +190,39 @@ print_image (gint32 image_ID,
gtk_print_operation_set_custom_tab_label (operation, _("Image")); gtk_print_operation_set_custom_tab_label (operation, _("Image"));
gtk_print_operation_set_allow_async (operation, TRUE);
g_signal_connect (operation, "done",
G_CALLBACK (print_done),
&result);
result = gtk_print_operation_run (operation, result = gtk_print_operation_run (operation,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
NULL, &error); NULL, &error);
while (result == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS)
{
const gchar *status;
while (gtk_events_pending ())
gtk_main_iteration ();
status = gtk_print_operation_get_status_string (operation);
/* display status of the print operation in the status bar */
gimp_progress_set_text_printf (_("Print: %s"), status);
}
switch (result) switch (result)
{ {
case GTK_PRINT_OPERATION_RESULT_APPLY: case GTK_PRINT_OPERATION_RESULT_APPLY:
case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
save_print_settings (data); save_print_settings (data);
break; break;
case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
g_warning ("shouldn't get here");
break;
case GTK_PRINT_OPERATION_RESULT_ERROR: case GTK_PRINT_OPERATION_RESULT_ERROR:
case GTK_PRINT_OPERATION_RESULT_CANCEL: case GTK_PRINT_OPERATION_RESULT_CANCEL:
break; break;
@ -239,6 +266,13 @@ end_print (GtkPrintOperation *operation,
gimp_progress_update (1.0); gimp_progress_update (1.0);
} }
static void
print_done (GtkPrintOperation *operation,
GtkPrintOperationResult result,
GtkPrintOperationResult *result_ptr)
{
*result_ptr = result;
}
static void static void
draw_page (GtkPrintOperation *operation, draw_page (GtkPrintOperation *operation,