- page_cache = ev_page_cache_get (ev_window->priv->document);
- if (last_page == -1) {
- last_page = ev_page_cache_get_n_pages (page_cache);
- }
-
- config = load_print_config_from_file ();
- job = gnome_print_job_new (config);
-
- print_dialog = gnome_print_dialog_new (job, (guchar *) _("Print"),
- (GNOME_PRINT_DIALOG_RANGE |
- GNOME_PRINT_DIALOG_COPIES));
-
- pages_label = g_strconcat (_("Pages"), " ", NULL);
- gnome_print_dialog_construct_range_page (GNOME_PRINT_DIALOG (print_dialog),
- GNOME_PRINT_RANGE_ALL |
- GNOME_PRINT_RANGE_RANGE,
- first_page, last_page,
- NULL, (const guchar *)pages_label);
- g_free (pages_label);
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog),
- GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
- FALSE);
-
- while (TRUE) {
- int response;
- response = gtk_dialog_run (GTK_DIALOG (print_dialog));
-
- if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT)
- break;
-
- /* FIXME: Change this when we have the first backend
- * that can print more than postscript
- */
- if (using_pdf_printer (config)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Generating PDF is not supported"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- continue;
- } else if (!using_postscript_printer (config)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Printing is not supported on this printer."));
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("You were trying to print to a printer using the \"%s\" driver. This program requires a PostScript printer driver."),
- gnome_print_config_get (
- config, (guchar *)"Settings.Engine.Backend.Driver"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- continue;
- }
-
- save_print_config_to_file (config);
-
- print_job = g_object_new (EV_TYPE_PRINT_JOB,
- "gnome_print_job", job,
- "document", ev_window->priv->document,
- "print_dialog", print_dialog,
- NULL);
- break;
- }