forked from AuroraMiddleware/gtk
Return error instead of showing an error dialog when printing
Remove message dialogs showing an error when printing. Return GTK_PRINT_OPERATION_RESULT_ERROR and set error in such a case. Also return GTK_PRINT_OPERATION_RESULT_CANCEL when cancelled. Do it for synchronous and asynchronous cases (#549127).
This commit is contained in:
parent
42deb581f9
commit
ca6aacc32d
@ -42,9 +42,9 @@ typedef struct _GtkPrintJob GtkPrintJob;
|
||||
typedef struct _GtkPrintJobClass GtkPrintJobClass;
|
||||
typedef struct _GtkPrintJobPrivate GtkPrintJobPrivate;
|
||||
|
||||
typedef void (*GtkPrintJobCompleteFunc) (GtkPrintJob *print_job,
|
||||
gpointer user_data,
|
||||
GError *error);
|
||||
typedef void (*GtkPrintJobCompleteFunc) (GtkPrintJob *print_job,
|
||||
gpointer user_data,
|
||||
const GError *error);
|
||||
|
||||
struct _GtkPrinter;
|
||||
|
||||
|
@ -306,20 +306,10 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
||||
out:
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkWidget *edialog;
|
||||
edialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
_("Error launching preview") /* FIXME better text */);
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (edialog),
|
||||
"%s", error->message);
|
||||
g_signal_connect (edialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (edialog));
|
||||
|
||||
g_error_free (error);
|
||||
if (op->priv->error == NULL)
|
||||
op->priv->error = error;
|
||||
else
|
||||
g_error_free (error);
|
||||
|
||||
filename_used = FALSE;
|
||||
settings_used = FALSE;
|
||||
@ -341,29 +331,15 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
||||
}
|
||||
|
||||
static void
|
||||
unix_finish_send (GtkPrintJob *job,
|
||||
gpointer user_data,
|
||||
GError *error)
|
||||
unix_finish_send (GtkPrintJob *job,
|
||||
gpointer user_data,
|
||||
const GError *error)
|
||||
{
|
||||
GtkPrintOperation *op = (GtkPrintOperation *) user_data;
|
||||
GtkPrintOperationUnix *op_unix = op->priv->platform_data;
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkWidget *edialog;
|
||||
edialog = gtk_message_dialog_new (op_unix->parent,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
_("Error printing") /* FIXME better text */);
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (edialog),
|
||||
"%s", error->message);
|
||||
gtk_window_set_modal (GTK_WINDOW (edialog), TRUE);
|
||||
g_signal_connect (edialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (edialog));
|
||||
}
|
||||
if (error != NULL && op->priv->error == NULL)
|
||||
op->priv->error = g_error_copy (error);
|
||||
|
||||
op_unix->data_sent = TRUE;
|
||||
|
||||
|
@ -205,6 +205,7 @@ static void
|
||||
preview_iface_end_preview (GtkPrintOperationPreview *preview)
|
||||
{
|
||||
GtkPrintOperation *op;
|
||||
GtkPrintOperationResult result;
|
||||
|
||||
op = GTK_PRINT_OPERATION (preview);
|
||||
|
||||
@ -218,7 +219,14 @@ preview_iface_end_preview (GtkPrintOperationPreview *preview)
|
||||
|
||||
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED, NULL);
|
||||
|
||||
g_signal_emit (op, signals[DONE], 0, GTK_PRINT_OPERATION_RESULT_APPLY);
|
||||
if (op->priv->error)
|
||||
result = GTK_PRINT_OPERATION_RESULT_ERROR;
|
||||
else if (op->priv->cancelled)
|
||||
result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
||||
else
|
||||
result = GTK_PRINT_OPERATION_RESULT_APPLY;
|
||||
|
||||
g_signal_emit (op, signals[DONE], 0, result);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2228,10 +2236,18 @@ print_pages_idle_done (gpointer user_data)
|
||||
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);
|
||||
{
|
||||
GtkPrintOperationResult result;
|
||||
|
||||
if (priv->error)
|
||||
result = GTK_PRINT_OPERATION_RESULT_ERROR;
|
||||
else if (priv->cancelled)
|
||||
result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
||||
else
|
||||
result = GTK_PRINT_OPERATION_RESULT_APPLY;
|
||||
|
||||
g_signal_emit (data->op, signals[DONE], 0, result);
|
||||
}
|
||||
|
||||
g_object_unref (data->op);
|
||||
g_free (data->pages);
|
||||
@ -2854,8 +2870,19 @@ print_pages (GtkPrintOperation *op,
|
||||
|
||||
if (!do_print)
|
||||
{
|
||||
GtkPrintOperationResult tmp_result;
|
||||
|
||||
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL);
|
||||
g_signal_emit (op, signals[DONE], 0, result);
|
||||
|
||||
if (priv->error)
|
||||
tmp_result = GTK_PRINT_OPERATION_RESULT_ERROR;
|
||||
else if (priv->cancelled)
|
||||
tmp_result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
||||
else
|
||||
tmp_result = result;
|
||||
|
||||
g_signal_emit (op, signals[DONE], 0, tmp_result);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3132,7 +3159,12 @@ gtk_print_operation_run (GtkPrintOperation *op,
|
||||
print_pages (op, parent, do_print, result);
|
||||
|
||||
if (priv->error && error)
|
||||
*error = g_error_copy (priv->error);
|
||||
{
|
||||
*error = g_error_copy (priv->error);
|
||||
result = GTK_PRINT_OPERATION_RESULT_ERROR;
|
||||
}
|
||||
else if (priv->cancelled)
|
||||
result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user