From a7f2b2ba3f13ceb60376802f4a31e104153839e8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 17 Feb 2015 03:00:37 +0100 Subject: At first, I was thinking "I just have to go to the selection file, and change that GSList* with a std::list, then resolve the few problems" So, i tried that. And I will continue tomorrow, and the days after, on and on. (bzr r13922.1.1) --- src/widgets/stroke-style.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/widgets/stroke-style.cpp') diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 5ca06a795..2599fe537 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -475,9 +475,9 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using continue; } @@ -901,8 +901,8 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - GSList const *objects = sel->itemList(); - SPObject * const object = SP_OBJECT(objects->data); + SelContainer const objects = sel->itemList(); + SPObject * const object = SP_OBJECT(objects.front()); SPStyle * const style = object->style; /* Markers */ @@ -957,13 +957,12 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - - GSList const *items = selection->itemList(); + SelContainer items=selection->itemList(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); - if (items) { + if (!items.empty()) { #if WITH_GTKMM_3_0 double width_typed = (*widthAdj)->get_value(); double const miterlimit = (*miterLimitAdj)->get_value(); @@ -978,13 +977,13 @@ StrokeStyle::scaleLine() int ndash; dashSelector->get_dash(&ndash, &dash, &offset); - for (GSList const *i = items; i != NULL; i = i->next) { + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ /* Set stroke width */ double width; if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { width = Inkscape::Util::Quantity::convert(width_typed, unit, "px"); } else { // percentage - gdouble old_w = SP_OBJECT(i->data)->style->stroke_width.computed; + gdouble old_w = SP_OBJECT(*i)->style->stroke_width.computed; width = old_w * width_typed / 100; } @@ -1003,7 +1002,7 @@ StrokeStyle::scaleLine() /* Set dash */ setScaledDash(css, ndash, dash, offset, width); - sp_desktop_apply_css_recursive (SP_OBJECT(i->data), css, true); + sp_desktop_apply_css_recursive (SP_OBJECT(*i), css, true); } g_free(dash); @@ -1144,7 +1143,7 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active) * that marker. */ void -StrokeStyle::updateAllMarkers(GSList const *objects) +StrokeStyle::updateAllMarkers(SelContainer const &objects) { struct { MarkerComboBox *key; int loc; } const keyloc[] = { { startMarkerCombo, SP_MARKER_LOC_START }, @@ -1153,8 +1152,8 @@ StrokeStyle::updateAllMarkers(GSList const *objects) }; bool all_texts = true; - for (GSList *i = (GSList *) objects; i != NULL; i = i->next) { - if (!SP_IS_TEXT (i->data)) { + for(SelContainer::const_iterator i=objects.begin();i!=objects.end();i++){ + if (!SP_IS_TEXT (*i)) { all_texts = false; } } @@ -1167,7 +1166,7 @@ StrokeStyle::updateAllMarkers(GSList const *objects) // We show markers of the first object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = SP_OBJECT(objects->data); + SPObject *object = SP_OBJECT(objects.front()); for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { // For all three marker types, -- cgit v1.2.3 From 5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 04:25:21 +0100 Subject: Put a few std::vector (bzr r13922.1.5) --- src/widgets/stroke-style.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/widgets/stroke-style.cpp') diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 2599fe537..65390819b 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -475,8 +475,8 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using continue; @@ -901,7 +901,7 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - SelContainer const objects = sel->itemList(); + std::vector const objects = sel->itemList(); SPObject * const object = SP_OBJECT(objects.front()); SPStyle * const style = object->style; @@ -957,7 +957,7 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items=selection->itemList(); + std::vector items=selection->itemList(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); @@ -977,7 +977,7 @@ StrokeStyle::scaleLine() int ndash; dashSelector->get_dash(&ndash, &dash, &offset); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ /* Set stroke width */ double width; if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { @@ -1143,7 +1143,7 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active) * that marker. */ void -StrokeStyle::updateAllMarkers(SelContainer const &objects) +StrokeStyle::updateAllMarkers(std::vector const &objects) { struct { MarkerComboBox *key; int loc; } const keyloc[] = { { startMarkerCombo, SP_MARKER_LOC_START }, @@ -1152,7 +1152,7 @@ StrokeStyle::updateAllMarkers(SelContainer const &objects) }; bool all_texts = true; - for(SelContainer::const_iterator i=objects.begin();i!=objects.end();i++){ + for(std::vector::const_iterator i=objects.begin();i!=objects.end();i++){ if (!SP_IS_TEXT (*i)) { all_texts = false; } -- cgit v1.2.3 From 9a7fa4d1899d30ec745107823f307b2a0bf3172f Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 03:10:36 +0100 Subject: corrected the casts (hopefully) (bzr r13922.1.10) --- src/widgets/stroke-style.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/widgets/stroke-style.cpp') diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 65390819b..c05ef93e7 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -477,7 +477,7 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, Inkscape::Selection *selection = spw->desktop->getSelection(); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using continue; } @@ -902,7 +902,7 @@ StrokeStyle::updateLine() return; std::vector const objects = sel->itemList(); - SPObject * const object = SP_OBJECT(objects.front()); + SPObject * const object = SP_OBJECT(objects[0]); SPStyle * const style = object->style; /* Markers */ @@ -1155,6 +1155,7 @@ StrokeStyle::updateAllMarkers(std::vector const &objects) for(std::vector::const_iterator i=objects.begin();i!=objects.end();i++){ if (!SP_IS_TEXT (*i)) { all_texts = false; + break; } } @@ -1166,7 +1167,7 @@ StrokeStyle::updateAllMarkers(std::vector const &objects) // We show markers of the first object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = SP_OBJECT(objects.front()); + SPObject *object = SP_OBJECT(objects[0]); for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { // For all three marker types, -- cgit v1.2.3 From 9bdc157f705ca61516e599cb416580283d21ec35 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 04:21:48 +0100 Subject: more cast cleanup (bzr r13922.1.11) --- src/widgets/stroke-style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/stroke-style.cpp') diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index c05ef93e7..481fa0609 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -983,7 +983,7 @@ StrokeStyle::scaleLine() if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { width = Inkscape::Util::Quantity::convert(width_typed, unit, "px"); } else { // percentage - gdouble old_w = SP_OBJECT(*i)->style->stroke_width.computed; + gdouble old_w = (*i)->style->stroke_width.computed; width = old_w * width_typed / 100; } @@ -1167,7 +1167,7 @@ StrokeStyle::updateAllMarkers(std::vector const &objects) // We show markers of the first object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = SP_OBJECT(objects[0]); + SPObject *object = objects[0]; for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { // For all three marker types, -- cgit v1.2.3 From 643c75ddbbbea2f018050faa1e7e38c71482418a Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 28 Apr 2015 01:20:57 +0200 Subject: removed a few useless SP_OBJECT() casts (bzr r13922.1.17) --- src/widgets/stroke-style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/stroke-style.cpp') diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 481fa0609..482ca7af4 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -902,7 +902,7 @@ StrokeStyle::updateLine() return; std::vector const objects = sel->itemList(); - SPObject * const object = SP_OBJECT(objects[0]); + SPObject * const object = objects[0]; SPStyle * const style = object->style; /* Markers */ @@ -1002,7 +1002,7 @@ StrokeStyle::scaleLine() /* Set dash */ setScaledDash(css, ndash, dash, offset, width); - sp_desktop_apply_css_recursive (SP_OBJECT(*i), css, true); + sp_desktop_apply_css_recursive ((*i), css, true); } g_free(dash); -- cgit v1.2.3