summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 730dcc8)
raw | patch | inline | side by side (parent: 730dcc8)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Tue, 16 Oct 2007 19:42:27 +0000 (19:42 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Tue, 16 Oct 2007 19:42:27 +0000 (19:42 +0000) |
src/print.cpp | patch | blob | history |
diff --git a/src/print.cpp b/src/print.cpp
index a62733c6a8317e022da5c916415c38b711f58bbe..872a0234f4d4e6847fd03e14b05a150a517bebbe 100644 (file)
--- a/src/print.cpp
+++ b/src/print.cpp
#include "extension/system.h"
#include "print.h"
+#include <unit-constants.h>
+
#ifdef HAVE_GTK_UNIX_PRINT
# include <gtk/gtk.h>
# include <glibmm/i18n.h>
}
static void
-unix_print_dialog (const gchar * ps_file, const gchar * jobname)
+unix_print_dialog (const gchar * ps_file, const gchar * jobname, gdouble doc_width, gdouble doc_height)
{
Glib::ustring title = _("Print");
title += " ";
GtkPrinter* printer = gtk_print_unix_dialog_get_selected_printer(GTK_PRINT_UNIX_DIALOG(dlg));
if (gtk_printer_accepts_ps (printer)) {
+ GtkPageSetup *page_setup = gtk_print_unix_dialog_get_page_setup(GTK_PRINT_UNIX_DIALOG(dlg));
+
+ //It's important to set the right paper size here, otherwise it will
+ //default to letter; if for example an A4 is printed as a letter, then
+ //part of it will be truncated even when printing on A4 paper
+
+ //TODO: let the user decide upon the paper size, by enabling
+ //the drop down widget in the printing dialog. For now, we'll simply
+ //take the document's dimensions and communicate these to the printer
+ //driver
+
+ GtkPaperSize *page_size = gtk_paper_size_new_custom("custom", "custom", doc_width, doc_height, GTK_UNIT_POINTS);
+
+ gtk_page_setup_set_paper_size (page_setup, page_size);
+
GtkPrintJob* job = gtk_print_job_new (jobname, printer,
gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG(dlg)),
- gtk_print_unix_dialog_get_page_setup(GTK_PRINT_UNIX_DIALOG(dlg)));
-
-
+ page_setup);
+
+ GtkPaperSize* tmp = gtk_page_setup_get_paper_size(gtk_print_unix_dialog_get_page_setup(GTK_PRINT_UNIX_DIALOG(dlg)));
+
GError * error = NULL;
if ( gtk_print_job_set_source_file (job, ps_file, &error)) {
gtk_print_job_send (job, unix_print_complete, NULL, NULL);
#ifdef HAVE_GTK_UNIX_PRINT
// redirect output to new print dialog
- unix_print_dialog(tmpfile.c_str(),doc->name ? doc->name : _("SVG Document"));
+
+ // width and height in pt
+ gdouble width = sp_document_width(doc) * PT_PER_PX;
+ gdouble height = sp_document_height(doc) * PT_PER_PX;
+
+ unix_print_dialog(tmpfile.c_str(),doc->name ? doc->name : _("SVG Document"), width, height);
unlink(tmpfile.c_str());
// end redirected new print dialog
#endif