summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMarek Kasik <mkasik@redhat.com>2010-06-07 14:52:38 +0200
committerMarek Kasik <mkasik@redhat.com>2010-06-07 14:52:38 +0200
commitca6aacc32d8141c0d6ebbf8c1ed6152764232bae (patch)
tree61014921fed2f1221a9d8a1a3609b38c18739ce0 /gtk
parent42deb581f936ee847cc54ddd936902934d889e7a (diff)
downloadgtk+-ca6aacc32d8141c0d6ebbf8c1ed6152764232bae.tar.gz
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).
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkprintjob.h6
-rw-r--r--gtk/gtkprintoperation-unix.c42
-rw-r--r--gtk/gtkprintoperation.c48
3 files changed, 52 insertions, 44 deletions
diff --git a/gtk/gtkprintjob.h b/gtk/gtkprintjob.h
index 9d2c25b548..e1c5845289 100644
--- a/gtk/gtkprintjob.h
+++ b/gtk/gtkprintjob.h
@@ -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;
diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c
index dbf622846f..896871ab22 100644
--- a/gtk/gtkprintoperation-unix.c
+++ b/gtk/gtkprintoperation-unix.c
@@ -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;
diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c
index b6a77b4bf4..a633bcdb7e 100644
--- a/gtk/gtkprintoperation.c
+++ b/gtk/gtkprintoperation.c
@@ -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,8 +3159,13 @@ 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;
}