Make the emission of ::end-print and ::done consistent for previews.

2007-04-29  Matthias Clasen <mclasen@redhat.com>

        Make the emission of ::end-print and ::done consistent
        for previews.  (#347567, Yevgen Muntyan)

        * gtk/gtkprintoperation.c (preview_iface_end_preview): Set
        the finished status here.
        (preview_end_run): ...and not here.
        (print_pages_idle_done): Emit ::done for a cancelled preview.
        (print_pages_idle): If a preview has been cancelled, don't
        emit ::ready, but emit ::end-print.

        tests/print-editor.c: Use ::end-print to undo allocations
        from ::begin-print.


svn path=/trunk/; revision=17719
This commit is contained in:
Matthias Clasen
2007-04-30 02:18:36 +00:00
committed by Matthias Clasen
parent 177f9aec9c
commit b9856ac887
3 changed files with 31 additions and 9 deletions

View File

@ -1,3 +1,18 @@
2007-04-29 Matthias Clasen <mclasen@redhat.com>
Make the emission of ::end-print and ::done consistent
for previews. (#347567, Yevgen Muntyan)
* gtk/gtkprintoperation.c (preview_iface_end_preview): Set
the finished status here.
(preview_end_run): ...and not here.
(print_pages_idle_done): Emit ::done for a cancelled preview.
(print_pages_idle): If a preview has been cancelled, don't
emit ::ready, but emit ::end-print.
tests/print-editor.c: Use ::end-print to undo allocations
from ::begin-print.
2007-04-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkpapersize.c (gtk_paper_size_new): Mark paper sizes

View File

@ -190,8 +190,9 @@ preview_iface_end_preview (GtkPrintOperationPreview *preview)
if (op->priv->end_run)
op->priv->end_run (op, op->priv->is_sync, TRUE);
g_signal_emit (op, signals[DONE], 0,
GTK_PRINT_OPERATION_RESULT_APPLY);
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED, NULL);
g_signal_emit (op, signals[DONE], 0, GTK_PRINT_OPERATION_RESULT_APPLY);
}
static gboolean
@ -252,8 +253,6 @@ preview_end_run (GtkPrintOperation *op,
{
g_free (op->priv->page_ranges);
op->priv->page_ranges = NULL;
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED, NULL);
}
@ -1929,7 +1928,7 @@ print_pages_idle_done (gpointer user_data)
if (priv->rloop && !data->is_preview)
g_main_loop_quit (priv->rloop);
if (!data->is_preview)
if (!data->is_preview || priv->cancelled)
g_signal_emit (data->op, signals[DONE], 0,
priv->cancelled ?
GTK_PRINT_OPERATION_RESULT_CANCEL :
@ -2126,7 +2125,7 @@ print_pages_idle (gpointer user_data)
}
}
if (data->is_preview)
if (data->is_preview && !priv->cancelled)
{
done = TRUE;
@ -2147,7 +2146,7 @@ print_pages_idle (gpointer user_data)
done = TRUE;
}
if (done && !data->is_preview)
if (done && (!data->is_preview || priv->cancelled))
{
g_signal_emit (data->op, signals[END_PRINT], 0, priv->print_context);
priv->end_run (data->op, priv->is_sync, priv->cancelled);

View File

@ -634,8 +634,6 @@ print_done (GtkPrintOperation *op,
g_free (print_data->text);
g_free (print_data->font);
g_list_free (print_data->page_breaks);
g_object_unref (print_data->layout);
g_free (print_data);
if (!gtk_print_operation_is_finished (op))
@ -650,6 +648,15 @@ print_done (GtkPrintOperation *op,
}
}
static void
end_print (GtkPrintOperation *op, GtkPrintContext *context, PrintData *print_data)
{
g_list_free (print_data->page_breaks);
print_data->page_breaks = NULL;
g_object_unref (print_data->layout);
print_data->layout = NULL;
}
static void
do_print_or_preview (GtkAction *action, GtkPrintOperationAction print_action)
{
@ -672,6 +679,7 @@ do_print_or_preview (GtkAction *action, GtkPrintOperationAction print_action)
gtk_print_operation_set_default_page_setup (print, page_setup);
g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), print_data);
g_signal_connect (print, "end-print", G_CALLBACK (end_print), print_data);
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), print_data);
g_signal_connect (print, "create_custom_widget", G_CALLBACK (create_custom_widget), print_data);
g_signal_connect (print, "custom_widget_apply", G_CALLBACK (custom_widget_apply), print_data);