From e9468d5c8bc974ee96dc7537e0d13fe2def0e615 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 24 Aug 2013 23:36:04 +0200 Subject: Add listing procedural templates in NewFromTemplate dialog. (bzr r12481.1.1) --- src/ui/dialog/template-load-tab.cpp | 100 ++++++++++++++++++++++++------------ src/ui/dialog/template-load-tab.h | 4 ++ 2 files changed, 72 insertions(+), 32 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 265ee8026..280b3b073 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "interface.h" #include "file.h" @@ -27,6 +29,8 @@ #include "xml/repr.h" #include "xml/document.h" #include "xml/node.h" +#include "extension/db.h" +#include "extension/effect.h" namespace Inkscape { @@ -187,6 +191,10 @@ void TemplateLoadTab::_loadTemplates() // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); + + + // procedural templates + _getProceduralTemplates(); } @@ -209,7 +217,6 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: Inkscape::XML::Document *rdoc; rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; - Inkscape::XML::Node *dataNode; if (rdoc){ myRoot = rdoc->root(); @@ -221,37 +228,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: if (myRoot == NULL) // No template info return result; - - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_name")) != NULL) - result.display_name = dgettext("Document template name", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:author")) != NULL) - result.author = dataNode->firstChild()->content(); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_short")) != NULL) - result.short_description = dgettext("Document template short description", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_long") )!= NULL) - result.long_description = dgettext("Document template long description", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:preview")) != NULL) - result.preview_name = dataNode->firstChild()->content(); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:date")) != NULL){ - result.creation_date = dataNode->firstChild()->content(); - } - - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_keywords")) != NULL){ - Glib::ustring data = dataNode->firstChild()->content(); - while (!data.empty()){ - std::size_t pos = data.find_first_of(" "); - if (pos == Glib::ustring::npos) - pos = data.size(); - - Glib::ustring keyword = dgettext("Document template keyword", data.substr(0, pos).data()); - result.keywords.insert(keyword); - _keywords.insert(keyword); - - if (pos == data.size()) - break; - data.erase(0, pos+1); - } - } + _getDataFromNode(myRoot, result); } return result; @@ -277,5 +254,64 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) } } + +void TemplateLoadTab::_getProceduralTemplates() +{ + std::list effects; + Inkscape::Extension::db.get_effect_list(effects); + + std::list::iterator it = effects.begin(); + while (it != effects.end()){ + Inkscape::XML::Node *myRoot; + myRoot = (*it)->get_repr(); + myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + + if (myRoot){ + TemplateData result; + result.display_name = (*it)->get_name(); + result.is_procedural = true; + result.path = ""; + _getDataFromNode(myRoot, result); + _tdata[result.display_name] = result; + } + ++it; + } +} + + +void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateData &data) +{ + Inkscape::XML::Node *currentData; + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_name")) != NULL) + data.display_name = dgettext("Document template name", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) + data.author = currentData->firstChild()->content(); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_short")) != NULL) + data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) + data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:preview")) != NULL) + data.preview_name = currentData->firstChild()->content(); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:date")) != NULL) + data.creation_date = currentData->firstChild()->content(); + + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_keywords")) != NULL){ + Glib::ustring tplKeywords = currentData->firstChild()->content(); + while (!tplKeywords.empty()){ + std::size_t pos = tplKeywords.find_first_of(" "); + if (pos == Glib::ustring::npos) + pos = tplKeywords.size(); + + Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); + data.keywords.insert(keyword); + _keywords.insert(keyword); + + if (pos == tplKeywords.size()) + break; + tplKeywords.erase(0, pos+1); + } + } +} + } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 50f3e0be2..c3817cf1b 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -19,6 +19,8 @@ #include #include +#include "xml/node.h" + namespace Inkscape { namespace UI { @@ -91,6 +93,8 @@ private: SearchType _current_search_type; + void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); + void _getProceduralTemplates(); void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); TemplateData _processTemplateFile(const Glib::ustring &); -- cgit v1.2.3 From 77f61343ff18f29f05331131c2fe2bd810a64498 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 25 Aug 2013 19:42:22 -0400 Subject: Use real world units for page sizes. (bzr r12475.1.1) --- src/ui/dialog/document-properties.cpp | 30 +++++++++++++-- src/ui/widget/page-sizer.cpp | 69 +++++++++++++++++++---------------- src/ui/widget/page-sizer.h | 8 +++- 3 files changed, 70 insertions(+), 37 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 77fb182e5..430f28474 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1433,9 +1433,33 @@ void DocumentProperties::update() if (nv->doc_units) _rum_deflt.setUnit (nv->doc_units->abbr); - double const doc_w_px = sp_desktop_document(dt)->getWidth(); - double const doc_h_px = sp_desktop_document(dt)->getHeight(); - _page_sizer.setDim (doc_w_px, doc_h_px); + double const doc_w = sp_desktop_document(dt)->getRoot()->width.value; + Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit).abbr; + if (doc_w_unit == "") { + if (nv->units) { + doc_w_unit = nv->units->abbr; + } else { + if (nv->doc_units) { + doc_w_unit = nv->doc_units->abbr; + } else { + doc_w_unit = "px"; + } + } + } + double const doc_h = sp_desktop_document(dt)->getRoot()->height.value; + Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit).abbr; + if (doc_h_unit == "") { + if (nv->units) { + doc_h_unit = nv->units->abbr; + } else { + if (nv->doc_units) { + doc_h_unit = nv->doc_units->abbr; + } else { + doc_h_unit = "px"; + } + } + } + _page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit)); _page_sizer.updateFitMarginsUI(nv->getRepr()); //-----------------------------------------------------------guide page diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 8287452d7..5a289096c 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -442,6 +442,7 @@ PageSizer::init () _portrait_connection = _portraitButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_portrait)); _changedw_connection = _dimensionWidth.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed)); _changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed)); + _changedu_connection = _dimensionUnits.getUnitMenu()->signal_changed().connect (sigc::mem_fun (*this, &PageSizer::on_units_changed)); _fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing)); show_all_children(); @@ -454,11 +455,11 @@ PageSizer::init () * 'changeList' is true, then adjust the paperSizeList to show the closest * standard page size. * - * \param w, h given in px + * \param w, h * \param changeList whether to modify the paper size list */ void -PageSizer::setDim (double w, double h, bool changeList) +PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList) { static bool _called = false; if (_called) { @@ -476,19 +477,19 @@ PageSizer::setDim (double w, double h, bool changeList) if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); double const old_height = doc->getHeight(); - doc->setWidth (Inkscape::Util::Quantity(w, "px")); - doc->setHeight (Inkscape::Util::Quantity(h, "px")); + doc->setWidth (w); + doc->setHeight (h); // 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))); + Geom::Translate const vert_offset(Geom::Point(0, (old_height - h.quantity))); doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } - if ( w != h ) { + if ( w.quantity != h.quantity ) { _landscapeButton.set_sensitive(true); _portraitButton.set_sensitive (true); - _landscape = ( w > h ); + _landscape = ( w.quantity > h.quantity ); _landscapeButton.set_active(_landscape ? true : false); _portraitButton.set_active (_landscape ? false : true); } else { @@ -503,9 +504,10 @@ PageSizer::setDim (double w, double h, bool changeList) _paperSizeListSelection->select(row); } - Unit const& unit = _dimensionUnits.getUnit(); - _dimensionWidth.setValue (w / unit.factor); - _dimensionHeight.setValue (h / unit.factor); + _dimensionWidth.setUnit(w.unit->abbr); + _dimensionWidth.setValue (w.quantity); + _dimensionHeight.setUnit(h.unit->abbr); + _dimensionHeight.setValue (h.quantity); _paper_size_list_connection.unblock(); _landscape_connection.unblock(); @@ -547,12 +549,12 @@ PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr) * paperSizeListStore->children().end() if no such paper exists. */ Gtk::ListStore::iterator -PageSizer::find_paper_size (double w, double h) const +PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h) const { - double smaller = w; - double larger = h; - if ( h < w ) { - smaller = h; larger = w; + double smaller = w.quantity; + double larger = h.quantity; + if ( h.quantity < w.quantity ) { + smaller = h.quantity; larger = w.quantity; } g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end()); @@ -562,8 +564,8 @@ PageSizer::find_paper_size (double w, double h) const iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; Inkscape::Util::Unit const &i_unit = paper.unit; - double smallX = Inkscape::Util::Quantity::convert(paper.smaller, i_unit, "px"); - double largeX = Inkscape::Util::Quantity::convert(paper.larger, i_unit, "px"); + double smallX = Inkscape::Util::Quantity::convert(paper.smaller, i_unit, *w.unit); + double largeX = Inkscape::Util::Quantity::convert(paper.larger, i_unit, *w.unit); g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); @@ -643,8 +645,8 @@ PageSizer::on_paper_size_list_changed() return; } PaperSize paper = piter->second; - double w = paper.smaller; - double h = paper.larger; + Inkscape::Util::Quantity w = Inkscape::Util::Quantity(paper.smaller, paper.unit); + Inkscape::Util::Quantity h = Inkscape::Util::Quantity(paper.larger, paper.unit); if (std::find(lscape_papers.begin(), lscape_papers.end(), paper.name.c_str()) != lscape_papers.end()) { // enforce landscape mode if this is desired for the given page format @@ -654,9 +656,6 @@ PageSizer::on_paper_size_list_changed() _landscape = _landscapeButton.get_active(); } - w = Inkscape::Util::Quantity::convert(w, paper.unit, "px"); - h = Inkscape::Util::Quantity::convert(h, paper.unit, "px"); - if (_landscape) setDim (h, w, false); else @@ -673,9 +672,9 @@ PageSizer::on_portrait() { if (!_portraitButton.get_active()) return; - double w = _dimensionWidth.getValue ("px"); - double h = _dimensionHeight.getValue ("px"); - if (h < w) { + Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); + Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); + if (h.quantity < w.quantity) { setDim (h, w); } } @@ -689,9 +688,9 @@ PageSizer::on_landscape() { if (!_landscapeButton.get_active()) return; - double w = _dimensionWidth.getValue ("px"); - double h = _dimensionHeight.getValue ("px"); - if (w < h) { + Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); + Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); + if (w.quantity < h.quantity) { setDim (h, w); } } @@ -703,11 +702,17 @@ void PageSizer::on_value_changed() { if (_widgetRegistry->isUpdating()) return; - - setDim (_dimensionWidth.getValue("px"), - _dimensionHeight.getValue("px")); + if (_unit != _dimensionUnits.getUnit().abbr) return; + setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), + Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); +} +void +PageSizer::on_units_changed() +{ + _unit = _dimensionUnits.getUnit().abbr; + setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), + Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); } - } // namespace Widget } // namespace UI diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 34ed7592d..95836a005 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -161,7 +161,7 @@ public: * Set the page size to the given dimensions. If 'changeList' is * true, then reset the paper size list to the closest match */ - void setDim (double w, double h, bool changeList=true); + void setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList=true); /** * Updates the scalar widgets for the fit margins. (Just changes the value @@ -179,7 +179,7 @@ protected: /** * Find the closest standard paper size in the table, to the */ - Gtk::ListStore::iterator find_paper_size (double w, double h) const; + Gtk::ListStore::iterator find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h) const; void fire_fit_canvas_to_selection_or_drawing(); @@ -252,13 +252,17 @@ protected: //callback void on_value_changed(); + void on_units_changed(); sigc::connection _changedw_connection; sigc::connection _changedh_connection; + sigc::connection _changedu_connection; Registry *_widgetRegistry; //### state - whether we are currently landscape or portrait bool _landscape; + + Glib::ustring _unit; }; -- cgit v1.2.3 From f10048be170a45921ae8fc65ccd2588a9ad2897d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 12:32:55 -0400 Subject: Added viewBox implement document unit support. (bzr r12475.1.2) --- src/ui/dialog/aboutbox.cpp | 5 ++-- src/ui/dialog/document-properties.cpp | 43 ++++++++++++++++++++--------------- src/ui/dialog/document-properties.h | 4 ++++ src/ui/dialog/export.cpp | 6 ++--- src/ui/dialog/print.cpp | 8 +++---- src/ui/widget/page-sizer.cpp | 5 ++-- 6 files changed, 42 insertions(+), 29 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 6f1137e46..121773b6d 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -34,6 +34,7 @@ #include "svg-view-widget.h" #include "sp-text.h" #include "text-editing.h" +#include "util/units.h" #include "inkscape-version.h" @@ -175,8 +176,8 @@ Gtk::Widget *build_splash_widget() { GtkWidget *v=sp_svg_view_widget_new(doc); - double width=doc->getWidth(); - double height=doc->getHeight(); + double width=doc->getWidth().value("px"); + double height=doc->getHeight().value("px"); doc->doUnref(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 430f28474..272b85d2a 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -54,6 +54,8 @@ #include #include +#include <2geom/transforms.h> + using std::pair; namespace Inkscape { @@ -169,6 +171,9 @@ DocumentProperties::DocumentProperties() signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced)); signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop)); signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); + + _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); + _old_doc_unit = _rum_deflt.getUnit(); } void DocumentProperties::init() @@ -1436,28 +1441,12 @@ void DocumentProperties::update() double const doc_w = sp_desktop_document(dt)->getRoot()->width.value; Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit).abbr; if (doc_w_unit == "") { - if (nv->units) { - doc_w_unit = nv->units->abbr; - } else { - if (nv->doc_units) { - doc_w_unit = nv->doc_units->abbr; - } else { - doc_w_unit = "px"; - } - } + doc_w_unit = "px"; } double const doc_h = sp_desktop_document(dt)->getRoot()->height.value; Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit).abbr; if (doc_h_unit == "") { - if (nv->units) { - doc_h_unit = nv->units->abbr; - } else { - if (nv->doc_units) { - doc_h_unit = nv->doc_units->abbr; - } else { - doc_h_unit = "px"; - } - } + doc_h_unit = "px"; } _page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit)); _page_sizer.updateFitMarginsUI(nv->getRepr()); @@ -1642,6 +1631,24 @@ void DocumentProperties::onRemoveGrid() } } +/** Callback for document unit change. */ +void DocumentProperties::onDocUnitChange() +{ + SPDocument *doc = SP_ACTIVE_DOCUMENT; + Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit(); + + // Set viewBox + Inkscape::Util::Quantity width = doc->getWidth(); + Inkscape::Util::Quantity height = doc->getHeight(); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); + + // Scale and translate objects + gdouble scale = Inkscape::Util::Quantity::convert(1, _old_doc_unit, doc_unit); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + + _old_doc_unit = doc_unit; + DocumentUndo::done(doc, SP_VERB_NONE, _("Changed document unit")); +} } // namespace Dialog } // namespace UI diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 56fed30c4..56abf9741 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -216,6 +216,10 @@ private: // callback methods for buttons on grids page. void onNewGrid(); void onRemoveGrid(); + + // callback for document unit change + Inkscape::Util::Unit _old_doc_unit; + void onDocUnitChange(); }; } // namespace Dialog diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2c92608d7..c98e23000 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -762,7 +762,7 @@ void Export::onAreaToggled () } case SELECTION_PAGE: bbox = Geom::Rect(Geom::Point(0.0, 0.0), - Geom::Point(doc->getWidth(), doc->getHeight())); + Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px"))); // std::cout << "Using selection: PAGE" << std::endl; key = SELECTION_PAGE; @@ -1475,8 +1475,8 @@ void Export::detectSize() { doc = sp_desktop_document (SP_ACTIVE_DESKTOP); Geom::Point x(0.0, 0.0); - Geom::Point y(doc->getWidth(), - doc->getHeight()); + Geom::Point y(doc->getWidth().value("px"), + doc->getHeight().value("px")); Geom::Rect bbox(x, y); if (bbox_equal(bbox,current_bbox)) { diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 4c8c77f96..3ce75327f 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -49,8 +49,8 @@ static void draw_page( if (junk->_tab->as_bitmap()) { // Render as exported PNG - gdouble width = (junk->_doc)->getWidth(); - gdouble height = (junk->_doc)->getHeight(); + gdouble width = (junk->_doc)->getWidth().value("px"); + gdouble height = (junk->_doc)->getHeight().value("px"); gdouble dpi = junk->_tab->bitmap_dpi(); std::string tmp_png; std::string tmp_base = "inkscape-print-png-XXXXXX"; @@ -195,8 +195,8 @@ Print::Print(SPDocument *doc, SPItem *base) : // set up paper size to match the document size gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS); GtkPageSetup *page_setup = gtk_page_setup_new(); - gdouble doc_width = _doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt"); - gdouble doc_height = _doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt"); + gdouble doc_width = _doc->getWidth().value("pt"); + gdouble doc_height = _doc->getHeight().value("pt"); GtkPaperSize *paper_size; if (doc_width > doc_height) { gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 5a289096c..94c7b453a 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -476,12 +476,12 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); - double const old_height = doc->getHeight(); + Inkscape::Util::Quantity const old_height = doc->getHeight(); doc->setWidth (w); doc->setHeight (h); // 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.quantity))); + Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - h.value("px")))); doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } @@ -709,6 +709,7 @@ PageSizer::on_value_changed() void PageSizer::on_units_changed() { + if (_widgetRegistry->isUpdating()) return; _unit = _dimensionUnits.getUnit().abbr; setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); -- cgit v1.2.3 From df50dc11aa33a9ceeaa0cac84dd3a869680e998f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 22:53:42 -0400 Subject: Use Quantity comparisons in PageSizer. (bzr r12475.1.8) --- src/ui/widget/page-sizer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 94c7b453a..051937c43 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -486,10 +486,10 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } - if ( w.quantity != h.quantity ) { + if ( w != h ) { _landscapeButton.set_sensitive(true); _portraitButton.set_sensitive (true); - _landscape = ( w.quantity > h.quantity ); + _landscape = ( w > h ); _landscapeButton.set_active(_landscape ? true : false); _portraitButton.set_active (_landscape ? false : true); } else { @@ -553,7 +553,7 @@ PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity { double smaller = w.quantity; double larger = h.quantity; - if ( h.quantity < w.quantity ) { + if ( h < w ) { smaller = h.quantity; larger = w.quantity; } @@ -674,7 +674,7 @@ PageSizer::on_portrait() return; Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); - if (h.quantity < w.quantity) { + if (h < w) { setDim (h, w); } } @@ -690,7 +690,7 @@ PageSizer::on_landscape() return; Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); - if (w.quantity < h.quantity) { + if (w < h) { setDim (h, w); } } -- cgit v1.2.3 From 3bfb610bb7719d49821fe5381ae449789c3cb968 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 23:32:14 -0400 Subject: Improve code readability. (bzr r12475.1.9) --- src/ui/clipboard.cpp | 4 ++-- src/ui/dialog/print.cpp | 4 ++-- src/ui/dialog/text-edit.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 629960613..084b2ebd8 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1084,8 +1084,8 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); - unsigned long int width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); - unsigned long int height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); + unsigned long int width = (unsigned long int) (Inkscape::Util::Quantity::convert(area.width(), "px", "in") * dpi + 0.5); + unsigned long int height = (unsigned long int) (Inkscape::Util::Quantity::convert(area.height(), "in", "px") * dpi + 0.5); // read from namedview Inkscape::XML::Node *nv = sp_repr_lookup_name (_clipboardSPDoc->rroot, "sodipodi:namedview"); diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 3ce75327f..e6dae278b 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -72,8 +72,8 @@ static void draw_page( sp_export_png_file(junk->_doc, tmp_png.c_str(), 0.0, 0.0, width, height, - (unsigned long)(width * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), - (unsigned long)(height * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), + (unsigned long)(Inkscape::Util::Quantity::convert(width, "px", "in") * dpi), + (unsigned long)(Inkscape::Util::Quantity::convert(height, "px", "in") * dpi), dpi, dpi, bgcolor, NULL, NULL, true, NULL); // This doesn't seem to work: diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 4a25f723b..9124681a0 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -401,7 +401,7 @@ void TextEdit::setPreviewText (Glib::ustring font_spec, Glib::ustring phrase) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); - double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * Inkscape::Util::Quantity::convert(1, "px", "pt"); + double pt_size = Inkscape::Util::Quantity::convert(sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit), "px", "pt"); // Pango font size is in 1024ths of a point // C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE ); -- cgit v1.2.3 From 100be92caf253e8743126da4264e84a060c82182 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 4 Sep 2013 11:50:07 +0200 Subject: Creating documents from procedural templates added. (bzr r12481.1.2) --- src/ui/dialog/template-load-tab.cpp | 2 ++ src/ui/dialog/template-load-tab.h | 2 ++ src/ui/dialog/template-widget.cpp | 59 +++++++++++++++++++++++-------------- src/ui/dialog/template-widget.h | 1 + 4 files changed, 42 insertions(+), 22 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 280b3b073..11511d7fc 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -271,6 +271,8 @@ void TemplateLoadTab::_getProceduralTemplates() result.display_name = (*it)->get_name(); result.is_procedural = true; result.path = ""; + result.tpl_effect = *it; + _getDataFromNode(myRoot, result); _tdata[result.display_name] = result; } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index c3817cf1b..cdf8a0ade 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -20,6 +20,7 @@ #include #include "xml/node.h" +#include "extension/effect.h" namespace Inkscape { @@ -42,6 +43,7 @@ public: Glib::ustring preview_name; Glib::ustring creation_date; std::set keywords; + Inkscape::Extension::Effect *tpl_effect; }; TemplateLoadTab(); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index be7e2b515..21ea709f2 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -20,6 +20,10 @@ #include "template-load-tab.h" #include "file.h" +#include "extension/implementation/implementation.h" + +#include "inkscape.h" +#include "desktop.h" namespace Inkscape { namespace UI { @@ -30,6 +34,7 @@ TemplateWidget::TemplateWidget() , _short_description_label(_(" ")) , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) + , _effect_prefs(NULL) { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); @@ -55,10 +60,13 @@ TemplateWidget::TemplateWidget() void TemplateWidget::create() { - if (_current_template.path == "") + if (_current_template.display_name == "") return; - if (_current_template.is_procedural) {} + if (_current_template.is_procedural){ + SPDesktop *desc = sp_file_new_default(); + _current_template.tpl_effect->effect(desc); + } else { sp_file_new(_current_template.path); } @@ -68,34 +76,41 @@ void TemplateWidget::create() void TemplateWidget::display(TemplateLoadTab::TemplateData data) { _current_template = data; - if (data.is_procedural){} - else{ - _template_name_label.set_text(_current_template.display_name); - _template_author_label.set_text(_current_template.author); - _short_description_label.set_text(_current_template.short_description); + + _template_name_label.set_text(_current_template.display_name); + // _template_author_label.set_text(_current_template.author); + _short_description_label.set_text(_current_template.short_description); - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); - if (data.preview_name != ""){ - _preview_image.set(imagePath); - _preview_image.show(); - _preview_render.hide(); - } - else{ - _preview_render.showImage(data.path); - _preview_render.show(); - _preview_image.hide(); - } + _preview_render.hide(); + _preview_image.hide(); + + Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + if (data.preview_name != ""){ + _preview_image.set(imagePath); + _preview_image.show(); + } + else if (!data.is_procedural){ + _preview_render.showImage(data.path); + _preview_render.show(); + } + + if (_effect_prefs != NULL){ + remove (*_effect_prefs); + _effect_prefs = NULL; + } + if (data.is_procedural){ + _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); // SP_ACTIVE_DESKTOP? + pack_start(*_effect_prefs); } } void TemplateWidget::_displayTemplateDetails() { - if (_current_template.path == "") - return; + Glib::ustring message = _current_template.display_name + "\n\n"; - Glib::ustring message = _current_template.display_name + "\n\n" + - _("Path: ") + _current_template.path + "\n\n"; + if (_current_template.path != "") + message += _("Path: ") + _current_template.path + "\n\n"; if (_current_template.long_description != "") message += _("Description: ") + _current_template.long_description + "\n\n"; diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index f7e1267ce..a41a14a38 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -38,6 +38,7 @@ private: Gtk::Label _short_description_label; Gtk::Label _template_author_label; Gtk::Label _template_name_label; + Gtk::Widget *_effect_prefs; void _displayTemplateDetails(); }; -- cgit v1.2.3 From 0661bbe927d7847e2d88c3f4ec51e59a549f8c78 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 11 Sep 2013 18:47:47 -0400 Subject: Fix document unit change undo bug. (bzr r12475.1.14) --- src/ui/dialog/document-properties.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 272b85d2a..a2712bf68 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -35,6 +35,7 @@ #include "sp-object-repr.h" #include "sp-root.h" #include "sp-script.h" +#include "svg/stringstream.h" #include "ui/widget/color-picker.h" #include "ui/widget/scalar-unit.h" #include "ui/dialog/filedialog.h" @@ -172,6 +173,7 @@ DocumentProperties::DocumentProperties() signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop)); signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); + _rum_deflt._changed_connection.block(); _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); _old_doc_unit = _rum_deflt.getUnit(); } @@ -1637,6 +1639,17 @@ void DocumentProperties::onDocUnitChange() SPDocument *doc = SP_ACTIVE_DOCUMENT; Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit(); + // Don't execute when change is being undone + if (!DocumentUndo::getUndoSensitive(doc)) { + return; + } + + // Set document unit + Inkscape::SVGOStringStream os; + os << doc_unit.abbr; + Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); + repr->setAttribute("inkscape:document-units", os.str().c_str()); + // Set viewBox Inkscape::Util::Quantity width = doc->getWidth(); Inkscape::Util::Quantity height = doc->getHeight(); @@ -1646,6 +1659,8 @@ void DocumentProperties::onDocUnitChange() gdouble scale = Inkscape::Util::Quantity::convert(1, _old_doc_unit, doc_unit); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + doc->setModifiedSinceSave(); + _old_doc_unit = doc_unit; DocumentUndo::done(doc, SP_VERB_NONE, _("Changed document unit")); } -- cgit v1.2.3 From 93167c446a8a8e5574e94cda37dc91c17072513b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 11 Sep 2013 19:35:54 -0400 Subject: Finish fixing document unit change undo bug. (bzr r12475.1.15) --- src/ui/dialog/document-properties.cpp | 10 ++++++---- src/ui/dialog/document-properties.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index a2712bf68..1b2761b13 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -175,7 +175,6 @@ DocumentProperties::DocumentProperties() _rum_deflt._changed_connection.block(); _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); - _old_doc_unit = _rum_deflt.getUnit(); } void DocumentProperties::init() @@ -1637,6 +1636,11 @@ void DocumentProperties::onRemoveGrid() void DocumentProperties::onDocUnitChange() { SPDocument *doc = SP_ACTIVE_DOCUMENT; + Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); + Inkscape::Util::Unit old_doc_unit = unit_table.getUnit("px"); + if(repr->attribute("inkscape:document-units")) { + old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units")); + } Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit(); // Don't execute when change is being undone @@ -1647,7 +1651,6 @@ void DocumentProperties::onDocUnitChange() // Set document unit Inkscape::SVGOStringStream os; os << doc_unit.abbr; - Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->setAttribute("inkscape:document-units", os.str().c_str()); // Set viewBox @@ -1656,12 +1659,11 @@ void DocumentProperties::onDocUnitChange() doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); // Scale and translate objects - gdouble scale = Inkscape::Util::Quantity::convert(1, _old_doc_unit, doc_unit); + gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); doc->setModifiedSinceSave(); - _old_doc_unit = doc_unit; DocumentUndo::done(doc, SP_VERB_NONE, _("Changed document unit")); } diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 56abf9741..e3ca91731 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -218,7 +218,6 @@ private: void onRemoveGrid(); // callback for document unit change - Inkscape::Util::Unit _old_doc_unit; void onDocUnitChange(); }; -- cgit v1.2.3 From 09c1fee60bcd713fe66178021053d59e3f649660 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 14 Sep 2013 16:37:55 -0400 Subject: Fix bug with tool handles during document unit change. (bzr r12475.1.17) --- src/ui/dialog/document-properties.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 1b2761b13..0c39876ea 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -31,11 +31,13 @@ #include "inkscape.h" #include "io/sys.h" #include "preferences.h" +#include "shape-editor.h" #include "sp-namedview.h" #include "sp-object-repr.h" #include "sp-root.h" #include "sp-script.h" #include "svg/stringstream.h" +#include "tools-switch.h" #include "ui/widget/color-picker.h" #include "ui/widget/scalar-unit.h" #include "ui/dialog/filedialog.h" @@ -1658,9 +1660,16 @@ void DocumentProperties::onDocUnitChange() Inkscape::Util::Quantity height = doc->getHeight(); doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); + // TODO: Fix bug in nodes tool instead of switching away from it + if (tools_active(getDesktop()) == TOOLS_NODES) { + tools_switch(getDesktop(), TOOLS_SELECT); + } + // Scale and translate objects gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit); + ShapeEditor::blockSetItem(true); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + ShapeEditor::blockSetItem(false); doc->setModifiedSinceSave(); -- cgit v1.2.3 From 5dc7ab56d1f8bf9b51367702e13788f8eea00aaf Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 21:58:27 +0200 Subject: Removed search templates case sensitivity (bzr r12481.1.4) --- src/ui/dialog/template-load-tab.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 11511d7fc..ababd4ca3 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -156,7 +156,7 @@ void TemplateLoadTab::_refreshTemplatesList() case LIST_KEYWORD: { for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) != 0){ + if (it->second.keywords.count(_current_keyword.lowercase()) != 0){ Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; row[_columns.textValue] = it->first; @@ -167,11 +167,11 @@ void TemplateLoadTab::_refreshTemplatesList() case USER_SPECIFIED : { for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) != 0 || - it->second.display_name.find(_current_keyword) != Glib::ustring::npos || - it->second.author.find(_current_keyword) != Glib::ustring::npos || - it->second.short_description.find(_current_keyword) != Glib::ustring::npos || - it->second.long_description.find(_current_keyword) != Glib::ustring::npos ) + if (it->second.keywords.count(_current_keyword.lowercase()) != 0 || + it->second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; @@ -192,7 +192,6 @@ void TemplateLoadTab::_loadTemplates() // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); - // procedural templates _getProceduralTemplates(); } @@ -305,8 +304,8 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa pos = tplKeywords.size(); Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); - data.keywords.insert(keyword); - _keywords.insert(keyword); + data.keywords.insert(keyword.lowercase()); + _keywords.insert(keyword.lowercase()); if (pos == tplKeywords.size()) break; -- cgit v1.2.3 From fbaf8db2eb5c15ac84348f9e9de3303c78860f62 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 22:36:28 +0200 Subject: Fixed available undo after new template creation. (bzr r12481.1.6) --- src/ui/dialog/template-widget.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 21ea709f2..6ead7ef8d 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -24,6 +24,9 @@ #include "inkscape.h" #include "desktop.h" +#include "desktop-handles.h" +#include "document.h" +#include "document-undo.h" namespace Inkscape { namespace UI { @@ -66,6 +69,7 @@ void TemplateWidget::create() if (_current_template.is_procedural){ SPDesktop *desc = sp_file_new_default(); _current_template.tpl_effect->effect(desc); + DocumentUndo::clearUndo(sp_desktop_document(desc)); } else { sp_file_new(_current_template.path); -- cgit v1.2.3 From bd94128f84bc367d11815c53347eb8d5b5557c5e Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 23:18:47 +0200 Subject: Fix procedural templates "modified" status. (bzr r12481.1.7) --- src/ui/dialog/template-widget.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 6ead7ef8d..1e0900a07 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -70,6 +70,7 @@ void TemplateWidget::create() SPDesktop *desc = sp_file_new_default(); _current_template.tpl_effect->effect(desc); DocumentUndo::clearUndo(sp_desktop_document(desc)); + sp_desktop_document(desc)->setModifiedSinceSave(false); } else { sp_file_new(_current_template.path); -- cgit v1.2.3 From 5614df9770b985070122b3c08b45902317c9bd15 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 19:07:21 -0400 Subject: Enable unit evaluation in toolbars. (bzr r12475.1.22) --- src/ui/widget/spinbutton.cpp | 10 ++++++++-- src/ui/widget/spinbutton.h | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index c107979a8..2c95e8b5a 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -14,6 +14,7 @@ #include "spinbutton.h" #include "unit-menu.h" +#include "unit-tracker.h" #include "util/expression-evaluator.h" #include "event-context.h" @@ -33,8 +34,13 @@ int SpinButton::on_input(double* newvalue) { try { Inkscape::Util::GimpEevlQuantity result; - if (_unit_menu) { - Unit unit = _unit_menu->getUnit(); + if (_unit_menu || _unit_tracker) { + Unit unit; + if (_unit_menu) { + unit = _unit_menu->getUnit(); + } else { + unit = _unit_tracker->getActiveUnit(); + } result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); // check if output dimension corresponds to input unit if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index fe5d699e7..c772fe2a2 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -25,6 +25,7 @@ namespace UI { namespace Widget { class UnitMenu; +class UnitTracker; /** * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu), @@ -50,14 +51,18 @@ public: _unit_menu(NULL) { connect_signals(); + _unit_tracker = NULL; }; virtual ~SpinButton() {}; void setUnitMenu(UnitMenu* unit_menu) { _unit_menu = unit_menu; }; + + void addUnitTracker(UnitTracker* ut) { _unit_tracker = ut; }; protected: UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + UnitTracker *_unit_tracker; // Linked unit tracker for unit conversion in entered expressions. void connect_signals(); -- cgit v1.2.3 From f55a53ef2d861b634ad83622edc5e26430baeae0 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 23:59:14 -0400 Subject: C++ify expression evaluator. (bzr r12475.1.23) --- src/ui/widget/spinbutton.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 2c95e8b5a..62c17f821 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -33,7 +33,7 @@ SpinButton::connect_signals() { int SpinButton::on_input(double* newvalue) { try { - Inkscape::Util::GimpEevlQuantity result; + Inkscape::Util::EvaluatorQuantity result; if (_unit_menu || _unit_tracker) { Unit unit; if (_unit_menu) { @@ -41,13 +41,15 @@ int SpinButton::on_input(double* newvalue) } else { unit = _unit_tracker->getActiveUnit(); } - result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), &unit); + result = eval.evaluate(); // check if output dimension corresponds to input unit if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); } } else { - result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), NULL); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), NULL); + result = eval.evaluate(); } *newvalue = result.value; -- cgit v1.2.3 From c549b2977183241cecc95d40839d31d99eb76699 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 18 Sep 2013 17:04:03 +0200 Subject: Fix "default_*" template names treatment. (bzr r12481.1.8) --- src/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ababd4ca3..c884df2b1 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -244,7 +244,7 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) Glib::ustring file = Glib::build_filename(path, dir.read_name()); while (file != path){ - if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default")){ + if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default.")){ TemplateData tmp = _processTemplateFile(file); if (tmp.display_name != "") _tdata[tmp.display_name] = tmp; -- cgit v1.2.3 From 0fea1d0d5af42e2dadf5dd3e4df779e68b7c6dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 19 Sep 2013 17:43:38 -0300 Subject: Removing redundant "include config.h" (bzr r12545) --- src/ui/dialog/pixelartdialog.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index ef181b357..24c1ec37f 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -16,10 +16,6 @@ # include #endif -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "pixelartdialog.h" #include #include -- cgit v1.2.3 From 47f1c1ee40b8185001b047c2a7bc2ca58e40ab0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 19 Sep 2013 18:14:28 -0300 Subject: Show warning when input image of Trace Pixel Art dialog is too large. (bzr r12546) --- src/ui/dialog/pixelartdialog.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 24c1ec37f..e07cbccb5 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -19,6 +19,7 @@ #include "pixelartdialog.h" #include #include +#include #include //for GTK_RESPONSE* types #include @@ -363,6 +364,17 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) Glib::RefPtr pixbuf = Glib::wrap(img->pixbuf->getPixbufRaw(), true); + if ( pixbuf->get_width() > 256 || pixbuf->get_height() > 256 ) { + char *msg = _("Image looks too big. Process may take a while and is" + " wise to save your document before continue." + "\n\nContinue the procedure (without saving)?"); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_OK_CANCEL, true); + + if ( dialog.run() != Gtk::RESPONSE_OK ) + return; + } + if ( voronoiRadioButton.get_active() ) { out = Tracer::Kopf2011::to_voronoi(pixbuf, options()); } else { -- cgit v1.2.3 From 044c350e4c0e27e97cb39dd6dbb25e7655c302d1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 20 Sep 2013 07:38:24 +1000 Subject: updates for cmake (bzr r12547) --- src/ui/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 233e01862..24324c874 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -175,6 +175,7 @@ set(ui_SRC dialog/object-properties.h dialog/ocaldialogs.h dialog/panel-dialog.h + dialog/pixelartdialog.h dialog/print-colors-preview-dialog.h dialog/print.h @@ -183,7 +184,7 @@ set(ui_SRC dialog/swatches.h dialog/symbols.h dialog/template-load-tab.h - dialog/template-widget.h + dialog/template-widget.h dialog/text-edit.h dialog/tile.h dialog/tracedialog.h -- cgit v1.2.3 From 074dfbc9661c5d2b1d2b29b0eb3dabb632b676a4 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 20 Sep 2013 16:20:17 +0200 Subject: Small style fixes. (bzr r12481.1.10) --- src/ui/dialog/template-widget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 1e0900a07..64be57a45 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -19,14 +19,14 @@ #include #include "template-load-tab.h" -#include "file.h" -#include "extension/implementation/implementation.h" - -#include "inkscape.h" #include "desktop.h" #include "desktop-handles.h" #include "document.h" #include "document-undo.h" +#include "file.h" +#include "extension/implementation/implementation.h" +#include "inkscape.h" + namespace Inkscape { namespace UI { -- cgit v1.2.3 From 18bc66ea42cb3e7ad8d2b77ba70bd06d1b88cc7c Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 20 Sep 2013 16:48:10 +0200 Subject: Change paths storage to std::string. (bzr r12481.1.12) --- src/ui/dialog/template-load-tab.cpp | 6 +++--- src/ui/dialog/template-load-tab.h | 9 +++++---- src/ui/dialog/template-widget.cpp | 5 +++-- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index c884df2b1..127a7e4f5 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -197,7 +197,7 @@ void TemplateLoadTab::_loadTemplates() } -TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib::ustring &path) +TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::string &path) { TemplateData result; result.path = path; @@ -234,7 +234,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: } -void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) +void TemplateLoadTab::_getTemplatesFromDir(const std::string &path) { if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) @@ -242,7 +242,7 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) Glib::Dir dir(path); - Glib::ustring file = Glib::build_filename(path, dir.read_name()); + std::string file = Glib::build_filename(path, dir.read_name()); while (file != path){ if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default.")){ TemplateData tmp = _processTemplateFile(file); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index cdf8a0ade..744a2a9fb 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "xml/node.h" #include "extension/effect.h" @@ -35,7 +36,7 @@ public: struct TemplateData { bool is_procedural; - Glib::ustring path; + std::string path; Glib::ustring display_name; Glib::ustring author; Glib::ustring short_description; @@ -64,7 +65,7 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; - Glib::ustring _loading_path; + std::string _loading_path; std::map _tdata; std::set _keywords; @@ -97,9 +98,9 @@ private: void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); void _getProceduralTemplates(); - void _getTemplatesFromDir(const Glib::ustring &); + void _getTemplatesFromDir(const std::string &); void _keywordSelected(); - TemplateData _processTemplateFile(const Glib::ustring &); + TemplateData _processTemplateFile(const std::string &); }; } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 64be57a45..916d968ec 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -89,13 +89,14 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _preview_render.hide(); _preview_image.hide(); - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + std::string imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); if (data.preview_name != ""){ _preview_image.set(imagePath); _preview_image.show(); } else if (!data.is_procedural){ - _preview_render.showImage(data.path); + Glib::ustring gPath = data.path.c_str(); + _preview_render.showImage(gPath); _preview_render.show(); } -- cgit v1.2.3 From 0d4a38635fc26ed09d56b46e462b373489c8a4e2 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 21 Sep 2013 11:42:33 +0100 Subject: Fix format security errors Fixed bugs: - https://launchpad.net/bugs/1193025 (bzr r12563) --- src/ui/dialog/print.cpp | 6 +++--- src/ui/dialog/spellcheck.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index e6dae278b..03ac9dc64 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -101,7 +101,7 @@ static void draw_page( unlink (tmp_png.c_str()); } else { - g_warning(_("Could not open temporary PNG for bitmap printing")); + g_warning("%s", _("Could not open temporary PNG for bitmap printing")); } } else { @@ -144,11 +144,11 @@ static void draw_page( ret = ctx->finish(); } else { - g_warning(_("Could not set up Document")); + g_warning("%s", _("Could not set up Document")); } } else { - g_warning(_("Failed to set CairoRenderContext")); + g_warning("%s", _("Failed to set CairoRenderContext")); } // Clean up diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 9cc18c02c..45106755c 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -459,7 +459,7 @@ SpellCheck::finished () if (_stops) label = g_strdup_printf(_("Finished, %d words added to dictionary"), _adds); else - label = g_strdup_printf(_("Finished, nothing suspicious found")); + label = g_strdup_printf("%s", _("Finished, nothing suspicious found")); banner_label.set_markup(label); g_free(label); } -- cgit v1.2.3 From 9ba75e8a819b3fa9e266f6bd46ccee65322f89b0 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 21 Sep 2013 22:30:40 +0200 Subject: Fix templates parameters names. (bzr r12481.1.13) --- src/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 127a7e4f5..4517c4472 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -287,7 +287,7 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa data.display_name = dgettext("Document template name", currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) data.author = currentData->firstChild()->content(); - if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_short")) != NULL) + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_shortdesc")) != NULL) data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); -- cgit v1.2.3 From 8921f8000318d636ae8ce2a1198f92161f1dba9f Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 21 Sep 2013 23:32:09 +0200 Subject: Small style fixes. (bzr r12481.1.15) --- src/ui/dialog/template-load-tab.cpp | 8 ++++---- src/ui/dialog/template-widget.cpp | 6 +----- src/ui/dialog/template-widget.h | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 4517c4472..8e33cf503 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -18,19 +18,19 @@ #include #include #include -#include #include +#include +#include "extension/db.h" +#include "extension/effect.h" +#include "inkscape.h" #include "interface.h" #include "file.h" #include "path-prefix.h" #include "preferences.h" -#include "inkscape.h" #include "xml/repr.h" #include "xml/document.h" #include "xml/node.h" -#include "extension/db.h" -#include "extension/effect.h" namespace Inkscape { diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 916d968ec..ef022c421 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -35,19 +35,16 @@ namespace UI { TemplateWidget::TemplateWidget() : _more_info_button(_("More info")) , _short_description_label(_(" ")) - , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) , _effect_prefs(NULL) { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); - pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_box, Gtk::PACK_SHRINK, 0); _preview_box.pack_start(_preview_image, Gtk::PACK_EXPAND_PADDING, 15); _preview_box.pack_start(_preview_render, Gtk::PACK_EXPAND_PADDING, 10); _short_description_label.set_line_wrap(true); - //_short_description_label.set_size_request(200); Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); @@ -83,7 +80,6 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _current_template = data; _template_name_label.set_text(_current_template.display_name); - // _template_author_label.set_text(_current_template.author); _short_description_label.set_text(_current_template.short_description); _preview_render.hide(); @@ -105,7 +101,7 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _effect_prefs = NULL; } if (data.is_procedural){ - _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); // SP_ACTIVE_DESKTOP? + _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); pack_start(*_effect_prefs); } } diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index a41a14a38..bb35d26a0 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -17,6 +17,7 @@ #include "template-load-tab.h" + namespace Inkscape { namespace UI { @@ -36,7 +37,6 @@ private: Gtk::Image _preview_image; Dialog::SVGPreview _preview_render; Gtk::Label _short_description_label; - Gtk::Label _template_author_label; Gtk::Label _template_name_label; Gtk::Widget *_effect_prefs; -- cgit v1.2.3 From 37b7de3efa31c7aa3094aed7c849a08e7f7bedfd Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 22 Sep 2013 20:26:44 -0400 Subject: Fix percentage document size handling. Fixed bugs: - https://launchpad.net/bugs/1228852 (bzr r12577) --- src/ui/dialog/document-properties.cpp | 10 ++++++++-- src/ui/widget/page-sizer.cpp | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index ec04f6d98..37d0ce213 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1440,15 +1440,21 @@ void DocumentProperties::update() if (nv->doc_units) _rum_deflt.setUnit (nv->doc_units->abbr); - double const doc_w = sp_desktop_document(dt)->getRoot()->width.value; + double doc_w = sp_desktop_document(dt)->getRoot()->width.value; Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit).abbr; if (doc_w_unit == "") { doc_w_unit = "px"; + } else if (doc_w_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) { + doc_w_unit = "px"; + doc_w = sp_desktop_document(dt)->getRoot()->viewBox.width(); } - double const doc_h = sp_desktop_document(dt)->getRoot()->height.value; + double doc_h = sp_desktop_document(dt)->getRoot()->height.value; Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit).abbr; if (doc_h_unit == "") { doc_h_unit = "px"; + } else if (doc_h_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) { + doc_h_unit = "px"; + doc_h = sp_desktop_document(dt)->getRoot()->viewBox.height(); } _page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit)); _page_sizer.updateFitMarginsUI(nv->getRepr()); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 051937c43..2379dc181 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -474,6 +474,8 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool _changedw_connection.block(); _changedh_connection.block(); + _unit = w.unit->abbr; + if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); Inkscape::Util::Quantity const old_height = doc->getHeight(); -- cgit v1.2.3 From d61c35fdf2ffc449d916fc6ab33c20c177d22894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Mon, 23 Sep 2013 14:55:42 -0300 Subject: Disable smooth output in Inkscape PixelArtDialog (bzr r12578) --- src/ui/dialog/pixelartdialog.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index e07cbccb5..ff527434e 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -129,7 +129,9 @@ private: Gtk::RadioButton voronoiRadioButton; Gtk::RadioButton noOptimizeRadioButton; +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH Gtk::RadioButton optimizeRadioButton; +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH SPDesktop *desktop; DesktopTracker deskTrack; @@ -247,12 +249,14 @@ PixelArtDialogImpl::PixelArtDialogImpl() : outputVBox.pack_start(noOptimizeRadioButton, false, false); +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH optimizeRadioButton.set_label(_("_Smooth curves")); optimizeRadioButton.set_tooltip_text(_("The Kopf-Lischinski algorithm")); optimizeRadioButton.set_use_underline(true); optimizeRadioButton.set_group(outputGroup); outputVBox.pack_start(optimizeRadioButton, false, false); +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH outputFrame.set_label(_("Output")); outputFrame.add(outputVBox); @@ -308,7 +312,11 @@ Tracer::Kopf2011::Options PixelArtDialogImpl::options() options.islandsWeight = islandsWeightSpinner.get_value_as_int(); options.sparsePixelsMultiplier = sparsePixelsMultiplierSpinner.get_value(); options.sparsePixelsRadius = sparsePixelsRadiusSpinner.get_value_as_int(); +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH options.optimize = optimizeRadioButton.get_active(); +#else // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH + options.optimize = false; +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH options.nthreads = Inkscape::Preferences::get() ->getIntLimited("/options/threading/numthreads", @@ -450,7 +458,11 @@ void PixelArtDialogImpl::setDefaults() sparsePixelsMultiplierSpinner.set_value(Tracer::Kopf2011::Options ::SPARSE_PIXELS_MULTIPLIER); +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH optimizeRadioButton.set_active(); +#else // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH + noOptimizeRadioButton.set_active(); +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH ignorePreview = false; -- cgit v1.2.3 From 62b2cd734e684a93d1b9215aa8044c620939170d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 24 Sep 2013 00:11:51 +0200 Subject: fix crash on uninitialized unittracker for spinbuttons. fixes crash on changing major grid line number, possibly other random crashes Fixed bugs: - https://launchpad.net/bugs/1229183 (bzr r12581) --- src/ui/widget/spinbutton.cpp | 4 ++-- src/ui/widget/spinbutton.h | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 62c17f821..1114ff32b 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -65,7 +65,7 @@ int SpinButton::on_input(double* newvalue) bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) { - on_focus_in_value = get_value(); + _on_focus_in_value = get_value(); return false; // do not consume the event } @@ -92,7 +92,7 @@ bool SpinButton::on_my_key_press_event(GdkEventKey* event) void SpinButton::undo() { - set_value(on_focus_in_value); + set_value(_on_focus_in_value); } diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index c772fe2a2..812b5f515 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -38,7 +38,9 @@ class SpinButton : public Gtk::SpinButton public: SpinButton(double climb_rate = 0.0, guint digits = 0) : Gtk::SpinButton(climb_rate, digits), - _unit_menu(NULL) + _unit_menu(NULL), + _unit_tracker(NULL), + _on_focus_in_value(0.) { connect_signals(); }; @@ -48,10 +50,11 @@ public: explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) #endif : Gtk::SpinButton(adjustment, climb_rate, digits), - _unit_menu(NULL) + _unit_menu(NULL), + _unit_tracker(NULL), + _on_focus_in_value(0.) { connect_signals(); - _unit_tracker = NULL; }; virtual ~SpinButton() {}; @@ -63,6 +66,7 @@ public: protected: UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. UnitTracker *_unit_tracker; // Linked unit tracker for unit conversion in entered expressions. + double _on_focus_in_value; void connect_signals(); @@ -95,8 +99,6 @@ protected: */ void undo(); - double on_focus_in_value; - private: // noncopyable SpinButton(const SpinButton&); -- cgit v1.2.3 From eba05095970a9ee1de53703f5533efbbfbf91715 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 24 Sep 2013 11:31:44 -0700 Subject: Fix my email address through codebase (bzr r12588) --- src/ui/dialog/layer-properties.cpp | 2 +- src/ui/dialog/layer-properties.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 3feed2afe..b9e5d4883 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -3,7 +3,7 @@ * Dialog for renaming layers. */ /* Author: - * Bryce W. Harrington + * Bryce W. Harrington * Andrius R. * Abhishek Sharma * diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index d38b8edf5..d114c6ba5 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -2,7 +2,7 @@ * @brief Dialog for renaming layers */ /* Author: - * Bryce W. Harrington + * Bryce W. Harrington * * Copyright (C) 2004 Bryce Harrington * -- cgit v1.2.3