diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2009-08-12 14:00:19 +0000 |
|---|---|---|
| committer | JazzyNico <JazzyNico@users.sourceforge.net> | 2009-08-12 14:00:19 +0000 |
| commit | 3c5b9a5d0a9df79c757435ad63514287cd5b211b (patch) | |
| tree | 0a22f3d90db1a915fa9d3c8031e621ae082c23e7 /src | |
| parent | Don't open 'Save as ...' dialog inside the application bundle on OS X when it... (diff) | |
| download | inkscape-3c5b9a5d0a9df79c757435ad63514287cd5b211b.tar.gz inkscape-3c5b9a5d0a9df79c757435ad63514287cd5b211b.zip | |
Fix for Bug #166678 (Paper size or orientation are not used when printing) by Adrian Johnson.
(bzr r8473)
Diffstat (limited to 'src')
| -rw-r--r-- | src/document.cpp | 19 | ||||
| -rw-r--r-- | src/document.h | 2 | ||||
| -rw-r--r-- | src/sp-root.h | 1 | ||||
| -rw-r--r-- | src/ui/dialog/print.cpp | 15 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 23 |
5 files changed, 45 insertions, 15 deletions
diff --git a/src/document.cpp b/src/document.cpp index 288e52c6d..17057e1dc 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -572,6 +572,25 @@ gdouble sp_document_height(SPDocument *document) return root->height.computed; } +void sp_document_set_landscape (SPDocument *document, gboolean landscape) +{ + SPRoot *root = SP_ROOT(document->root); + + root->landscape = landscape; + SP_OBJECT (root)->updateRepr(); +} + +gboolean sp_document_landscape(SPDocument *document) +{ + g_return_val_if_fail(document != NULL, 0.0); + g_return_val_if_fail(document->priv != NULL, 0.0); + g_return_val_if_fail(document->root != NULL, 0.0); + + SPRoot *root = SP_ROOT(document->root); + + return root->landscape; +} + Geom::Point sp_document_dimensions(SPDocument *doc) { return Geom::Point(sp_document_width(doc), sp_document_height(doc)); diff --git a/src/document.h b/src/document.h index 696e568ad..63ca221a2 100644 --- a/src/document.h +++ b/src/document.h @@ -185,12 +185,14 @@ SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gdouble sp_document_width(SPDocument *document); gdouble sp_document_height(SPDocument *document); +gboolean sp_document_landscape(SPDocument *document); Geom::Point sp_document_dimensions(SPDocument *document); struct SPUnit; void sp_document_set_width(SPDocument *document, gdouble width, const SPUnit *unit); void sp_document_set_height(SPDocument *document, gdouble height, const SPUnit *unit); +void sp_document_set_landscape(SPDocument *document, gboolean landscape); #define SP_DOCUMENT_URI(d) (d->uri) #define SP_DOCUMENT_NAME(d) (d->name) diff --git a/src/sp-root.h b/src/sp-root.h index 7976eb2f4..8b3cb4f0c 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -36,6 +36,7 @@ struct SPRoot : public SPGroup { SVGLength y; SVGLength width; SVGLength height; + gboolean landscape; /* viewBox; */ unsigned int viewBox_set : 1; diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 214b1a6db..d98d6a49e 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -188,12 +188,19 @@ Print::Print(SPDocument *doc, SPItem *base) : GtkPageSetup *page_setup = gtk_page_setup_new(); gdouble doc_width = sp_document_width(_doc) * PT_PER_PX; gdouble doc_height = sp_document_height(_doc) * PT_PER_PX; - GtkPaperSize *paper_size = gtk_paper_size_new_custom("custom", "custom", - doc_width, doc_height, GTK_UNIT_POINTS); + GtkPaperSize *paper_size; + if (sp_document_landscape(_doc)) { + gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); + paper_size = gtk_paper_size_new_custom("custom", "custom", + doc_height, doc_width, GTK_UNIT_POINTS); + } else { + gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_PORTRAIT); + paper_size = gtk_paper_size_new_custom("custom", "custom", + doc_width, doc_height, GTK_UNIT_POINTS); + } + gtk_page_setup_set_paper_size (page_setup, paper_size); -#ifndef WIN32 gtk_print_operation_set_default_page_setup (_printop, page_setup); -#endif gtk_print_operation_set_use_full_page (_printop, TRUE); // set up signals diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 02688a55e..6817d815b 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -345,11 +345,23 @@ PageSizer::setDim (double w, double h, bool changeList) _changedw_connection.block(); _changedh_connection.block(); + if ( w != h ) { + _landscapeButton.set_sensitive(true); + _portraitButton.set_sensitive (true); + _landscape = ( w > h ); + _landscapeButton.set_active(_landscape ? true : false); + _portraitButton.set_active (_landscape ? false : true); + } else { + _landscapeButton.set_sensitive(false); + _portraitButton.set_sensitive (false); + } + if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); double const old_height = sp_document_height(doc); sp_document_set_width (doc, w, &_px_unit); sp_document_set_height (doc, h, &_px_unit); + sp_document_set_landscape (doc, _landscape); // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); @@ -357,17 +369,6 @@ PageSizer::setDim (double w, double h, bool changeList) sp_document_done (doc, SP_VERB_NONE, _("Set page size")); } - if ( w != h ) { - _landscapeButton.set_sensitive(true); - _portraitButton.set_sensitive (true); - _landscape = ( w > h ); - _landscapeButton.set_active(_landscape ? true : false); - _portraitButton.set_active (_landscape ? false : true); - } else { - _landscapeButton.set_sensitive(false); - _portraitButton.set_sensitive (false); - } - if (changeList) { Gtk::TreeModel::Row row = (*find_paper_size(w, h)); |
