diff options
| author | Alex Leone <acleone~AT~gmail.com> | 2010-06-01 00:06:11 +0000 |
|---|---|---|
| committer | Alex Leone <acleone~AT~gmail.com> | 2010-06-01 00:06:11 +0000 |
| commit | 3c402d24e7fdce198befa42833574e802bfcd0e5 (patch) | |
| tree | 30ab3626c980134de384e37b6def483dab4726bc /src/ui/widget | |
| parent | Japanese translations updated by Masato HASHIMOTO (bug #514341) (diff) | |
| download | inkscape-3c402d24e7fdce198befa42833574e802bfcd0e5.tar.gz inkscape-3c402d24e7fdce198befa42833574e802bfcd0e5.zip | |
Makes the "Fit Page to Selection" margin options load from the opened file. (Bug #499942)
Fixed bugs:
- https://launchpad.net/bugs/499942
(bzr r9462)
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 69 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.h | 11 |
2 files changed, 61 insertions, 19 deletions
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index e604a24ec..05de86308 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -18,25 +18,26 @@ # include <config.h> #endif -#include <string.h> -#include <vector> -#include <string> - #include <cmath> #include <gtkmm.h> -#include "ui/widget/button.h" - -#include "ui/widget/scalar-unit.h" +#include <string> +#include <string.h> +#include <vector> -#include "helper/units.h" -#include "inkscape.h" -#include "verbs.h" #include "desktop-handles.h" #include "document.h" #include "desktop.h" -#include "page-sizer.h" #include "helper/action.h" +#include "helper/units.h" +#include "inkscape.h" +#include "page-sizer.h" +#include "sp-namedview.h" #include "sp-root.h" +#include "ui/widget/button.h" +#include "ui/widget/scalar-unit.h" +#include "verbs.h" +#include "xml/node.h" +#include "xml/repr.h" using std::pair; @@ -320,11 +321,11 @@ PageSizer::PageSizer(Registry & _wr) _marginTable.set_border_width(4); _marginTable.set_row_spacings(4); _marginTable.set_col_spacings(4); - _marginTable.attach(_fitPageButtonAlign, 0,2, 0,1); - _marginTable.attach(_marginTopAlign, 0,2, 1,2); - _marginTable.attach(_marginLeftAlign, 0,1, 2,3); - _marginTable.attach(_marginRightAlign, 1,2, 2,3); - _marginTable.attach(_marginBottomAlign, 0,2, 3,4); + _marginTable.attach(_marginTopAlign, 0,2, 0,1); + _marginTable.attach(_marginLeftAlign, 0,1, 1,2); + _marginTable.attach(_marginRightAlign, 1,2, 1,2); + _marginTable.attach(_marginBottomAlign, 0,2, 2,3); + _marginTable.attach(_fitPageButtonAlign, 0,2, 3,4); _marginTopAlign.set(0.5, 0.5, 0.0, 1.0); _marginTopAlign.add(_marginTop); @@ -437,6 +438,28 @@ PageSizer::setDim (double w, double h, bool changeList) _called = false; } +/** + * Updates the scalar widgets for the fit margins. (Just changes the value + * of the ui widgets to match the xml). + */ +void +PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr) +{ + double value = 0.0; + if (sp_repr_get_double(nv_repr, "fit-margin-top", &value)) { + _marginTop.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-left", &value)) { + _marginLeft.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-right", &value)) { + _marginRight.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-bottom", &value)) { + _marginBottom.setValue(value); + } +} + /** * Returns an iterator pointing to a row in paperSizeListStore which @@ -492,11 +515,23 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing() if (!dt) { return; } + SPDocument *doc; + SPNamedView *nv; + Inkscape::XML::Node *nv_repr; + if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP)) + && (nv = sp_document_namedview(doc, 0)) + && (nv_repr = SP_OBJECT_REPR(nv))) { + sp_repr_set_svg_double(nv_repr, "fit-margin-top", _marginTop.getValue()); + sp_repr_set_svg_double(nv_repr, "fit-margin-left", _marginLeft.getValue()); + sp_repr_set_svg_double(nv_repr, "fit-margin-right", _marginRight.getValue()); + sp_repr_set_svg_double(nv_repr, "fit-margin-bottom", _marginBottom.getValue()); + } Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING ); if (verb) { SPAction *action = verb->get_action(dt); - if (action) + if (action) { sp_action_perform(action, NULL); + } } } diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 718eb95b5..7c2048534 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -14,10 +14,11 @@ #include <gtkmm.h> #include <sigc++/sigc++.h> + +#include "helper/units.h" #include "ui/widget/registry.h" #include "ui/widget/registered-widget.h" -#include "helper/units.h" - +#include "xml/node.h" namespace Inkscape { namespace UI { @@ -141,6 +142,12 @@ public: * true, then reset the paper size list to the closest match */ void setDim (double w, double h, bool changeList=true); + + /** + * Updates the scalar widgets for the fit margins. (Just changes the value + * of the ui widgets to match the xml). + */ + void updateFitMarginsUI(Inkscape::XML::Node *nv_repr); protected: |
