Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2007-07-26 14:53:17 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2007-07-26 14:53:17 (GMT)
commite70119b293ab8a26bdea4a56407bb0f41f1e43aa (patch)
tree627b9853902c99806786543eb0155151925cfed6 /shell
parent0b6b9a984c7cfbf0e313a10f9bd09f77cb3be164 (diff)
Use capabilities to know which options should be offered by the print
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. svn path=/trunk/; revision=2580
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-jobs.c30
-rw-r--r--shell/ev-print-job.c47
-rw-r--r--shell/ev-window.c38
3 files changed, 55 insertions, 60 deletions
diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c
index 0f0a0da..d61185c 100644
--- a/shell/ev-jobs.c
+++ b/shell/ev-jobs.c
@@ -643,12 +643,13 @@ ev_job_print_do_page (EvJobPrint *job, gint page)
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));
@@ -671,14 +672,17 @@ ev_job_print_run (EvJobPrint *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++) {
diff --git a/shell/ev-print-job.c b/shell/ev-print-job.c
index 79076f9..d042ab6 100644
--- a/shell/ev-print-job.c
+++ b/shell/ev-print-job.c
@@ -45,16 +45,10 @@ struct _EvPrintJob {
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;
@@ -223,6 +217,7 @@ ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialo
{
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));
@@ -230,28 +225,31 @@ ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialo
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);
}
@@ -260,21 +258,16 @@ idle_print_handler (EvPrintJob *job)
{
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);
@@ -296,11 +289,11 @@ idle_print_handler (EvPrintJob *job)
}
} 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;
}
}
}
@@ -350,6 +343,8 @@ ev_print_job_print (EvPrintJob *job, GtkWindow *parent)
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);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 9f6f082..41b6836 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -2211,6 +2211,7 @@ ev_window_print_send (EvWindow *window,
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
@@ -2219,14 +2220,21 @@ ev_window_print_send (EvWindow *window,
* 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;
@@ -2457,20 +2465,8 @@ ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
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);
@@ -3441,7 +3437,7 @@ ev_window_cmd_preview_print (GtkAction *action, EvWindow *window)
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 ();