diff options
| author | kamalpreetgrewal <grewalkamal005@gmail.com> | 2016-06-10 06:57:53 +0000 |
|---|---|---|
| committer | kamalpreetgrewal <grewalkamal005@gmail.com> | 2016-06-10 06:57:53 +0000 |
| commit | 2b3f179e9c9e8f7d3836dc7350d34ebcc03f8326 (patch) | |
| tree | 07d53177432172f888df8be9ec0476f68aeba1cb /src | |
| parent | Set class attribute values of selected objects using style dialog (diff) | |
| parent | Fix make test target (diff) | |
| download | inkscape-2b3f179e9c9e8f7d3836dc7350d34ebcc03f8326.tar.gz inkscape-2b3f179e9c9e8f7d3836dc7350d34ebcc03f8326.zip | |
Merge changes from trunk
(bzr r14949.1.4)
Diffstat (limited to 'src')
| -rw-r--r-- | src/document.cpp | 5 | ||||
| -rw-r--r-- | src/file.cpp | 16 | ||||
| -rw-r--r-- | src/sp-namedview.cpp | 46 | ||||
| -rw-r--r-- | src/sp-namedview.h | 1 | ||||
| -rw-r--r-- | src/sp-root.cpp | 8 | ||||
| -rw-r--r-- | src/ui/tools/measure-tool.cpp | 2 | ||||
| -rw-r--r-- | src/version.cpp | 12 | ||||
| -rw-r--r-- | src/version.h | 3 | ||||
| -rw-r--r-- | src/widgets/paint-selector.cpp | 2 |
9 files changed, 53 insertions, 42 deletions
diff --git a/src/document.cpp b/src/document.cpp index e9388893e..d8c3f1269 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -369,11 +369,6 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, // Recursively build object tree document->root->invoke_build(document, rroot, false); - /* fixme: Not sure about this, but lets assume ::build updates */ - rroot->setAttribute("inkscape:version", Inkscape::version_string); - /* fixme: Again, I moved these here to allow version determining in ::build (Lauris) */ - - /* Eliminate obsolete sodipodi:docbase, for privacy reasons */ rroot->setAttribute("sodipodi:docbase", NULL); diff --git a/src/file.cpp b/src/file.cpp index 9d390908e..650ce5d0f 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -45,7 +45,7 @@ #include "helper/png-write.h" #include "id-clash.h" #include "inkscape.h" -#include "inkscape.h" +#include "inkscape-version.h" #include "ui/interface.h" #include "io/sys.h" #include "message.h" @@ -318,6 +318,12 @@ bool sp_file_open(const Glib::ustring &uri, // everyone who cares now has a reference, get rid of our`s doc->doUnref(); + SPRoot *root = doc->getRoot(); + + // This is the only place original values should be set. + root->original.inkscape = root->version.inkscape; + root->original.svg = root->version.svg; + // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); @@ -669,6 +675,8 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, if (!doc || uri.size()<1) //Safety check return false; + Inkscape::Version save = doc->getRoot()->version.inkscape; + doc->getReprRoot()->setAttribute("inkscape:version", Inkscape::version_string); try { Inkscape::Extension::save(key, doc, uri.c_str(), false, @@ -681,6 +689,8 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, sp_ui_error_dialog(text); g_free(text); g_free(safeUri); + // Restore Inkscape version + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::file_read_only &e) { gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str()); @@ -689,6 +699,7 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, sp_ui_error_dialog(text); g_free(text); g_free(safeUri); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::save_failed &e) { gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str()); @@ -697,14 +708,17 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, sp_ui_error_dialog(text); g_free(text); g_free(safeUri); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::save_cancelled &e) { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } catch (Inkscape::Extension::Output::no_overwrite &e) { return sp_file_save_dialog(parentWindow, doc, save_method); } catch (...) { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); + doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save )); return false; } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 06e068c42..616ec3921 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -59,25 +59,25 @@ static gboolean sp_str_to_bool(const gchar *str); static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color); SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { - this->zoom = 0; - this->guidecolor = 0; - this->guidehicolor = 0; - this->views.clear(); - this->borderlayer = 0; - this->page_size_units = NULL; - this->window_x = 0; - this->cy = 0; - this->window_y = 0; - this->svg_units = unit_table.getUnit("px"); // legacy behavior: if no viewbox present, default to 'px' units + + this->zoom = 0; + this->guidecolor = 0; + this->guidehicolor = 0; + this->views.clear(); + this->borderlayer = 0; + this->page_size_units = NULL; + this->window_x = 0; + this->cy = 0; + this->window_y = 0; this->display_units = NULL; - this->page_size_units = NULL; - this->pagecolor = 0; - this->cx = 0; - this->pageshadow = 0; - this->window_width = 0; - this->window_height = 0; - this->window_maximized = 0; - this->bordercolor = 0; + this->page_size_units = NULL; + this->pagecolor = 0; + this->cx = 0; + this->pageshadow = 0; + this->window_width = 0; + this->window_height = 0; + this->window_maximized = 0; + this->bordercolor = 0; this->editable = TRUE; this->showguides = TRUE; @@ -261,16 +261,6 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { // backwards compatibility with grid settings (pre 0.46) sp_namedview_generate_old_grid(this, document, repr); - - // If viewbox defined: try to calculate the SVG unit from document width and viewbox - if (document->getRoot()->viewBox_set) { - Inkscape::Util::Quantity svgwidth = document->getWidth(); - Geom::Rect viewbox = document->getRoot()->viewBox; - double factor = svgwidth.value(unit_table.primary(Inkscape::Util::UNIT_TYPE_LINEAR)) / viewbox.width(); - svg_units = unit_table.findUnit(factor, Inkscape::Util::UNIT_TYPE_LINEAR); - } else { // force the document units to be px - repr->setAttribute("inkscape:document-units", "px"); - } } void SPNamedView::release() { diff --git a/src/sp-namedview.h b/src/sp-namedview.h index ca85153b4..d8ac1a77e 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -64,7 +64,6 @@ public: std::vector<Inkscape::CanvasGrid *> grids; bool grids_visible; - Inkscape::Util::Unit const *svg_units; // Units used for the values in SVG Inkscape::Util::Unit const *display_units; // Units used for the UI (*not* the same as units of SVG coordinates) Inkscape::Util::Unit const *page_size_units; // Only used in "Custom size" part of Document Properties dialog diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 8bedec0a5..98eae2159 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -313,9 +313,11 @@ Inkscape::XML::Node *SPRoot::write(Inkscape::XML::Document *xml_doc, Inkscape::X repr = xml_doc->createElement("svg:svg"); } - if (flags & SP_OBJECT_WRITE_EXT) { - repr->setAttribute("inkscape:version", Inkscape::version_string); - } + /* Only update version string on successful write to file. This is handled by 'file_save()'. + * if (flags & SP_OBJECT_WRITE_EXT) { + * repr->setAttribute("inkscape:version", Inkscape::version_string); + * } + */ if (!repr->attribute("version")) { gchar *myversion = sp_version_to_string(this->version.svg); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 287828d32..5900a2359 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -778,7 +778,7 @@ void MeasureTool::toPhantom() measure_tmp_items.clear(); showCanvasItems(false, false, true); doc->ensureUpToDate(); - DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MEASURE,_("Add Stored to measure tool")); + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MEASURE,_("Keep last measure on the canvas, for reference")); } void MeasureTool::toItem() diff --git a/src/version.cpp b/src/version.cpp index abe855ee7..7610cd8e7 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -21,28 +21,36 @@ bool sp_version_from_string(const char *string, Inkscape::Version *version) if (!string) { return false; } - + try { std::stringstream ss; + + // Throw exception if error. + ss.exceptions(std::ios::failbit | std::ios::badbit); ss << string; ss >> version->_major; char tmp=0; ss >> tmp; ss >>version->_minor; + + // Don't throw exception if failbit gets set (empty string OK). + ss.exceptions(std::ios::goodbit); + getline(ss, version->_tail); return true; } catch(...) { version->_major = 0; version->_minor = 0; + version->_tail.clear(); return false; } } char *sp_version_to_string(Inkscape::Version version) { - return g_strdup_printf("%u.%u", version._major, version._minor); + return g_strdup_printf("%u.%u%s", version._major, version._minor, version._tail.c_str()); } bool sp_version_inside_range(Inkscape::Version version, diff --git a/src/version.h b/src/version.h index e17688b6d..f6221f6a6 100644 --- a/src/version.h +++ b/src/version.h @@ -13,6 +13,8 @@ #define SVG_VERSION "1.1" +#include <string> + namespace Inkscape { class Version { @@ -43,6 +45,7 @@ public: unsigned int _major; unsigned int _minor; + std::string _tail; // Development version }; } diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index aafa6bd1e..58a178aec 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -789,7 +789,7 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_LINEAR); //sp_gradient_selector_set_mode(SP_GRADIENT_SELECTOR(gsel), SP_GRADIENT_SELECTOR_MODE_LINEAR); gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Linear gradient</b>")); - } else if (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) { + } else if (mode == SPPaintSelector::MODE_GRADIENT_RADIAL) { SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_RADIAL); gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Radial gradient</b>")); } |
