summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomasz Boczkowski <penginsbacon@gmail.com>2014-05-27 17:13:09 +0000
committerTomasz Boczkowski <penginsbacon@gmail.com>2014-05-27 17:13:09 +0000
commit6508c429a4a678541bc51df10a8335bbb45f0128 (patch)
tree66c65dd3765654172b4e3bef0c4f116c1cb5515c /src
parentSPPattern c++-sification: replaced gchar* by Glib::ustring (diff)
downloadinkscape-6508c429a4a678541bc51df10a8335bbb45f0128.tar.gz
inkscape-6508c429a4a678541bc51df10a8335bbb45f0128.zip
SPPattern c++-sification: replaced GSList by std::list
(bzr r13341.6.18)
Diffstat (limited to 'src')
-rw-r--r--src/selection-chemistry.cpp6
-rw-r--r--src/sp-pattern.cpp41
-rw-r--r--src/sp-pattern.h21
3 files changed, 37 insertions, 31 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 868a9d743..19eba8ddd 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -3242,13 +3242,11 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
gint pos = SP_OBJECT(items->data)->getRepr()->position();
// create a list of duplicates
- GSList *repr_copies = NULL;
+ std::list<Inkscape::XML::Node*> repr_copies;
for (GSList *i = items; i != NULL; i = i->next) {
Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
- repr_copies = g_slist_prepend(repr_copies, dup);
+ repr_copies.push_back(dup);
}
- // restore the z-order after prepends
- repr_copies = g_slist_reverse(repr_copies);
Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index 59fbca435..a3de09368 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -222,37 +222,34 @@ void SPPattern::set(unsigned int key, const gchar* value) {
/* fixme: We need ::order_changed handler too (Lauris) */
-static GSList *pattern_getchildren(SPPattern *pat)
+void pattern_getchildren(SPPattern *pat, std::list<SPObject*>& l)
{
- GSList *l = NULL;
-
for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
if (pat_i->firstChild()) { // find the first one with children
for (SPObject *child = pat->firstChild() ; child ; child = child->getNext() ) {
- l = g_slist_prepend (l, child);
+ l.push_back(child);
}
break; // do not go further up the chain if children are found
}
}
-
- return l;
}
void SPPattern::update(SPCtx* ctx, unsigned int flags) {
- if (flags & SP_OBJECT_MODIFIED_FLAG) {
+ typedef std::list<SPObject*>::iterator SPObjectIterator;
+
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
flags &= SP_OBJECT_MODIFIED_CASCADE;
- GSList *l = pattern_getchildren (this);
- l = g_slist_reverse (l);
+ std::list<SPObject*> l;
+ pattern_getchildren (this, l);
- while (l) {
- SPObject *child = SP_OBJECT (l->data);
+ for (SPObjectIterator it = l.begin(); it != l.end(); it++) {
+ SPObject *child = *it;
sp_object_ref (child, NULL);
- l = g_slist_remove (l, child);
if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->updateDisplay(ctx, flags);
@@ -263,20 +260,21 @@ void SPPattern::update(SPCtx* ctx, unsigned int flags) {
}
void SPPattern::modified(unsigned int flags) {
+ typedef std::list<SPObject*>::iterator SPObjectIterator;
+
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
flags &= SP_OBJECT_MODIFIED_CASCADE;
- GSList *l = pattern_getchildren (this);
- l = g_slist_reverse (l);
+ std::list<SPObject*> l;
+ pattern_getchildren (this, l);
- while (l) {
- SPObject *child = SP_OBJECT (l->data);
+ for (SPObjectIterator it = l.begin(); it != l.end(); it++) {
+ SPObject *child = *it;
sp_object_ref (child, NULL);
- l = g_slist_remove (l, child);
if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->emitModified(flags);
@@ -402,8 +400,11 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se
pattern->getRepr()->setAttribute("patternTransform", c);
}
-const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move)
+const gchar *pattern_tile(const std::list<Inkscape::XML::Node*> &reprs, Geom::Rect bounds,
+ SPDocument *document, Geom::Affine transform, Geom::Affine move)
{
+ typedef std::list<Inkscape::XML::Node*>::const_iterator NodePtrIterator;
+
Inkscape::XML::Document *xml_doc = document->getReprDoc();
Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr();
@@ -419,8 +420,8 @@ const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document
const gchar *pat_id = repr->attribute("id");
SPObject *pat_object = document->getObjectById(pat_id);
- for (GSList *i = reprs; i != NULL; i = i->next) {
- Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data);
+ for (NodePtrIterator i = reprs.begin(); i != reprs.end(); i++) {
+ Inkscape::XML::Node *node = *i;
SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node));
Geom::Affine dup_transform;
diff --git a/src/sp-pattern.h b/src/sp-pattern.h
index 422adb169..3f7433d62 100644
--- a/src/sp-pattern.h
+++ b/src/sp-pattern.h
@@ -13,22 +13,29 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <list>
#include <gtk/gtk.h>
+#include <stddef.h>
+#include <sigc++/connection.h>
#include "sp-item.h"
+#include "svg/svg-length.h"
+#include "sp-paint-server.h"
+#include "uri-references.h"
+#include "viewbox.h"
#define SP_PATTERN(obj) (dynamic_cast<SPPattern*>((SPObject*)obj))
#define SP_IS_PATTERN(obj) (dynamic_cast<const SPPattern*>((SPObject*)obj) != NULL)
class SPPatternReference;
-#include "svg/svg-length.h"
-#include "sp-paint-server.h"
-#include "uri-references.h"
-#include "viewbox.h"
+namespace Inkscape {
+namespace XML {
-#include <stddef.h>
-#include <sigc++/connection.h>
+class Node;
+
+}
+}
class SPPattern : public SPPaintServer, public SPViewBox {
@@ -92,7 +99,7 @@ SPPattern *pattern_chain (SPPattern *pattern);
SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property);
void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set);
-const gchar *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move);
+const gchar *pattern_tile (const std::list<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move);
SPPattern *pattern_getroot (SPPattern *pat);