+2007-07-26 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * backend/dvi/dvi-document.c: (dvi_document_file_exporter_begin),
+ (dvi_document_file_exporter_do_page),
+ (dvi_document_file_exporter_get_capabilities),
+ (dvi_document_file_exporter_iface_init):
+ * backend/ps/ps-document.c: (ps_document_file_exporter_begin),
+ (ps_document_file_exporter_do_page),
+ (ps_document_file_exporter_get_capabilities),
+ (ps_document_file_exporter_iface_init):
+ * backend/djvu/djvu-document.c:
+ (djvu_document_file_exporter_begin),
+ (djvu_document_file_exporter_end),
+ (djvu_document_file_exporter_get_capabilities),
+ (djvu_document_file_exporter_iface_init):
+ * backend/tiff/tiff-document.c:
+ (tiff_document_file_exporter_begin),
+ (tiff_document_file_exporter_get_capabilities),
+ (tiff_document_document_file_exporter_iface_init):
+ * backend/pdf/ev-poppler.cc: (pdf_document_file_exporter_begin),
+ (pdf_document_file_exporter_do_page),
+ (pdf_document_file_exporter_get_capabilities),
+ (pdf_document_file_exporter_iface_init):
+ * libdocument/ev-file-exporter.[ch]: (ev_file_exporter_begin),
+ (ev_file_exporter_get_capabilities):
+ * shell/ev-print-job.c: (ev_print_job_use_print_dialog_settings),
+ (idle_print_handler), (ev_print_job_print):
+ * shell/ev-jobs.c: (ev_job_print_run):
+ * shell/ev-window.c: (ev_window_print_send),
+ (ev_window_print_range):
+
+ Use capabilities to know which options should be offered by the
+ print dialog depending on the document backend.
+
2007-07-25 Carlos Garcia Campos <carlosgc@gnome.org>
* shell/ev-view.c: (ev_view_handle_cursor_over_xy):
}
/* EvFileExporterIface */
-static gboolean
-djvu_document_file_exporter_format_supported (EvFileExporter *exporter,
- EvFileExporterFormat format)
-{
- return (format == EV_FILE_FORMAT_PS); // only exporting to PS is implemented.
-}
-
static void
-djvu_document_file_exporter_begin (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const char *filename, /* for storing the temp ps file */
- int first_page,
- int last_page,
- double width,
- double height,
- gboolean duplex)
+djvu_document_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterContext *fc)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
if (djvu_document->ps_filename)
g_free (djvu_document->ps_filename);
- djvu_document->ps_filename = g_strdup(filename);
+ djvu_document->ps_filename = g_strdup (fc->filename);
- g_string_assign(djvu_document->opts, "-page=");
+ g_string_assign (djvu_document->opts, "-page=");
}
static void
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
- g_string_append_printf(djvu_document->opts, "%d,", (rc->page) + 1);
+ g_string_append_printf (djvu_document->opts, "%d,", (rc->page) + 1);
}
static void
DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
- FILE *fn = fopen(djvu_document->ps_filename, "w");
+ FILE *fn = fopen (djvu_document->ps_filename, "w");
if (fn == NULL) {
- g_warning(_("Cannot open file ā%sā."), djvu_document->ps_filename);
+ g_warning ("Cannot open file ā%sā.", djvu_document->ps_filename);
return;
}
d_optv[0] = djvu_document->opts->str;
ddjvu_job_t * job = ddjvu_document_print(djvu_document->d_document, fn, d_optc, d_optv);
- while (!ddjvu_job_done(job) ) {
+ while (!ddjvu_job_done(job)) {
djvu_handle_events (djvu_document, TRUE);
}
fclose(fn);
}
+static EvFileExporterCapabilities
+djvu_document_file_exporter_get_capabilities (EvFileExporter *exporter)
+{
+ return EV_FILE_EXPORTER_CAN_PAGE_SET |
+ EV_FILE_EXPORTER_CAN_COPIES |
+ EV_FILE_EXPORTER_CAN_COLLATE |
+ EV_FILE_EXPORTER_CAN_REVERSE |
+ EV_FILE_EXPORTER_CAN_GENERATE_PS;
+}
+
static void
djvu_document_file_exporter_iface_init (EvFileExporterIface *iface)
{
- iface->format_supported = djvu_document_file_exporter_format_supported;
iface->begin = djvu_document_file_exporter_begin;
iface->do_page = djvu_document_file_exporter_do_page;
iface->end = djvu_document_file_exporter_end;
+ iface->get_capabilities = djvu_document_file_exporter_get_capabilities;
}
static void
}
/* EvFileExporterIface */
-static gboolean
-dvi_document_file_exporter_format_supported (EvFileExporter *exporter,
- EvFileExporterFormat format)
-{
- return (format == EV_FILE_FORMAT_PDF); /* only exporting to PDF is implemented. */
-}
-
static void
-dvi_document_file_exporter_begin (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const char *filename, /* for storing the temp pdf file */
- int first_page,
- int last_page,
- double width,
- double height,
- gboolean duplex)
+dvi_document_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterContext *fc)
{
DviDocument *dvi_document = DVI_DOCUMENT(exporter);
if (dvi_document->exporter_filename)
g_free (dvi_document->exporter_filename);
- dvi_document->exporter_filename = g_strdup(filename);
+ dvi_document->exporter_filename = g_strdup(fc->filename);
if (dvi_document->exporter_opts) {
g_string_free (dvi_document->exporter_opts, TRUE);
}
static void
-dvi_document_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *rc)
+dvi_document_file_exporter_do_page (EvFileExporter *exporter,
+ EvRenderContext *rc)
{
DviDocument *dvi_document = DVI_DOCUMENT(exporter);
g_free(command_line);
if (success == FALSE) {
- g_warning (_("Error: %s"), err->message);
+ g_warning ("Error: %s", err->message);
} else if (exit_stat != 0) {
- g_warning (_("Error: dvipdfm exited with non-zero status."));
+ g_warning ("Error: dvipdfm exited with non-zero status.");
}
if (err)
g_error_free(err);
}
+static EvFileExporterCapabilities
+dvi_document_file_exporter_get_capabilities (EvFileExporter *exporter)
+{
+ return EV_FILE_EXPORTER_CAN_PAGE_SET |
+ EV_FILE_EXPORTER_CAN_COPIES |
+ EV_FILE_EXPORTER_CAN_COLLATE |
+ EV_FILE_EXPORTER_CAN_REVERSE |
+ EV_FILE_EXPORTER_CAN_GENERATE_PDF;
+}
+
static void
dvi_document_file_exporter_iface_init (EvFileExporterIface *iface)
{
- iface->format_supported = dvi_document_file_exporter_format_supported;
iface->begin = dvi_document_file_exporter_begin;
iface->do_page = dvi_document_file_exporter_do_page;
iface->end = dvi_document_file_exporter_end;
+ iface->get_capabilities = dvi_document_file_exporter_get_capabilities;
}
#define RGB2ULONG(r,g,b) ((0xFF<<24)|(r<<16)|(g<<8)|(b))
iface->cancel = pdf_document_find_cancel;
}
-static const gboolean supported_formats[] = {
- TRUE, /* EV_FILE_FORMAT_PS */
-#ifdef HAVE_CAIRO_PDF
-#ifdef HAVE_POPPLER_PAGE_RENDER
- TRUE, /* EV_FILE_FORMAT_PDF */
-#else
- FALSE, /* EV_FILE_FORMAT_PDF */
-#endif
-#endif
-};
-
static void
pdf_print_context_free (PdfPrintContext *ctx)
{
g_free (ctx);
}
-static gboolean
-pdf_document_file_exporter_format_supported (EvFileExporter *exporter,
- EvFileExporterFormat format)
-{
- return supported_formats[format];
-}
-
static void
-pdf_document_file_exporter_begin (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const char *filename,
- int first_page,
- int last_page,
- double width,
- double height,
- gboolean duplex)
+pdf_document_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterContext *fc)
{
PdfDocument *pdf_document = PDF_DOCUMENT (exporter);
PdfPrintContext *ctx;
pdf_print_context_free (pdf_document->print_ctx);
pdf_document->print_ctx = g_new0 (PdfPrintContext, 1);
ctx = pdf_document->print_ctx;
- ctx->format = format;
+ ctx->format = fc->format;
- switch (format) {
+ switch (fc->format) {
case EV_FILE_FORMAT_PS:
ctx->ps_file = poppler_ps_file_new (pdf_document->document,
- filename, first_page,
- last_page - first_page + 1);
- poppler_ps_file_set_paper_size (ctx->ps_file, width, height);
- poppler_ps_file_set_duplex (ctx->ps_file, duplex);
+ fc->filename, fc->first_page,
+ fc->last_page - fc->first_page + 1);
+ poppler_ps_file_set_paper_size (ctx->ps_file, fc->paper_width, fc->paper_height);
+ poppler_ps_file_set_duplex (ctx->ps_file, fc->duplex);
break;
case EV_FILE_FORMAT_PDF: {
#ifdef HAVE_CAIRO_PDF
cairo_surface_t *surface;
- surface = cairo_pdf_surface_create (filename, width, height);
+ surface = cairo_pdf_surface_create (fc->filename, fc->paper_width, fc->paper_height);
ctx->pdf_cairo = cairo_create (surface);
cairo_surface_destroy (surface);
#endif
}
static void
-pdf_document_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *rc)
+pdf_document_file_exporter_do_page (EvFileExporter *exporter,
+ EvRenderContext *rc)
{
PdfDocument *pdf_document = PDF_DOCUMENT (exporter);
PdfPrintContext *ctx = pdf_document->print_ctx;
pdf_document->print_ctx = NULL;
}
+static EvFileExporterCapabilities
+pdf_document_file_exporter_get_capabilities (EvFileExporter *exporter)
+{
+ return (EvFileExporterCapabilities) (
+ EV_FILE_EXPORTER_CAN_PAGE_SET |
+ EV_FILE_EXPORTER_CAN_COPIES |
+ EV_FILE_EXPORTER_CAN_COLLATE |
+ EV_FILE_EXPORTER_CAN_REVERSE |
+ EV_FILE_EXPORTER_CAN_SCALE |
+#ifdef HAVE_CAIRO_PDF
+#ifdef HAVE_POPPLER_PAGE_RENDER
+ EV_FILE_EXPORTER_CAN_GENERATE_PDF |
+#endif
+#endif
+ EV_FILE_EXPORTER_CAN_GENERATE_PS);
+}
+
static void
pdf_document_file_exporter_iface_init (EvFileExporterIface *iface)
{
- iface->format_supported = pdf_document_file_exporter_format_supported;
iface->begin = pdf_document_file_exporter_begin;
iface->do_page = pdf_document_file_exporter_do_page;
iface->end = pdf_document_file_exporter_end;
+ iface->get_capabilities = pdf_document_file_exporter_get_capabilities;
}
static void
}
/* EvFileExporterIface */
-static gboolean
-ps_document_file_exporter_format_supported (EvFileExporter *exporter,
- EvFileExporterFormat format)
-{
- return (format == EV_FILE_FORMAT_PS);
-}
-
static void
-ps_document_file_exporter_begin (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const char *filename,
- int first_page,
- int last_page,
- double width,
- double height,
- gboolean duplex)
+ps_document_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterContext *fc)
{
PSDocument *document = PS_DOCUMENT (exporter);
document->ps_export_pagelist = g_new0 (int, document->doc->numpages);
}
- document->ps_export_filename = g_strdup (filename);
+ document->ps_export_filename = g_strdup (fc->filename);
}
static void
-ps_document_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *rc)
+ps_document_file_exporter_do_page (EvFileExporter *exporter,
+ EvRenderContext *rc)
{
PSDocument *document = PS_DOCUMENT (exporter);
}
}
+static EvFileExporterCapabilities
+ps_document_file_exporter_get_capabilities (EvFileExporter *exporter)
+{
+ return EV_FILE_EXPORTER_CAN_PAGE_SET |
+ EV_FILE_EXPORTER_CAN_GENERATE_PS;
+}
+
static void
ps_document_file_exporter_iface_init (EvFileExporterIface *iface)
{
- iface->format_supported = ps_document_file_exporter_format_supported;
iface->begin = ps_document_file_exporter_begin;
iface->do_page = ps_document_file_exporter_do_page;
iface->end = ps_document_file_exporter_end;
+ iface->get_capabilities = ps_document_file_exporter_get_capabilities;
}
}
/* postscript exporter implementation */
-
-static gboolean
-tiff_document_file_exporter_format_supported (EvFileExporter *exporter,
- EvFileExporterFormat format)
-{
- return (format == EV_FILE_FORMAT_PS);
-}
-
static void
-tiff_document_file_exporter_begin (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const char *filename,
- int first_page,
- int last_page,
- double width,
- double height,
- gboolean duplex)
+tiff_document_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterContext *fc)
{
TiffDocument *document = TIFF_DOCUMENT (exporter);
- document->ps_export_ctx = tiff2ps_context_new(filename);
+ document->ps_export_ctx = tiff2ps_context_new(fc->filename);
}
static void
tiff2ps_context_finalize(document->ps_export_ctx);
}
+static EvFileExporterCapabilities
+tiff_document_file_exporter_get_capabilities (EvFileExporter *exporter)
+{
+ return EV_FILE_EXPORTER_CAN_PAGE_SET |
+ EV_FILE_EXPORTER_CAN_COPIES |
+ EV_FILE_EXPORTER_CAN_COLLATE |
+ EV_FILE_EXPORTER_CAN_REVERSE |
+ EV_FILE_EXPORTER_CAN_GENERATE_PS;
+}
+
static void
tiff_document_document_file_exporter_iface_init (EvFileExporterIface *iface)
{
- iface->format_supported = tiff_document_file_exporter_format_supported;
iface->begin = tiff_document_file_exporter_begin;
iface->do_page = tiff_document_file_exporter_do_page;
iface->end = tiff_document_file_exporter_end;
+ iface->get_capabilities = tiff_document_file_exporter_get_capabilities;
}
static void
return type;
}
-gboolean
-ev_file_exporter_format_supported (EvFileExporter *exporter,
- EvFileExporterFormat format)
-{
- EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
-
- if (format < EV_FILE_FORMAT_PS ||
- format > EV_FILE_FORMAT_PDF)
- return FALSE;
-
- return iface->format_supported (exporter, format);
-}
-
void
-ev_file_exporter_begin (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const gchar *filename,
- gint first_page,
- gint last_page,
- gdouble paper_width,
- gdouble paper_height,
- gboolean duplex)
+ev_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterContext *fc)
{
EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
- g_return_if_fail (ev_file_exporter_format_supported (exporter, format));
-
- iface->begin (exporter, format, filename, first_page, last_page,
- paper_width, paper_height, duplex);
+ iface->begin (exporter, fc);
}
void
-ev_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *rc)
+ev_file_exporter_do_page (EvFileExporter *exporter,
+ EvRenderContext *rc)
{
EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
iface->end (exporter);
}
+
+EvFileExporterCapabilities
+ev_file_exporter_get_capabilities (EvFileExporter *exporter)
+{
+ EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter);
+
+ iface->get_capabilities (exporter);
+}
G_BEGIN_DECLS
typedef enum {
- EV_FILE_FORMAT_PS,
- EV_FILE_FORMAT_PDF,
- EV_FILE_FORMAT_UNKNOWN
+ EV_FILE_FORMAT_UNKNOWN,
+ EV_FILE_FORMAT_PS,
+ EV_FILE_FORMAT_PDF
} EvFileExporterFormat;
+typedef enum {
+ EV_FILE_EXPORTER_CAN_PAGE_SET = 1 << 0,
+ EV_FILE_EXPORTER_CAN_COPIES = 1 << 1,
+ EV_FILE_EXPORTER_CAN_COLLATE = 1 << 2,
+ EV_FILE_EXPORTER_CAN_REVERSE = 1 << 3,
+ EV_FILE_EXPORTER_CAN_SCALE = 1 << 4,
+ EV_FILE_EXPORTER_CAN_GENERATE_PDF = 1 << 5,
+ EV_FILE_EXPORTER_CAN_GENERATE_PS = 1 << 6,
+ EV_FILE_EXPORTER_CAN_PREVIEW = 1 << 7,
+ EV_FILE_EXPORTER_CAN_NUMBER_UP = 1 << 8
+} EvFileExporterCapabilities;
+
+typedef struct {
+ EvFileExporterFormat format;
+ const gchar *filename;
+ gint first_page;
+ gint last_page;
+ gdouble paper_width;
+ gdouble paper_height;
+ gboolean duplex;
+} EvFileExporterContext;
+
#define EV_TYPE_FILE_EXPORTER (ev_file_exporter_get_type ())
#define EV_FILE_EXPORTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_FILE_EXPORTER, EvFileExporter))
#define EV_FILE_EXPORTER_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_FILE_EXPORTER, EvFileExporterIface))
#define EV_IS_FILE_EXPORTER_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_FILE_EXPORTER))
#define EV_FILE_EXPORTER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_FILE_EXPORTER, EvFileExporterIface))
-typedef struct _EvFileExporter EvFileExporter;
+typedef struct _EvFileExporter EvFileExporter;
typedef struct _EvFileExporterIface EvFileExporterIface;
struct _EvFileExporterIface {
GTypeInterface base_iface;
/* Methods */
- gboolean (* format_supported) (EvFileExporter *exporter,
- EvFileExporterFormat format);
- void (* begin) (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const gchar *filename,
- gint first_page,
- gint last_page,
- gdouble paper_width,
- gdouble paper_height,
- gboolean duplex);
- void (* do_page) (EvFileExporter *exporter,
- EvRenderContext *rc);
- void (* end) (EvFileExporter *exporter);
+ void (* begin) (EvFileExporter *exporter,
+ EvFileExporterContext *fc);
+ void (* do_page) (EvFileExporter *exporter,
+ EvRenderContext *rc);
+ void (* end) (EvFileExporter *exporter);
+ EvFileExporterCapabilities (* get_capabilities) (EvFileExporter *exporter);
};
-GType ev_file_exporter_get_type (void) G_GNUC_CONST;
-gboolean ev_file_exporter_format_supported (EvFileExporter *exporter,
- EvFileExporterFormat format);
-void ev_file_exporter_begin (EvFileExporter *exporter,
- EvFileExporterFormat format,
- const gchar *filename,
- gint first_page,
- gint last_page,
- gdouble paper_width,
- gdouble paper_height,
- gboolean duplex);
-void ev_file_exporter_do_page (EvFileExporter *exporter,
- EvRenderContext *rc);
-void ev_file_exporter_end (EvFileExporter *exporter);
+GType ev_file_exporter_get_type (void) G_GNUC_CONST;
+void ev_file_exporter_begin (EvFileExporter *exporter,
+ EvFileExporterContext *fc);
+void ev_file_exporter_do_page (EvFileExporter *exporter,
+ EvRenderContext *rc);
+void ev_file_exporter_end (EvFileExporter *exporter);
+EvFileExporterCapabilities ev_file_exporter_get_capabilities (EvFileExporter *exporter);
G_END_DECLS
void
ev_job_print_run (EvJobPrint *job)
{
- EvDocument *document = EV_JOB (job)->document;
- gint fd;
- gint last_page;
- gint first_page;
- gint i;
- gchar *filename;
+ EvDocument *document = EV_JOB (job)->document;
+ EvFileExporterContext fc;
+ gint fd;
+ gint last_page;
+ gint first_page;
+ gint i;
+ gchar *filename;
g_return_if_fail (EV_IS_JOB_PRINT (job));
first_page = ev_print_job_get_first_page (job);
last_page = ev_print_job_get_last_page (job);
+ fc.format = g_ascii_strcasecmp (job->format, "pdf") == 0 ?
+ EV_FILE_FORMAT_PDF : EV_FILE_FORMAT_PS;
+ fc.filename = job->temp_file;
+ fc.first_page = MIN (first_page, last_page);
+ fc.last_page = MAX (first_page, last_page);
+ fc.paper_width = job->width;
+ fc.paper_height = job->height;
+ fc.duplex = FALSE;
+
ev_document_doc_mutex_lock ();
- ev_file_exporter_begin (EV_FILE_EXPORTER (document),
- g_ascii_strcasecmp (job->format, "pdf") == 0 ?
- EV_FILE_FORMAT_PDF : EV_FILE_FORMAT_PS,
- job->temp_file,
- MIN (first_page, last_page),
- MAX (first_page, last_page),
- job->width, job->height, FALSE);
+ ev_file_exporter_begin (EV_FILE_EXPORTER (document), &fc);
ev_document_doc_mutex_unlock ();
for (i = 0; i < job->copies; i++) {
EvDocument *document;
GnomePrintJob *gnome_print_job;
- double width; /* FIXME unused */
- double height; /* FIXME unused */
- gboolean duplex; /* FIXME unused */
+ EvFileExporterContext fc;
int copies;
int collate;
- /* range printing */
- int first_page;
- int last_page;
-
int fd;
char *temp_file;
guint idle_id;
{
GnomePrintConfig *print_config;
EvPageCache *page_cache = ev_page_cache_get (job->document);
+ gint first_page, last_page;
g_return_if_fail (EV_IS_PRINT_JOB (job));
g_return_if_fail (GNOME_IS_PRINT_DIALOG (dialog));
print_config = gnome_print_dialog_get_config (dialog);
gnome_print_dialog_get_copies (dialog, &job->copies, &job->collate);
gnome_print_config_get_page_size (print_config,
- &job->width, &job->height);
+ &job->fc.paper_width, &job->fc.paper_height);
gnome_print_config_get_boolean (print_config,
- (guchar *)GNOME_PRINT_KEY_DUPLEX, &job->duplex);
+ (guchar *)GNOME_PRINT_KEY_DUPLEX, &job->fc.duplex);
page_cache = ev_page_cache_get (job->document);
/* get the printing ranges */
switch (gnome_print_dialog_get_range (dialog)) {
case GNOME_PRINT_RANGE_ALL:
- job->first_page = 0;
- job->last_page = ev_page_cache_get_n_pages (page_cache) - 1;
+ first_page = 0;
+ last_page = ev_page_cache_get_n_pages (page_cache) - 1;
break;
case GNOME_PRINT_RANGE_RANGE:
- gnome_print_dialog_get_range_page (dialog, &job->first_page, &job->last_page);
+ gnome_print_dialog_get_range_page (dialog, &first_page, &last_page);
/* convert 1-based user interface to 0-based internal numbers */
- job->first_page--;
- job->last_page--;
+ first_page--;
+ last_page--;
break;
default:
g_assert_not_reached ();
}
+ job->fc.first_page = MIN (first_page, last_page);
+ job->fc.last_page = MAX (first_page, last_page);
+
gnome_print_config_unref (print_config);
}
{
if (!job->printing) {
ev_document_doc_mutex_lock ();
- ev_file_exporter_begin (
- EV_FILE_EXPORTER (job->document),
- EV_FILE_FORMAT_PS,
- job->temp_file,
- MIN (job->first_page, job->last_page),
- MAX (job->first_page, job->last_page),
- job->width, job->height, job->duplex);
+ ev_file_exporter_begin (EV_FILE_EXPORTER (job->document),
+ &(job->fc));
ev_document_doc_mutex_unlock ();
- job->next_page = job->first_page;
- job->shift = (job->first_page > job->last_page) ? -1 : 1;
+ job->next_page = job->fc.first_page;
+ job->shift = (job->fc.first_page > job->fc.last_page) ? -1 : 1;
job->printing = TRUE;
return TRUE;
}
- if ((job->next_page - job->last_page) * job->shift <= 0) {
+ if ((job->next_page - job->fc.last_page) * job->shift <= 0) {
EvRenderContext *rc;
#if 0
g_printerr ("Printing page %d\n", job->next_page);
}
} else {
job->next_page += job->shift;
- if ((job->next_page - job->last_page) * job->shift > 0){
+ if ((job->next_page - job->fc.last_page) * job->shift > 0){
job->copies_done++;
if(job->copies_done < job->copies) {
/* more copies to go, restart to the first page */
- job->next_page = job->first_page;
+ job->next_page = job->fc.first_page;
}
}
}
if (job->fd <= -1)
return; /* FIXME use GError */
+ job->fc.format = EV_FILE_FORMAT_PS;
+ job->fc.filename = job->temp_file;
gnome_print_job_set_file (job->gnome_print_job, job->temp_file);
g_object_ref (job);
const gchar *filename)
{
GtkPrintSettings *settings;
+ EvFileExporterCapabilities capabilities;
/* Some printers take into account some print settings,
* and others don't. However we have exported the document
* settings set to default values.
*/
settings = gtk_print_settings_copy (window->priv->print_settings);
- gtk_print_settings_set_n_copies (settings, 1);
+ capabilities = ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (window->priv->document));
+
gtk_print_settings_set_page_ranges (settings, NULL, 0);
- gtk_print_settings_set_page_set (settings, GTK_PAGE_SET_ALL);
gtk_print_settings_set_print_pages (settings, GTK_PRINT_PAGES_ALL);
- gtk_print_settings_set_scale (settings, 1.0);
- gtk_print_settings_set_collate (settings, FALSE);
- gtk_print_settings_set_reverse (settings, FALSE);
-
+ if (capabilities & EV_FILE_EXPORTER_CAN_COPIES)
+ gtk_print_settings_set_n_copies (settings, 1);
+ if (capabilities & EV_FILE_EXPORTER_CAN_PAGE_SET)
+ gtk_print_settings_set_page_set (settings, GTK_PAGE_SET_ALL);
+ if (capabilities & EV_FILE_EXPORTER_CAN_SCALE)
+ gtk_print_settings_set_scale (settings, 1.0);
+ if (capabilities & EV_FILE_EXPORTER_CAN_COLLATE)
+ gtk_print_settings_set_collate (settings, FALSE);
+ if (capabilities & EV_FILE_EXPORTER_CAN_REVERSE)
+ gtk_print_settings_set_reverse (settings, FALSE);
+
if (window->priv->print_preview) {
gchar *uri;
gchar *print_settings_file = NULL;
dialog = gtk_print_unix_dialog_new (_("Print"), GTK_WINDOW (ev_window));
ev_window->priv->print_dialog = dialog;
- capabilities = GTK_PRINT_CAPABILITY_PAGE_SET |
- GTK_PRINT_CAPABILITY_COPIES |
- GTK_PRINT_CAPABILITY_COLLATE |
- GTK_PRINT_CAPABILITY_REVERSE |
- GTK_PRINT_CAPABILITY_SCALE |
- GTK_PRINT_CAPABILITY_GENERATE_PS |
- GTK_PRINT_CAPABILITY_PREVIEW;
-
- if (EV_IS_FILE_EXPORTER (ev_window->priv->document) &&
- ev_file_exporter_format_supported (EV_FILE_EXPORTER (ev_window->priv->document),
- EV_FILE_FORMAT_PDF)) {
- capabilities |= GTK_PRINT_CAPABILITY_GENERATE_PDF;
- }
-
+ capabilities = GTK_PRINT_CAPABILITY_PREVIEW |
+ ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (ev_window->priv->document));
gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
capabilities);
gtk_enumerate_printers ((GtkPrinterFunc) lookup_printer_from_name,
window, NULL, TRUE);
- g_assert (GTK_IS_PRINTER (window->priv->printer));
+ g_assert (GTK_IS_PRINTER (window->priv->printer));
page_setup = gtk_page_setup_new ();