summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorMarc Jeanmougin <mc@localhost.localdomain>2015-02-17 02:00:37 +0000
committerMarc Jeanmougin <mc@localhost.localdomain>2015-02-17 02:00:37 +0000
commita7f2b2ba3f13ceb60376802f4a31e104153839e8 (patch)
tree6db393e9e5a0a9ab7916a0e7ed29d875efa39ea1 /src/ui
parentdevice-manager: Get rid of GLists (diff)
downloadinkscape-a7f2b2ba3f13ceb60376802f4a31e104153839e8.tar.gz
inkscape-a7f2b2ba3f13ceb60376802f4a31e104153839e8.zip
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)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/clipboard.cpp33
-rw-r--r--src/ui/dialog/align-and-distribute.cpp87
-rw-r--r--src/ui/dialog/clonetiler.cpp14
-rw-r--r--src/ui/dialog/export.cpp28
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp27
-rw-r--r--src/ui/dialog/find.cpp92
-rw-r--r--src/ui/dialog/find.h11
-rw-r--r--src/ui/dialog/glyphs.cpp12
-rw-r--r--src/ui/interface.cpp17
9 files changed, 162 insertions, 159 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 94a1eb2dc..20b43af3b 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -523,8 +523,9 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
// resize each object in the selection
if (separately) {
- for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ SelContainer itemlist=selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ SPItem *item = SP_ITEM(*i);
if (item) {
Geom::OptRect obj_size = item->desktopVisualBounds();
if ( obj_size ) {
@@ -578,8 +579,9 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
desktop->doc()->importDefs(tempdoc);
// make sure all selected items are converted to paths first (i.e. rectangles)
sp_selected_to_lpeitems(desktop);
- for (GSList *itemptr = const_cast<GSList *>(selection->itemList()) ; itemptr ; itemptr = itemptr->next) {
- SPItem *item = reinterpret_cast<SPItem*>(itemptr->data);
+ SelContainer itemlist=selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ SPItem *item = SP_ITEM(*i);
_applyPathEffect(item, effectstack);
}
@@ -659,10 +661,10 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
*/
void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
{
- GSList const *items = selection->itemList();
// copy the defs used by all items
- for (GSList *i = const_cast<GSList *>(items) ; i != NULL ; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ SelContainer itemlist=selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ SPItem *item = SP_ITEM(*i);
if (item) {
_copyUsedDefs(item);
} else {
@@ -671,11 +673,11 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
}
// copy the representation of the items
- GSList *sorted_items = g_slist_copy(const_cast<GSList *>(items));
- sorted_items = g_slist_sort(sorted_items, (GCompareFunc) sp_object_compare_position);
+ SelContainer sorted_items(itemlist);
+ sorted_items.sort(sp_object_compare_position);
- for (GSList *i = sorted_items ; i ; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ for(SelContainer::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){
+ SPItem *item = SP_ITEM(*i);
if (item) {
Inkscape::XML::Node *obj = item->getRepr();
Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root);
@@ -695,8 +697,8 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
}
// copy style for Paste Style action
- if (sorted_items) {
- SPObject *object = static_cast<SPObject *>(sorted_items->data);
+ if (!sorted_items.empty()) {
+ SPObject *object = static_cast<SPObject *>(sorted_items.front());
SPItem *item = dynamic_cast<SPItem *>(object);
if (item) {
SPCSSAttr *style = take_style_from_item(item);
@@ -719,7 +721,6 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
sp_repr_set_point(_clipnode, "max", size->max());
}
- g_slist_free(sorted_items);
}
@@ -1156,8 +1157,8 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/)
sp_repr_get_double(nv, "inkscape:pageopacity", &opacity);
bgcolor |= SP_COLOR_F_TO_U(opacity);
}
-
- sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, NULL);
+ SelContainer x;
+ sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, x);
}
else
{
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 65bc94011..562bc28b7 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -98,8 +98,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups");
using Inkscape::Util::GSListConstIterator;
- std::list<SPItem *> selected;
- selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL);
+ SelContainer selected(selection->itemList());
if (selected.empty()) return;
const Coeffs &a = _allCoeffs[index];
@@ -149,18 +148,19 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
b = selection->preferredBounds();
//Move each item in the selected list separately
- for (std::list<SPItem *>::iterator it(selected.begin());
+ for (SelContainer::iterator it(selected.begin());
it != selected.end(); ++it)
{
+ SPItem* item=static_cast<SPItem*> (*it);
desktop->getDocument()->ensureUpToDate();
if (!sel_as_group)
- b = (*it)->desktopPreferredBounds();
- if (b && (!focus || (*it) != focus)) {
+ b = (item)->desktopPreferredBounds();
+ if (b && (!focus || (item) != focus)) {
Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X],
a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]);
Geom::Point const mp_rel( mp - sp );
if (LInfty(mp_rel) > 1e-9) {
- sp_item_move_rel(*it, Geom::Translate(mp_rel));
+ sp_item_move_rel(item, Geom::Translate(mp_rel));
changed = true;
}
}
@@ -251,25 +251,24 @@ private :
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
- std::list<SPItem *> selected;
- selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL);
+ SelContainer selected(selection->itemList());
if (selected.empty()) return;
//Check 2 or more selected objects
- std::list<SPItem *>::iterator second(selected.begin());
+ SelContainer::iterator second(selected.begin());
++second;
if (second == selected.end()) return;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int prefs_bbox = prefs->getBool("/tools/bounding_box");
std::vector< BBoxSort > sorted;
- for (std::list<SPItem *>::iterator it(selected.begin());
+ for (SelContainer::iterator it(selected.begin());
it != selected.end();
++it)
- {
- Geom::OptRect bbox = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds();
+ {SPItem *item=static_cast<SPItem*>(*it);
+ Geom::OptRect bbox = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds();
if (bbox) {
- sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd));
+ sorted.push_back(BBoxSort(item, *bbox, _orientation, _kBegin, _kEnd));
}
}
//sort bbox by anchors
@@ -541,6 +540,10 @@ private :
return (a->isSiblingOf(b));
}
+ static bool local_obj_compare(SPObject* a,SPObject* b){
+ return ActionExchangePositions::sort_compare(static_cast<SPItem*>(a),static_cast<SPItem*>(b));
+ }
+
virtual void on_button_click()
{
SPDesktop *desktop = _dialog.getDesktop();
@@ -550,8 +553,7 @@ private :
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
- std::list<SPItem *> selected;
- selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL);
+ SelContainer selected(selection->itemList());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -569,20 +571,22 @@ private :
} else { // sorting by ZOrder is outomatically done by not setting the center
center.reset();
}
- selected.sort(ActionExchangePositions::sort_compare);
+ selected.sort(local_obj_compare);
}
- std::list<SPItem *>::iterator it(selected.begin());
- Geom::Point p1 = (*it)->getCenter();
+ SelContainer::iterator it(selected.begin());
+ SPItem* item=static_cast<SPItem*>(*it);
+ Geom::Point p1 = (item)->getCenter();
for (++it ;it != selected.end(); ++it)
{
- Geom::Point p2 = (*it)->getCenter();
+ item=static_cast<SPItem*>(*it);
+ Geom::Point p2 = (item)->getCenter();
Geom::Point delta = p1 - p2;
- sp_item_move_rel((*it),Geom::Translate(delta[Geom::X],delta[Geom::Y] ));
+ sp_item_move_rel((item),Geom::Translate(delta[Geom::X],delta[Geom::Y] ));
p1 = p2;
}
- Geom::Point p2 = selected.front()->getCenter();
+ Geom::Point p2 = static_cast<SPItem*>(selected.front())->getCenter();
Geom::Point delta = p1 - p2;
- sp_item_move_rel(selected.front(),Geom::Translate(delta[Geom::X],delta[Geom::Y] ));
+ sp_item_move_rel(static_cast<SPItem*>(selected.front()),Geom::Translate(delta[Geom::X],delta[Geom::Y] ));
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
@@ -615,8 +619,8 @@ private :
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
-
- unclump ((GSList *) _dialog.getDesktop()->getSelection()->itemList());
+ SelContainer x(_dialog.getDesktop()->getSelection()->itemList());
+ unclump (x);
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
@@ -647,8 +651,7 @@ private :
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
- std::list<SPItem *> selected;
- selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL);
+ SelContainer selected(selection->itemList());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -672,12 +675,13 @@ private :
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- for (std::list<SPItem *>::iterator it(selected.begin());
+ for (SelContainer::iterator it(selected.begin());
it != selected.end();
++it)
{
+ SPItem* item=static_cast<SPItem*>(*it);
desktop->getDocument()->ensureUpToDate();
- Geom::OptRect item_box = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds();
+ Geom::OptRect item_box = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds();
if (item_box) {
// find new center, staying within bbox
double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 +
@@ -686,7 +690,7 @@ private :
g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::Y].extent() - (*item_box)[Geom::Y].extent());
// displacement is the new center minus old:
Geom::Point t = Geom::Point (x, y) - 0.5*(item_box->max() + item_box->min());
- sp_item_move_rel(*it, Geom::Translate(t));
+ sp_item_move_rel(item, Geom::Translate(t));
}
}
@@ -746,8 +750,7 @@ private :
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
- std::list<SPItem *> selected;
- selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL);
+ SelContainer selected(selection->itemList());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -758,20 +761,21 @@ private :
std::vector<Baselines> sorted;
- for (std::list<SPItem *>::iterator it(selected.begin());
+ for (SelContainer::iterator it(selected.begin());
it != selected.end();
++it)
{
- if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
- Inkscape::Text::Layout const *layout = te_get_layout(*it);
+ SPItem* item=static_cast<SPItem*>(*it);
+ if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) {
+ Inkscape::Text::Layout const *layout = te_get_layout(item);
boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
if (pt) {
- Geom::Point base = *pt * (*it)->i2dt_affine();
+ Geom::Point base = *pt * (item)->i2dt_affine();
if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X];
if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y];
if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X];
if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y];
- Baselines b (*it, base, _orientation);
+ Baselines b (item, base, _orientation);
sorted.push_back(b);
}
}
@@ -801,18 +805,19 @@ private :
}
} else {
- for (std::list<SPItem *>::iterator it(selected.begin());
+ for (SelContainer::iterator it(selected.begin());
it != selected.end();
++it)
{
- if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
- Inkscape::Text::Layout const *layout = te_get_layout(*it);
+ SPItem* item=static_cast<SPItem*>(*it);
+ if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) {
+ Inkscape::Text::Layout const *layout = te_get_layout(item);
boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
if (pt) {
- Geom::Point base = *pt * (*it)->i2dt_affine();
+ Geom::Point base = *pt * (item)->i2dt_affine();
Geom::Point t(0.0, 0.0);
t[_orientation] = b_min[_orientation] - base[_orientation];
- sp_item_move_rel(*it, Geom::Translate(t));
+ sp_item_move_rel(item, Geom::Translate(t));
changed = true;
}
}
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index fede30b26..abfab8b19 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -1359,7 +1359,7 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, Gtk
return;
}
- if (g_slist_length ((GSList *) selection->itemList()) > 1) {
+ if (selection->itemList().size() > 1) {
gtk_widget_set_sensitive (buttons, FALSE);
gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>"));
return;
@@ -2096,7 +2096,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
+ if (selection->isEmpty() || selection->itemList().size() > 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
return;
}
@@ -2104,11 +2104,11 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
SPObject *obj = selection->singleItem();
SPObject *parent = obj->parent;
- GSList *to_unclump = NULL; // not including the original
+ SelContainer to_unclump; // not including the original
for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
if (clonetiler_is_a_clone_of (child, obj)) {
- to_unclump = g_slist_prepend (to_unclump, child);
+ to_unclump.push_front(child);
}
}
@@ -2116,8 +2116,6 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
unclump (to_unclump);
- g_slist_free (to_unclump);
-
DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER,
_("Unclump tiled clones"));
}
@@ -2147,7 +2145,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
+ if (selection->isEmpty() || selection->itemList().size() > 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
return;
}
@@ -2225,7 +2223,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
}
// Check if more than one object is selected.
- if (g_slist_length((GSList *) selection->itemList()) > 1) {
+ if (selection->itemList().size() > 1) {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
return;
}
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 6d90c792e..fc6094c9f 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -605,7 +605,7 @@ void Export::onBatchClicked ()
void Export::updateCheckbuttons ()
{
- gint num = g_slist_length((GSList *) SP_ACTIVE_DESKTOP->getSelection()->itemList());
+ gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size();
if (num >= 2) {
batch_export.set_sensitive(true);
batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num));
@@ -817,9 +817,9 @@ void Export::onAreaToggled ()
one that's nice */
if (filename.empty()) {
const gchar * id = "object";
- const GSList * reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList();
- for(; reprlst != NULL; reprlst = reprlst->next) {
- Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data;
+ const SelContainer reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList();
+ for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) {
+ Inkscape::XML::Node * repr = (Inkscape::XML::Node *)(*i);
if (repr->attribute("id")) {
id = repr->attribute("id");
break;
@@ -1010,7 +1010,7 @@ void Export::onExport ()
if (batch_export.get_active ()) {
// Batch export of selected objects
- gint num = g_slist_length(const_cast<GSList *>(desktop->getSelection()->itemList()));
+ gint num = (desktop->getSelection()->itemList()).size();
gint n = 0;
if (num < 1) {
@@ -1024,8 +1024,9 @@ void Export::onExport ()
gint export_count = 0;
- for (GSList *i = const_cast<GSList *>(desktop->getSelection()->itemList()); i && !interrupted; i = i->next) {
- SPItem *item = reinterpret_cast<SPItem *>(i->data);
+ SelContainer itemlist=desktop->getSelection()->itemList();
+ for(SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){
+ SPItem *item = reinterpret_cast<SPItem *>(*i);
prog_dlg->set_data("current", GINT_TO_POINTER(n));
prog_dlg->set_data("total", GINT_TO_POINTER(num));
@@ -1063,13 +1064,13 @@ void Export::onExport ()
_("Exporting file <b>%s</b>..."), safeFile), desktop);
MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE,
_("Exporting file <b>%s</b>..."), safeFile), desktop);
-
+ SelContainer x;
if (!sp_export_png_file (doc, path.c_str(),
*area, width, height, dpi, dpi,
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
TRUE, // overwrite without asking
- hide ? const_cast<GSList *>(desktop->getSelection()->itemList()) : NULL
+ hide ? (desktop->getSelection()->itemList()) : x
)) {
gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
@@ -1153,12 +1154,13 @@ void Export::onExport ()
prog_dlg->set_data("total", GINT_TO_POINTER(0));
/* Do export */
+ SelContainer x;
ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(),
Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
FALSE,
- hide ? const_cast<GSList *>(desktop->getSelection()->itemList()) : NULL
+ hide ? (desktop->getSelection()->itemList()) : x
);
if (status == EXPORT_ERROR) {
gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str());
@@ -1224,7 +1226,7 @@ void Export::onExport ()
break;
}
case SELECTION_SELECTION: {
- const GSList * reprlst;
+ SelContainer reprlst;
SPDocument * doc = SP_ACTIVE_DOCUMENT;
bool modified = false;
@@ -1232,8 +1234,8 @@ void Export::onExport ()
DocumentUndo::setUndoSensitive(doc, false);
reprlst = desktop->getSelection()->reprList();
- for(; reprlst != NULL; reprlst = reprlst->next) {
- Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data);
+ for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) {
+ Inkscape::XML::Node * repr = dynamic_cast<Inkscape::XML::Node *>(*i);
const gchar * temp_string;
Glib::ustring dir = Glib::path_get_dirname(filename.c_str());
const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI();
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 3da0e0043..657d6771b 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -690,7 +690,7 @@ private:
void select_svg_element(){
Inkscape::Selection* sel = _desktop->getSelection();
if (sel->isEmpty()) return;
- Inkscape::XML::Node* node = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0);
+ Inkscape::XML::Node* node = (Inkscape::XML::Node*) sel->reprList().front();
if (!node || !node->matchAttributeName("id")) return;
std::ostringstream xlikhref;
@@ -1465,9 +1465,9 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel)
}
std::set<SPObject*> used;
-
- for (GSList const *i = sel->itemList(); i != NULL; i = i->next) {
- SPObject *obj = SP_OBJECT (i->data);
+ SelContainer itemlist=sel->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPStyle *style = obj->style;
if (!style || !SP_IS_ITEM(obj)) {
continue;
@@ -1545,10 +1545,9 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri
if((*iter)[_columns.sel] == 1)
filter = 0;
- GSList const *items = sel->itemList();
-
- for (GSList const *i = items; i != NULL; i = i->next) {
- SPItem * item = SP_ITEM(i->data);
+ SelContainer itemlist=sel->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) {
+ SPItem * item = SP_ITEM(*i);
SPStyle *style = item->style;
g_assert(style != NULL);
@@ -1650,12 +1649,13 @@ void FilterEffectsDialog::FilterModifier::remove_filter()
SPDocument* doc = filter->document;
// Delete all references to this filter
- GSList *all = get_all_items(NULL, _desktop->currentRoot(), _desktop, false, false, true, NULL);
- for (GSList *i = all; i != NULL; i = i->next) {
- if (!SP_IS_ITEM(i->data)) {
+ SelContainer x,y;
+ SelContainer all = get_all_items(x, _desktop->currentRoot(), _desktop, false, false, true, y);
+ for(SelContainer::const_iterator i=all.begin(); all.end() != i; i++) {
+ if (!SP_IS_ITEM(*i)) {
continue;
}
- SPItem *item = SP_ITEM(i->data);
+ SPItem *item = SP_ITEM(*i);
if (!item->style) {
continue;
}
@@ -1668,9 +1668,6 @@ void FilterEffectsDialog::FilterModifier::remove_filter()
}
}
}
- if (all) {
- g_slist_free(all);
- }
//XML Tree being used directly here while it shouldn't be.
sp_repr_unparent(filter->getRepr());
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index 951cb01ea..43ecb60ac 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -549,7 +549,7 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas
}
-GSList *Find::filter_fields (GSList *l, bool exact, bool casematch)
+SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch)
{
Glib::ustring tmp = entry_find.getEntry()->get_text();
if (tmp.empty()) {
@@ -557,17 +557,17 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch)
}
gchar* text = g_strdup(tmp.c_str());
- GSList *in = l;
- GSList *out = NULL;
+ SelContainer in = l;
+ SelContainer out;
if (check_searchin_text.get_active()) {
- for (GSList *i = in; i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
if (item_text_match(item, text, exact, casematch)) {
- if (!g_slist_find(out, i->data)) {
- out = g_slist_prepend (out, i->data);
+ if (out.end()==find(out.begin(),out.end(), *i)) {
+ out.push_front(*i);
if (_action_replace) {
item_text_match(item, text, exact, casematch, _action_replace);
}
@@ -584,12 +584,12 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch)
bool attrvalue = check_attributevalue.get_active();
if (ids) {
- for (GSList *i = in; i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
if (item_id_match(item, text, exact, casematch)) {
- if (!g_slist_find(out, i->data)) {
- out = g_slist_prepend (out, i->data);
+ if (out.end()==find(out.begin(),out.end(), *i)) {
+ out.push_front(*i);
if (_action_replace) {
item_id_match(item, text, exact, casematch, _action_replace);
}
@@ -600,14 +600,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch)
if (style) {
- for (GSList *i = in; i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
if (item_style_match(item, text, exact, casematch)) {
- if (!g_slist_find(out, i->data))
- if (!g_slist_find(out, i->data)) {
- out = g_slist_prepend (out, i->data);
+ if (out.end()==find(out.begin(),out.end(), *i)){
+ out.push_front(*i);
if (_action_replace) {
item_style_match(item, text, exact, casematch, _action_replace);
}
@@ -618,13 +617,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch)
if (attrname) {
- for (GSList *i = in; i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
if (item_attr_match(item, text, exact, casematch)) {
- if (!g_slist_find(out, i->data)) {
- out = g_slist_prepend (out, i->data);
+ if (out.end()==find(out.begin(),out.end(), *i)) {
+ out.push_front(*i);
if (_action_replace) {
item_attr_match(item, text, exact, casematch, _action_replace);
}
@@ -635,13 +634,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch)
if (attrvalue) {
- for (GSList *i = in; i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
if (item_attrvalue_match(item, text, exact, casematch)) {
- if (!g_slist_find(out, i->data)) {
- out = g_slist_prepend (out, i->data);
+ if (out.end()==find(out.begin(),out.end(), *i)) {
+ out.push_front(*i);
if (_action_replace) {
item_attrvalue_match(item, text, exact, casematch, _action_replace);
}
@@ -652,13 +651,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch)
if (font) {
- for (GSList *i = in; i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
if (item_font_match(item, text, exact, casematch)) {
- if (!g_slist_find(out, i->data)) {
- out = g_slist_prepend (out, i->data);
+ if (out.end()==find(out.begin(),out.end(),*i)) {
+ out.push_front(*i);
if (_action_replace) {
item_font_match(item, text, exact, casematch, _action_replace);
}
@@ -716,29 +715,29 @@ bool Find::item_type_match (SPItem *item)
return false;
}
-GSList *Find::filter_types (GSList *l)
+SelContainer Find::filter_types (SelContainer &l)
{
- GSList *n = NULL;
- for (GSList *i = l; i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ SelContainer n;
+ for(SelContainer::const_iterator i=l.begin(); l.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
if (item_type_match(item)) {
- n = g_slist_prepend (n, i->data);
+ n.push_front(*i);
}
}
return n;
}
-GSList *Find::filter_list (GSList *l, bool exact, bool casematch)
+SelContainer &Find::filter_list (SelContainer &l, bool exact, bool casematch)
{
l = filter_types (l);
l = filter_fields (l, exact, casematch);
return l;
}
-GSList *Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked)
+SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool locked)
{
if (dynamic_cast<SPDefs *>(r)) {
return l; // we're not interested in items in defs
@@ -752,7 +751,7 @@ GSList *Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked)
SPItem *item = dynamic_cast<SPItem *>(child);
if (item && !child->cloned && !desktop->isLayer(item)) {
if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) {
- l = g_slist_prepend (l, child);
+ l.push_front(child);
}
}
l = all_items (child, l, hidden, locked);
@@ -760,16 +759,17 @@ GSList *Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked)
return l;
}
-GSList *Find::all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked)
+SelContainer &Find::all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked)
{
- for (GSList *i = (GSList *) s->itemList(); i != NULL; i = i->next) {
- SPObject *obj = reinterpret_cast<SPObject *>(i->data);
+ SelContainer itemlist=s->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) {
+ SPObject *obj = SP_OBJECT (*i);
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
if (item && !item->cloned && !desktop->isLayer(item)) {
if (!ancestor || ancestor->isAncestorOf(item)) {
if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) {
- l = g_slist_prepend (l, i->data);
+ l.push_back(*i);
}
}
}
@@ -817,7 +817,7 @@ void Find::onAction()
bool casematch = check_case_sensitive.get_active();
blocked = true;
- GSList *l = NULL;
+ SelContainer l;
if (check_scope_selection.get_active()) {
if (check_scope_layer.get_active()) {
l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked);
@@ -831,12 +831,12 @@ void Find::onAction()
l = all_items(desktop->getDocument()->getRoot(), l, hidden, locked);
}
}
- guint all = g_slist_length (l);
+ guint all = l.size();
- GSList *n = filter_list (l, exact, casematch);
+ SelContainer n = filter_list (l, exact, casematch);
- if (n != NULL) {
- int count = g_slist_length (n);
+ if (!n.empty()) {
+ int count = n.size();
desktop->messageStack()->flashF(Inkscape::NORMAL_MESSAGE,
// TRANSLATORS: "%s" is replaced with "exact" or "partial" when this string is displayed
ngettext("<b>%d</b> object found (out of <b>%d</b>), %s match.",
@@ -857,7 +857,7 @@ void Find::onAction()
Inkscape::Selection *selection = desktop->getSelection();
selection->clear();
selection->setList(n);
- SPObject *obj = reinterpret_cast<SPObject *>(n->data);
+ SPObject *obj = reinterpret_cast<SPObject *>(n.front());
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
scroll_to_show_item(desktop, item);
diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h
index c0c635f94..1aded96f2 100644
--- a/src/ui/dialog/find.h
+++ b/src/ui/dialog/find.h
@@ -16,6 +16,7 @@
# include <config.h>
#endif
+#include "selection.h"
#include "ui/widget/panel.h"
#include "ui/widget/button.h"
#include "ui/widget/entry.h"
@@ -148,10 +149,10 @@ protected:
/**
* Function to filter a list of items based on the item type by calling each item_XXX_match function
*/
- GSList * filter_fields (GSList *l, bool exact, bool casematch);
+ SelContainer filter_fields (SelContainer &l, bool exact, bool casematch);
bool item_type_match (SPItem *item);
- GSList * filter_types (GSList *l);
- GSList * filter_list (GSList *l, bool exact, bool casematch);
+ SelContainer filter_types (SelContainer &l);
+ SelContainer & filter_list (SelContainer &l, bool exact, bool casematch);
/**
* Find a string within a string and returns true if found with options for exact and casematching
@@ -172,12 +173,12 @@ protected:
* recursive function to return a list of all the items in the SPObject tree
*
*/
- GSList * all_items (SPObject *r, GSList *l, bool hidden, bool locked);
+ SelContainer & all_items (SPObject *r, SelContainer &l, bool hidden, bool locked);
/**
* to return a list of all the selected items
*
*/
- GSList * all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked);
+ SelContainer & all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked);
/**
* Shrink the dialog size when the expander widget is closed
diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp
index 2b9053da9..1ef97b996 100644
--- a/src/ui/dialog/glyphs.cpp
+++ b/src/ui/dialog/glyphs.cpp
@@ -578,9 +578,10 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop)
void GlyphsPanel::insertText()
{
SPItem *textItem = 0;
- for (const GSList *item = targetDesktop->selection->itemList(); item; item = item->next ) {
- if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) {
- textItem = SP_ITEM(item->data);
+ SelContainer itemlist=targetDesktop->selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) {
+ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) {
+ textItem = SP_ITEM(*i);
break;
}
}
@@ -687,8 +688,9 @@ void GlyphsPanel::selectionModifiedCB(guint flags)
void GlyphsPanel::calcCanInsert()
{
int items = 0;
- for (const GSList *item = targetDesktop->selection->itemList(); item; item = item->next ) {
- if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) {
+ SelContainer itemlist=targetDesktop->selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) {
+ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) {
++items;
}
}
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 28a65e0b4..86cf629c1 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -1906,11 +1906,10 @@ void ContextMenu::ActivateGroup(void)
void ContextMenu::ActivateUngroup(void)
{
- GSList *children = NULL;
+ SelContainer children;
- sp_item_group_ungroup(static_cast<SPGroup*>(_item), &children);
+ sp_item_group_ungroup(static_cast<SPGroup*>(_item), children);
_desktop->selection->setList(children);
- g_slist_free(children);
}
void ContextMenu::MakeAnchorMenu(void)
@@ -1959,10 +1958,9 @@ void ContextMenu::AnchorLinkFollow(void)
void ContextMenu::AnchorLinkRemove(void)
{
- GSList *children = NULL;
- sp_item_group_ungroup(static_cast<SPAnchor*>(_item), &children, false);
+ SelContainer children;
+ sp_item_group_ungroup(static_cast<SPAnchor*>(_item), children, false);
DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link"));
- g_slist_free(children);
}
void ContextMenu::MakeImageMenu (void)
@@ -2051,8 +2049,6 @@ void ContextMenu::ImageEdit(void)
_desktop->selection->set(_item);
}
- GSList const *selected = _desktop->selection->itemList();
-
GError* errThing = 0;
Glib::ustring cmdline = getImageEditorName();
Glib::ustring name;
@@ -2079,8 +2075,9 @@ void ContextMenu::ImageEdit(void)
}
#endif
- for (GSList const *iter = selected; iter != NULL; iter = iter->next) {
- Inkscape::XML::Node *ir = SP_ITEM(iter->data)->getRepr();
+ SelContainer itemlist=_desktop->selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ Inkscape::XML::Node *ir = SP_ITEM(*i)->getRepr();
const gchar *href = ir->attribute("xlink:href");
if (strncmp (href,"file:",5) == 0) {