summaryrefslogtreecommitdiffstats
path: root/src/widgets/stroke-style.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2015-04-29 21:14:01 +0000
committerMarc Jeanmougin <mc@M0nst3r.bouyguesbox.fr>2015-04-29 21:14:01 +0000
commit9b7af8caac08ad42a48214518bc004e258eb5873 (patch)
treedcaaac56217eb5da334ab420f5e791cf7eb70f23 /src/widgets/stroke-style.cpp
parentBetter solution picking (diff)
parentcorrected test file (diff)
downloadinkscape-9b7af8caac08ad42a48214518bc004e258eb5873.tar.gz
inkscape-9b7af8caac08ad42a48214518bc004e258eb5873.zip
bzr merge lp:~mc.../inkscape/SelContainer
The main change of this branch is that the container for selections is now a std::vector and not a GSList. This change propagates in most of the codebase. Normally, there are no changes of semantics, except the following: -> childList is now in the intuitive order (childList()[0] is now firstChild) -> sp_selection_paste_impl is now in the opposite order (change is local to selection-chemistry.cpp, and simplify a few things there) -> selection.setReprList now takes the list in the opposite order. It was always the case (the list was always reversed before handing to it) -> a few comparison functions now work "the c++ way": the C way was to return -1 if a<b, 0 if a==b and 1 if a>b, now they return (bool)(a<b) so they can be used with std::sort (bzr r14074)
Diffstat (limited to 'src/widgets/stroke-style.cpp')
-rw-r--r--src/widgets/stroke-style.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 5ca06a795..482ca7af4 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<SPItem *>(items->data);
+ std::vector<SPItem*> itemlist=selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();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 <path>
continue;
}
@@ -901,8 +901,8 @@ StrokeStyle::updateLine()
if (!sel || sel->isEmpty())
return;
- GSList const *objects = sel->itemList();
- SPObject * const object = SP_OBJECT(objects->data);
+ std::vector<SPItem*> const objects = sel->itemList();
+ SPObject * const object = objects[0];
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();
+ std::vector<SPItem*> 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(std::vector<SPItem*>::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 = (*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 ((*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(std::vector<SPItem*> const &objects)
{
struct { MarkerComboBox *key; int loc; } const keyloc[] = {
{ startMarkerCombo, SP_MARKER_LOC_START },
@@ -1153,9 +1152,10 @@ 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(std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++){
+ if (!SP_IS_TEXT (*i)) {
all_texts = false;
+ break;
}
}
@@ -1167,7 +1167,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 = objects[0];
for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) {
// For all three marker types,