+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ switch (response) {
+ case GTK_RESPONSE_YES:
+ if (!ev_window->priv->print_queue ||
+ g_queue_is_empty (ev_window->priv->print_queue))
+ gtk_widget_destroy (GTK_WIDGET (ev_window));
+ else
+ ev_window->priv->close_after_print = TRUE;
+ break;
+ case GTK_RESPONSE_NO:
+ ev_window->priv->close_after_print = TRUE;
+ if (ev_window->priv->print_queue &&
+ !g_queue_is_empty (ev_window->priv->print_queue)) {
+ gtk_widget_set_sensitive (GTK_WIDGET (ev_window), FALSE);
+ ev_window_print_cancel (ev_window);
+ } else {
+ gtk_widget_destroy (GTK_WIDGET (ev_window));
+ }
+ break;
+ case GTK_RESPONSE_CANCEL:
+ default:
+ ev_window->priv->close_after_print = FALSE;
+ }
+}
+
+static gboolean
+ev_window_check_print_queue (EvWindow *ev_window)
+{
+ GtkWidget *dialog;
+ gchar *text, *markup;
+ gint n_print_jobs;
+
+ n_print_jobs = ev_window->priv->print_queue ?
+ g_queue_get_length (ev_window->priv->print_queue) : 0;
+
+ if (n_print_jobs == 0)
+ return FALSE;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ NULL);
+ if (n_print_jobs == 1) {
+ EvPrintOperation *op;
+ const gchar *job_name;
+
+ op = g_queue_peek_tail (ev_window->priv->print_queue);
+ job_name = ev_print_operation_get_job_name (op);
+
+ text = g_strdup_printf (_("Wait until print job “%s” finishes before closing?"),
+ job_name);
+ } else {
+ text = g_strdup_printf (_("There are %d print jobs active. "
+ "Wait until print finishes before closing?"),
+ n_print_jobs);
+ }
+
+ markup = g_strdup_printf ("<b>%s</b>", text);
+ g_free (text);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
+ g_free (markup);
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s",
+ _("If you close the window, pending print "
+ "jobs will not be printed."));
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("Cancel _print and Close"),
+ GTK_RESPONSE_NO,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ _("Close _after Printing"),
+ GTK_RESPONSE_YES,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_YES,
+ GTK_RESPONSE_NO,
+ GTK_RESPONSE_CANCEL,
+ -1);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (print_jobs_confirmation_dialog_response),
+ ev_window);
+ gtk_widget_show (dialog);
+
+ return TRUE;
+}
+
+static gboolean
+ev_window_close (EvWindow *ev_window)
+{
+ if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
+ gint current_page;
+
+ /* Save current page */
+ current_page = ev_view_presentation_get_current_page (
+ EV_VIEW_PRESENTATION (ev_window->priv->presentation_view));
+ ev_document_model_set_page (ev_window->priv->model, current_page);
+ }
+
+ if (ev_window_check_document_modified (ev_window))
+ return FALSE;
+
+ if (ev_window_check_print_queue (ev_window))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
+{
+ if (ev_window_close (ev_window))
+ gtk_widget_destroy (GTK_WIDGET (ev_window));
+}
+
+static void
+ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
+{
+ GtkAction *action;