summaryrefslogtreecommitdiffstats
path: root/src/ui/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/tools')
-rw-r--r--src/ui/tools/box3d-tool.cpp2
-rw-r--r--src/ui/tools/connector-tool.cpp8
-rw-r--r--src/ui/tools/eraser-tool.cpp33
-rw-r--r--src/ui/tools/flood-tool.cpp2
-rw-r--r--src/ui/tools/gradient-tool.cpp37
-rw-r--r--src/ui/tools/lpe-tool.cpp8
-rw-r--r--src/ui/tools/measure-tool.cpp6
-rw-r--r--src/ui/tools/mesh-tool.cpp27
-rw-r--r--src/ui/tools/node-tool.cpp10
-rw-r--r--src/ui/tools/pen-tool.cpp15
-rw-r--r--src/ui/tools/pencil-tool.cpp3
-rw-r--r--src/ui/tools/rect-tool.cpp1
-rw-r--r--src/ui/tools/select-tool.cpp6
-rw-r--r--src/ui/tools/spray-tool.cpp32
-rw-r--r--src/ui/tools/text-tool.cpp7
-rw-r--r--src/ui/tools/tool-base.cpp10
-rw-r--r--src/ui/tools/tweak-tool.cpp25
17 files changed, 96 insertions, 136 deletions
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 538e0c7e2..27e755add 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -165,7 +165,7 @@ bool Box3dTool::item_handler(SPItem* item, GdkEvent* event) {
case GDK_BUTTON_PRESS:
if ( event->button.button == 1 && !this->space_panning) {
Inkscape::setup_for_drag_start(desktop, this, event);
- ret = TRUE;
+ //ret = TRUE;
}
break;
// motion and release are always on root (why?)
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index c3ef19507..0a36877ff 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -1303,12 +1303,12 @@ void cc_selection_set_avoid(bool const set_avoid)
Inkscape::Selection *selection = desktop->getSelection();
- GSList *l = const_cast<GSList *>(selection->itemList());
int changes = 0;
- while (l) {
- SPItem *item = SP_ITEM(l->data);
+ std::vector<SPItem*> l = selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end();i++) {
+ SPItem *item = *i;
char const *value = (set_avoid) ? "true" : NULL;
@@ -1317,8 +1317,6 @@ void cc_selection_set_avoid(bool const set_avoid)
item->avoidRef->handleSettingChange();
changes++;
}
-
- l = l->next;
}
if (changes == 0) {
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index af0cbcb78..10f8c8694 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -666,8 +666,7 @@ void EraserTool::set_to_accumulated() {
Geom::OptRect eraserBbox = acid->visualBounds();
Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt();
std::vector<SPItem*> remainingItems;
- GSList* toWorkOn = 0;
-
+ std::vector<SPItem*> toWorkOn;
if (selection->isEmpty()) {
if ( eraserMode ) {
toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds);
@@ -675,17 +674,16 @@ void EraserTool::set_to_accumulated() {
Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
}
-
- toWorkOn = g_slist_remove( toWorkOn, acid );
+ toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end());
} else {
- toWorkOn = g_slist_copy(const_cast<GSList*>(selection->itemList()));
+ toWorkOn= selection->itemList();
wasSelection = true;
}
- if ( g_slist_length(toWorkOn) > 0 ) {
+ if ( !toWorkOn.empty() ) {
if ( eraserMode ) {
- for (GSList *i = toWorkOn ; i ; i = i->next ) {
- SPItem *item = SP_ITEM(i->data);
+ for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); i++){
+ SPItem *item = *i;
if ( eraserMode ) {
Geom::OptRect bbox = item->visualBounds();
@@ -702,13 +700,10 @@ void EraserTool::set_to_accumulated() {
if ( !selection->isEmpty() ) {
// If the item was not completely erased, track the new remainder.
- GSList *nowSel = g_slist_copy(const_cast<GSList *>(selection->itemList()));
-
- for (GSList const *i2 = nowSel ; i2 ; i2 = i2->next ) {
- remainingItems.push_back(SP_ITEM(i2->data));
+ std::vector<SPItem*> nowSel(selection->itemList());
+ for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) {
+ remainingItems.push_back(*i2);
}
-
- g_slist_free(nowSel);
}
} else {
remainingItems.push_back(item);
@@ -716,20 +711,18 @@ void EraserTool::set_to_accumulated() {
}
}
} else {
- for (GSList *i = toWorkOn ; i ; i = i->next ) {
- sp_object_ref( SP_ITEM(i->data), 0 );
+ for (std::vector<SPItem*> ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) {
+ sp_object_ref( *i, 0 );
}
- for (GSList *i = toWorkOn ; i ; i = i->next ) {
- SPItem *item = SP_ITEM(i->data);
+ for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) {
+ SPItem *item = *i;
item->deleteObject(true);
sp_object_unref(item);
workDone = true;
}
}
- g_slist_free(toWorkOn);
-
if ( !eraserMode ) {
//sp_selection_delete(desktop);
remainingItems.clear();
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index ffd41d97d..748c82717 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -932,7 +932,7 @@ static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, boo
std::deque<Geom::Point>::iterator start_sort = fill_queue.begin();
std::deque<Geom::Point>::iterator end_sort = fill_queue.begin();
unsigned int sort_y = (unsigned int)cp[Geom::Y];
- unsigned int current_y = sort_y;
+ unsigned int current_y;
for (std::deque<Geom::Point>::iterator i = fill_queue.begin(); i != fill_queue.end(); ++i) {
Geom::Point current = *i;
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 61baa7d66..603458983 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -106,7 +106,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) {
if (selection == NULL) {
return;
}
- guint n_obj = g_slist_length((GSList *) selection->itemList());
+ guint n_obj = selection->itemList().size();
if (!drag->isNonEmpty() || selection->isEmpty())
return;
@@ -492,10 +492,11 @@ bool GradientTool::root_handler(GdkEvent* event) {
if (over_line) {
// we take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList()->data), this->mousepoint_doc, event->button.time);
+ sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time);
} else {
- for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
- SPItem *item = SP_ITEM(i->data);
+ std::vector<SPItem*> items=selection->itemList();
+ for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) {
+ SPItem *item = *i;
SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -898,32 +899,32 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- GSList *items = g_slist_copy ((GSList *) selection->itemList());
- items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position);
+ std::vector<SPItem*> items(selection->itemList());
+ sort(items.begin(),items.end(),sp_item_repr_compare_position);
// take topmost
- vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke);
- g_slist_free (items);
+ vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
}
// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
+ std::vector<SPItem*> itemlist = selection->itemList();
+ for (std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end();i++) {
//FIXME: see above
- sp_repr_css_change_recursive(SP_OBJECT(i->data)->getRepr(), css, "style");
+ sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
- sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke);
+ sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke);
if (type == SP_GRADIENT_TYPE_LINEAR) {
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false);
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_END, 0, pt, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (*i, POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (*i, POINT_LG_END, 0, pt, fill_or_stroke, true, false);
} else if (type == SP_GRADIENT_TYPE_RADIAL) {
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false);
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_R1, 0, pt, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (*i, POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (*i, POINT_RG_R1, 0, pt, fill_or_stroke, true, false);
}
- SP_OBJECT(i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
if (ec->_grdrag) {
ec->_grdrag->updateDraggers();
@@ -932,7 +933,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
ec->_grdrag->local_change = true;
// give the grab out-of-bounds values of xp/yp because we're already dragging
// and therefore are already out of tolerance
- ec->_grdrag->grabKnot (SP_ITEM(selection->itemList()->data),
+ ec->_grdrag->grabKnot (selection->itemList()[0],
type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1,
-1, // ignore number (though it is always 1)
fill_or_stroke, 99999, 99999, etime);
@@ -941,7 +942,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = g_slist_length((GSList *) selection->itemList());
+ int n_objects = selection->itemList().size();
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index c0517578d..13e47f3a6 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -396,10 +396,10 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection)
SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup();
gchar *arc_length;
double lengthval;
-
- for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
- if (SP_IS_PATH(i->data)) {
- path = SP_PATH(i->data);
+ std::vector<SPItem*> items=selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ if (SP_IS_PATH(*i)) {
+ path = SP_PATH(*i);
curve = path->getCurve();
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = paths_to_pw(curve->get_pathvector());
canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), "");
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 0875c29e0..570f3e796 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -431,10 +431,10 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// TODO switch to a different variable name. The single letter 'l' is easy to misread.
//select elements crossed by line segment:
- GSList *items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points);
+ std::vector<SPItem*> items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points);
std::vector<double> intersection_times;
- for (GSList *l = items; l != NULL; l = l->next) {
- SPItem *item = static_cast<SPItem*>(l->data);
+ for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) {
+ SPItem *item = *i;
if (SP_IS_SHAPE(item)) {
calculate_intersections(desktop, item, lineseg, SP_SHAPE(item)->getCurve(), intersection_times);
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index 86d816e85..813d6ae5b 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -103,7 +103,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
return;
}
- guint n_obj = g_slist_length((GSList *) selection->itemList());
+ guint n_obj = selection->itemList().size();
if (!drag->isNonEmpty() || selection->isEmpty()) {
return;
@@ -467,11 +467,12 @@ bool MeshTool::root_handler(GdkEvent* event) {
if (over_line) {
// We take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList()->data), this->mousepoint_doc, event->button.time);
+ sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time);
} else {
// Create a new gradient with default coordinates.
- for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
- SPItem *item = SP_ITEM(i->data);
+ std::vector<SPItem*> items=selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPItem *item = *i;
SPGradientType new_type = SP_GRADIENT_TYPE_MESH;
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -940,27 +941,27 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- GSList *items = g_slist_copy ((GSList *) selection->itemList());
- items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position);
+ std::vector<SPItem*> items(selection->itemList());
+ sort(items.begin(),items.end(),sp_item_repr_compare_position);
// take topmost
- vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke);
- g_slist_free (items);
+ vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
}
// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
+ std::vector<SPItem*> items=selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
//FIXME: see above
- sp_repr_css_change_recursive(SP_OBJECT(i->data)->getRepr(), css, "style");
+ sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
- sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke);
+ sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke);
// We don't need to do anything. Mesh is already sized appropriately.
- SP_OBJECT(i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
// if (ec->_grdrag) {
// ec->_grdrag->updateDraggers();
@@ -978,7 +979,7 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = g_slist_length((GSList *) selection->itemList());
+ int n_objects = selection->itemList().size();
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index a4b903960..ef00eaa40 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -410,10 +410,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
std::set<ShapeRecord> shapes;
- GSList const *ilist = sel->itemList();
-
- for (GSList *i = const_cast<GSList*>(ilist); i; i = i->next) {
- SPObject *obj = static_cast<SPObject*>(i->data);
+ std::vector<SPItem*> items=sel->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPObject *obj = *i;
if (SP_IS_ITEM(obj)) {
gather_items(this, NULL, static_cast<SPItem*>(obj), SHAPE_ROLE_NORMAL, shapes);
@@ -658,9 +657,8 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) {
if (this->_multipath->empty()) {
// if multipath is empty, select rubberbanded items rather than nodes
Inkscape::Selection *selection = this->desktop->selection;
- GSList *items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel);
+ std::vector<SPItem*> items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel);
selection->setList(items);
- g_slist_free(items);
} else {
if (!held_shift(*event)) {
this->_selected_nodes->clear();
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 3eb838089..38892517d 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -761,14 +761,12 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) {
}
}
this->state = PenTool::CONTROL;
- ret = true;
break;
case PenTool::CONTROL:
// End current segment
this->_endpointSnap(p, revent.state);
this->_finishSegment(p, revent.state);
this->state = PenTool::POINT;
- ret = true;
break;
case PenTool::CLOSE:
// End current segment
@@ -782,12 +780,10 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) {
}
this->_finish(true);
this->state = PenTool::POINT;
- ret = true;
break;
case PenTool::STOP:
// This is allowed, if we just canceled curve
this->state = PenTool::POINT;
- ret = true;
break;
default:
break;
@@ -822,7 +818,6 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) {
break;
}
this->state = PenTool::POINT;
- ret = true;
break;
default:
break;
@@ -1431,8 +1426,7 @@ void PenTool::_bsplineSpiroStartAnchorOn()
{
using Geom::X;
using Geom::Y;
- SPCurve *tmp_curve = new SPCurve();
- tmp_curve = this->sa->curve->copy();
+ SPCurve *tmp_curve = this->sa->curve->copy();
if(this->sa->start)
tmp_curve = tmp_curve ->create_reverse();
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
@@ -1464,8 +1458,7 @@ void PenTool::_bsplineSpiroStartAnchorOn()
void PenTool::_bsplineSpiroStartAnchorOff()
{
- SPCurve *tmp_curve = new SPCurve();
- tmp_curve = this->sa->curve->copy();
+ SPCurve *tmp_curve = this->sa->curve->copy();
if(this->sa->start)
tmp_curve = tmp_curve ->create_reverse();
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
@@ -1563,7 +1556,7 @@ void PenTool::_bsplineSpiroEndAnchorOn()
using Geom::Y;
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
- SPCurve *tmp_curve = new SPCurve();
+ SPCurve *tmp_curve;
SPCurve *last_segment = new SPCurve();
Geom::Point point_c(0,0);
bool reverse = false;
@@ -1620,7 +1613,7 @@ void PenTool::_bsplineSpiroEndAnchorOn()
void PenTool::_bsplineSpiroEndAnchorOff()
{
- SPCurve *tmp_curve = new SPCurve();
+ SPCurve *tmp_curve;
SPCurve *last_segment = new SPCurve();
bool reverse = false;
this->p[2] = this->p[3];
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index 008804162..ba103fa8e 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -357,7 +357,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) {
// Ctrl+click creates a single point so only set context in ADDLINE mode when Ctrl isn't pressed
this->state = SP_PENCIL_CONTEXT_ADDLINE;
}
- ret = true;
break;
case SP_PENCIL_CONTEXT_ADDLINE:
/* Finish segment now */
@@ -371,7 +370,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) {
this->_finishEndpoint();
this->state = SP_PENCIL_CONTEXT_IDLE;
sp_event_context_discard_delayed_snap_event(this);
- ret = true;
break;
case SP_PENCIL_CONTEXT_FREEHAND:
if (revent.state & GDK_MOD1_MASK) {
@@ -413,7 +411,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) {
// reset sketch mode too
this->sketch_n = 0;
}
- ret = true;
break;
case SP_PENCIL_CONTEXT_SKETCH:
default:
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 62a9006ea..844965c4d 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -143,7 +143,6 @@ bool RectTool::item_handler(SPItem* item, GdkEvent* event) {
case GDK_BUTTON_PRESS:
if ( event->button.button == 1 && !this->space_panning) {
Inkscape::setup_for_drag_start(desktop, this, event);
- ret = TRUE;
}
break;
// motion and release are always on root (why?)
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index 40b994968..f06b03d91 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -472,7 +472,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_2BUTTON_PRESS:
if (event->button.button == 1) {
if (!selection->isEmpty()) {
- SPItem *clicked_item = static_cast<SPItem *>(selection->itemList()->data);
+ SPItem *clicked_item = selection->itemList()[0];
if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box
desktop->setCurrentLayer(clicked_item);
@@ -709,7 +709,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (r->is_started() && !within_tolerance) {
// this was a rubberband drag
- GSList *items = NULL;
+ std::vector<SPItem*> items;
if (r->getMode() == RUBBERBAND_MODE_RECT) {
Geom::OptRect const b = r->getRectangle();
@@ -730,7 +730,6 @@ bool SelectTool::root_handler(GdkEvent* event) {
selection->setList (items);
}
- g_slist_free (items);
} else { // it was just a click, or a too small rubberband
r->stop();
@@ -778,7 +777,6 @@ bool SelectTool::root_handler(GdkEvent* event) {
}
rb_escaped = 0;
- ret = TRUE;
}
}
}
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 0399b1e55..26d74733a 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -178,7 +178,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList()));
+ num = desktop->selection->itemList().size();
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -426,11 +426,9 @@ static bool sp_spray_recursive(SPDesktop *desktop,
SPItem *unionResult = NULL; // Previous union
int i=1;
- for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));
- items != NULL;
- items = items->next) {
-
- SPItem *item1 = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ std::vector<SPItem*> items=selection->itemList();
+ for(std::vector<SPItem*>::const_iterator it=items.begin();it!=items.end();it++){
+ SPItem *item1 = *it;
if (i == 1) {
parent_item = item1;
}
@@ -544,20 +542,16 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
double move_standard_deviation = get_move_standard_deviation(tc);
{
- GSList *const original_selection = g_slist_copy(const_cast<GSList *>(selection->itemList()));
+ std::vector<SPItem*> const items(selection->itemList());
- for (GSList *items = original_selection;
- items != NULL;
- items = items->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPItem *item = *i;
g_assert(item != NULL);
sp_object_ref(item);
}
- for (GSList *items = original_selection;
- items != NULL;
- items = items->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPItem *item = *i;
g_assert(item != NULL);
if (is_transform_modes(tc->mode)) {
@@ -571,10 +565,8 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
}
}
- for (GSList *items = original_selection;
- items != NULL;
- items = items->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPItem *item = *i;
g_assert(item != NULL);
sp_object_unref(item);
}
@@ -650,7 +642,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList()));
+ num = desktop->selection->itemList().size();
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray."));
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index a2c0c81ae..1888551cf 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -1461,7 +1461,7 @@ int TextTool::_styleQueried(SPStyle *style, int property)
}
sp_text_context_validate_cursor_iterators(this);
- GSList *styles_list = NULL;
+ std::vector<SPItem*> styles_list;
Inkscape::Text::Layout::iterator begin_it, end_it;
if (this->text_sel_start < this->text_sel_end) {
@@ -1477,7 +1477,7 @@ int TextTool::_styleQueried(SPStyle *style, int property)
}
}
for (Inkscape::Text::Layout::iterator it = begin_it ; it < end_it ; it.nextStartOfSpan()) {
- SPObject const *pos_obj = 0;
+ SPObject *pos_obj = 0;
void *rawptr = 0;
layout->getSourceOfCharacter(it, &rawptr);
if (!rawptr || !SP_IS_OBJECT(rawptr)) {
@@ -1487,12 +1487,11 @@ int TextTool::_styleQueried(SPStyle *style, int property)
while (SP_IS_STRING(pos_obj) && pos_obj->parent) {
pos_obj = pos_obj->parent; // SPStrings don't have style
}
- styles_list = g_slist_prepend(styles_list, (gpointer)pos_obj);
+ styles_list.insert(styles_list.begin(),(SPItem*)pos_obj);
}
int result = sp_desktop_query_style_from_list (styles_list, style, property);
- g_slist_free(styles_list);
return result;
}
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index a07f2fb86..0f9b3ee7a 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -20,10 +20,6 @@
#include "widgets/desktop-widget.h"
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include "shortcuts.h"
#include "file.h"
#include "ui/tools/tool-base.h"
@@ -1178,11 +1174,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p,
SPItem *
sp_event_context_over_item(SPDesktop *desktop, SPItem *item,
Geom::Point const &p) {
- GSList *temp = NULL;
- temp = g_slist_prepend(temp, item);
+ std::vector<SPItem*> temp;
+ temp.push_back(item);
SPItem *item_at_point = desktop->getItemFromListAtPointBottom(temp, p);
- g_slist_free(temp);
-
return item_at_point;
}
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 80b52fba6..76b52f9be 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -153,7 +153,7 @@ void TweakTool::update_cursor (bool with_shift) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList()));
+ num = desktop->selection->itemList().size();
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -372,14 +372,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
}
if (dynamic_cast<SPText *>(item) || dynamic_cast<SPFlowtext *>(item)) {
- GSList *items = g_slist_prepend (NULL, item);
- GSList *selected = NULL;
- GSList *to_select = NULL;
+ std::vector<SPItem*> items;
+ items.push_back(item);
+ std::vector<SPItem*> selected;
+ std::vector<Inkscape::XML::Node*> to_select;
SPDocument *doc = item->document;
- sp_item_list_to_curves (items, &selected, &to_select);
- g_slist_free (items);
- SPObject* newObj = doc->getObjectByRepr(static_cast<Inkscape::XML::Node *>(to_select->data));
- g_slist_free (to_select);
+ sp_item_list_to_curves (items, selected, to_select);
+ SPObject* newObj = doc->getObjectByRepr(to_select[0]);
item = dynamic_cast<SPItem *>(newObj);
g_assert(item != NULL);
selection->add(item);
@@ -1078,11 +1077,9 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point
double move_force = get_move_force(tc);
double color_force = MIN(sqrt(path_force)/20.0, 1);
- for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));
- items != NULL;
- items = items->next) {
-
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ std::vector<SPItem*> items=selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPItem *item = *i;
if (is_color_mode (tc->mode)) {
if (do_fill || do_stroke || do_opacity) {
@@ -1189,7 +1186,7 @@ bool TweakTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList()));
+ num = desktop->selection->itemList().size();
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak."));