diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-10-01 21:57:52 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-10-01 21:57:52 +0000 |
| commit | c20891fabc8c3ee2251e0545878e06545b6f0cdd (patch) | |
| tree | c19727ea5ec4c7fb90b7e4512a3cc5fb89f58945 /src | |
| parent | Merge branch 'master' of gitlab.com:inkscape/inkscape (diff) | |
| download | inkscape-c20891fabc8c3ee2251e0545878e06545b6f0cdd.tar.gz inkscape-c20891fabc8c3ee2251e0545878e06545b6f0cdd.zip | |
First batch
Diffstat (limited to 'src')
| -rw-r--r-- | src/gradient-chemistry.cpp | 27 | ||||
| -rw-r--r-- | src/inkscape.cpp | 46 | ||||
| -rw-r--r-- | src/selection-describer.cpp | 19 | ||||
| -rw-r--r-- | src/sp-clippath.cpp | 23 | ||||
| -rw-r--r-- | src/sp-flowregion.cpp | 62 | ||||
| -rw-r--r-- | src/sp-flowtext.cpp | 22 | ||||
| -rw-r--r-- | src/sp-item.cpp | 11 | ||||
| -rw-r--r-- | src/sp-mesh-array.cpp | 29 | ||||
| -rw-r--r-- | src/sp-mesh-row.cpp | 13 | ||||
| -rw-r--r-- | src/sp-script.cpp | 41 | ||||
| -rw-r--r-- | src/sp-text.cpp | 37 | ||||
| -rw-r--r-- | src/sp-tref.cpp | 10 | ||||
| -rw-r--r-- | src/ui/contextmenu.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/clonetiler.cpp | 8 | ||||
| -rw-r--r-- | src/ui/dialog/grid-arrange-tab.cpp | 10 | ||||
| -rw-r--r-- | src/ui/dialog/tags.cpp | 8 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 91 | ||||
| -rw-r--r-- | src/ui/widget/color-notebook.cpp | 5 | ||||
| -rw-r--r-- | src/widgets/ege-adjustment-action.cpp | 13 | ||||
| -rw-r--r-- | src/widgets/gradient-vector.cpp | 61 | ||||
| -rw-r--r-- | src/widgets/paint-selector.cpp | 74 |
21 files changed, 214 insertions, 398 deletions
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 05f594f86..cc676bffe 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -955,43 +955,36 @@ void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or sp_gradient_repr_set_link(gradient->getRepr(), vector); } - GSList *child_reprs = NULL; - GSList *child_objects = NULL; + std::vector<SPObject *> child_objects; + std::vector<Inkscape::XML::Node *>child_reprs; std::vector<double> offsets; double offset; for (auto& child: vector->children) { - child_reprs = g_slist_prepend (child_reprs, child.getRepr()); - child_objects = g_slist_prepend (child_objects, &child); + child_reprs.push_back(child.getRepr()); + child_objects.push_back(&child); offset=0; sp_repr_get_double(child.getRepr(), "offset", &offset); offsets.push_back(offset); } - GSList *child_copies = NULL; - for (GSList *i = child_reprs; i != NULL; i = i->next) { - Inkscape::XML::Node *repr = (Inkscape::XML::Node *) i->data; + std::vector<Inkscape::XML::Node *> child_copies; + for (auto repr:child_reprs) { Inkscape::XML::Document *xml_doc = vector->getRepr()->document(); - child_copies = g_slist_append (child_copies, repr->duplicate(xml_doc)); + child_copies.push_back(repr->duplicate(xml_doc)); } - for (GSList *i = child_objects; i != NULL; i = i->next) { - SPObject *child = SP_OBJECT (i->data); - child->deleteObject(); + for (auto i:child_objects) { + i->deleteObject(); } std::vector<double>::iterator iter = offsets.end() - 1; - for (GSList *i = child_copies; i != NULL; i = i->next) { - Inkscape::XML::Node *copy = (Inkscape::XML::Node *) i->data; + for (auto copy:child_copies) { vector->appendChildRepr(copy); sp_repr_set_svg_double (copy, "offset", 1 - *iter); --iter; Inkscape::GC::release(copy); } - - g_slist_free (child_reprs); - g_slist_free (child_copies); - g_slist_free (child_objects); } void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fill_or_stroke) diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 8dfff3c63..c56002753 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -579,8 +579,8 @@ Application::crash_handler (int /*signum*/) gint count = 0; gchar *curdir = g_get_current_dir(); // This one needs to be freed explicitly gchar *inkscapedir = g_path_get_dirname(INKSCAPE._argv0); // Needs to be freed - GSList *savednames = NULL; - GSList *failednames = NULL; + std::vector<gchar *> savednames; + std::vector<gchar *> failednames; for (std::map<SPDocument*,int>::iterator iter = INKSCAPE._document_set.begin(), e = INKSCAPE._document_set.end(); iter != e; ++iter) { @@ -641,10 +641,10 @@ Application::crash_handler (int /*signum*/) // Save if (file) { sp_repr_save_stream (repr->document(), file, SP_SVG_NS_URI); - savednames = g_slist_prepend (savednames, g_strdup (c)); + savednames.push_back(g_strdup (c)); fclose (file); } else { - failednames = g_slist_prepend (failednames, (doc->getName()) ? g_strdup(doc->getName()) : g_strdup (_("Untitled document"))); + failednames.push_back((doc->getName()) ? g_strdup(doc->getName()) : g_strdup (_("Untitled document"))); } count++; } @@ -652,18 +652,16 @@ Application::crash_handler (int /*signum*/) g_free(curdir); g_free(inkscapedir); - savednames = g_slist_reverse (savednames); - failednames = g_slist_reverse (failednames); - if (savednames) { + if (!savednames.empty()) { fprintf (stderr, "\nEmergency save document locations:\n"); - for (GSList *l = savednames; l != NULL; l = l->next) { - fprintf (stderr, " %s\n", (gchar *) l->data); + for (auto i:savednames) { + fprintf (stderr, " %s\n", i); } } - if (failednames) { + if (!failednames.empty()) { fprintf (stderr, "\nFailed to do emergency save for documents:\n"); - for (GSList *l = failednames; l != NULL; l = l->next) { - fprintf (stderr, " %s\n", (gchar *) l->data); + for (auto i:failednames) { + fprintf (stderr, " %s\n", i); } } @@ -681,11 +679,11 @@ Application::crash_handler (int /*signum*/) char const *fstr = _("Automatic backup of the following documents failed:\n"); gint nllen = strlen ("\n"); gint len = strlen (istr) + strlen (sstr) + strlen (fstr); - for (GSList *l = savednames; l != NULL; l = l->next) { - len = len + SP_INDENT + strlen ((gchar *) l->data) + nllen; + for (auto i:savednames) { + len = len + SP_INDENT + strlen (i) + nllen; } - for (GSList *l = failednames; l != NULL; l = l->next) { - len = len + SP_INDENT + strlen ((gchar *) l->data) + nllen; + for (auto i:failednames) { + len = len + SP_INDENT + strlen (i) + nllen; } len += 1; gchar *b = g_new (gchar, len); @@ -693,29 +691,29 @@ Application::crash_handler (int /*signum*/) len = strlen (istr); memcpy (b + pos, istr, len); pos += len; - if (savednames) { + if (!savednames.empty()) { len = strlen (sstr); memcpy (b + pos, sstr, len); pos += len; - for (GSList *l = savednames; l != NULL; l = l->next) { + for (auto i:savednames) { memset (b + pos, ' ', SP_INDENT); pos += SP_INDENT; - len = strlen ((gchar *) l->data); - memcpy (b + pos, l->data, len); + len = strlen(i); + memcpy (b + pos, i, len); pos += len; memcpy (b + pos, "\n", nllen); pos += nllen; } } - if (failednames) { + if (!failednames.empty()) { len = strlen (fstr); memcpy (b + pos, fstr, len); pos += len; - for (GSList *l = failednames; l != NULL; l = l->next) { + for (auto i:failednames) { memset (b + pos, ' ', SP_INDENT); pos += SP_INDENT; - len = strlen ((gchar *) l->data); - memcpy (b + pos, l->data, len); + len = strlen(i); + memcpy (b + pos, i, len); pos += len; memcpy (b + pos, "\n", nllen); pos += nllen; diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 43fe1311d..5044864a4 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -15,6 +15,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif +#include <set> #include <glibmm/i18n.h> #include "xml/quote.h" @@ -33,16 +34,15 @@ // Returns a list of terms for the items to be used in the statusbar char* collect_terms (const std::vector<SPItem*> &items) { - GSList *check = NULL; + std::set<Glib::ustring> check; std::stringstream ss; bool first = true; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();++iter ) { SPItem *item = *iter; - if (item) { - const char *term = item->displayName(); - if (term != NULL && g_slist_find (check, term) == NULL) { - check = g_slist_prepend (check, (void *) term); + if (item && item->displayName()) { + Glib::ustring term(item->displayName()); + if (term != "" && (check.insert(term).second)) { ss << (first ? "" : ", ") << "<b>" << term << "</b>"; first = false; } @@ -54,14 +54,13 @@ char* collect_terms (const std::vector<SPItem*> &items) // Returns the number of terms in the list static int count_terms (const std::vector<SPItem*> &items) { - GSList *check = NULL; + std::set<Glib::ustring> check; int count=0; for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();++iter ) { SPItem *item = *iter; - if (item) { - const char *term = item->displayName(); - if (term != NULL && g_slist_find (check, term) == NULL) { - check = g_slist_prepend (check, (void *) term); + if (item && item->displayName()) { + Glib::ustring term(item->displayName()); + if (term != "" && (check.insert(term).second)) { count++; } } diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index a56dfd85a..d3a3810cb 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -126,18 +126,13 @@ void SPClipPath::update(SPCtx* ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; + std::vector<SPObject *> l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse(l); - - while (l) { - SPObject *child = SP_OBJECT(l->data); - l = g_slist_remove(l, child); - + for (auto child:l) { if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); } @@ -165,22 +160,16 @@ void SPClipPath::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; + std::vector<SPObject *> l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse(l); - - while (l) { - SPObject *child = SP_OBJECT(l->data); - l = g_slist_remove(l, child); - + for (auto child:l) { if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); } - sp_object_unref(child); } } diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 4064c12f1..6640d93c2 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -59,19 +59,15 @@ void SPFlowregion::update(SPCtx *ctx, unsigned int flags) { } childflags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; + std::vector<SPObject*>l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse(l); - - while (l) { - SPObject *child = reinterpret_cast<SPObject *>(l->data); + for (auto child:l) { g_assert(child != NULL); - l = g_slist_remove(l, child); SPItem *item = dynamic_cast<SPItem *>(child); if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { @@ -114,19 +110,15 @@ void SPFlowregion::modified(guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; + std::vector<SPObject *>l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse(l); - - while (l) { - SPObject *child = reinterpret_cast<SPObject *>(l->data); + for (auto child:l) { g_assert(child != NULL); - l = g_slist_remove(l, child); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); @@ -142,21 +134,20 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc repr = xml_doc->createElement("svg:flowRegion"); } - GSList *l = NULL; + std::vector<Inkscape::XML::Node *> l; for (auto& child: children) { if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { - l = g_slist_prepend(l, crepr); + l.push_back(crepr); } } } - while (l) { - repr->addChild((Inkscape::XML::Node *) l->data, NULL); - Inkscape::GC::release((Inkscape::XML::Node *) l->data); - l = g_slist_remove(l, l->data); + for (auto i = l.rbegin(); i != l.rend(); ++i) { + repr->addChild(*i, NULL); + Inkscape::GC::release(*i); } for (auto& child: children) { @@ -216,19 +207,15 @@ void SPFlowregionExclude::update(SPCtx *ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; + std::vector<SPObject *> l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse (l); - - while (l) { - SPObject *child = reinterpret_cast<SPObject *>(l->data); + for(auto child:l) { g_assert(child != NULL); - l = g_slist_remove(l, child); if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { SPItem *item = dynamic_cast<SPItem *>(child); @@ -268,19 +255,15 @@ void SPFlowregionExclude::modified(guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; + std::vector<SPObject*> l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse (l); - - while (l) { - SPObject *child = reinterpret_cast<SPObject *>(l->data); + for (auto child:l) { g_assert(child != NULL); - l = g_slist_remove(l, child); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); @@ -296,20 +279,19 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc repr = xml_doc->createElement("svg:flowRegionExclude"); } - GSList *l = NULL; + std::vector<Inkscape::XML::Node *> l; for (auto& child: children) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { - l = g_slist_prepend(l, crepr); + l.push_back(crepr); } } - while (l) { - repr->addChild((Inkscape::XML::Node *) l->data, NULL); - Inkscape::GC::release((Inkscape::XML::Node *) l->data); - l = g_slist_remove(l, l->data); + for (auto i = l.rbegin(); i != l.rend(); ++i) { + repr->addChild(*i, NULL); + Inkscape::GC::release(*i); } } else { diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index c5af85774..2425dada3 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -65,19 +65,14 @@ void SPFlowtext::update(SPCtx* ctx, unsigned int flags) { } childflags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; - + std::vector<SPObject *> l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse(l); - - while (l) { - SPObject *child = reinterpret_cast<SPObject *>(l->data); + for (auto child:l) { g_assert(child != NULL); - l = g_slist_remove(l, child); if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { SPItem *item = dynamic_cast<SPItem *>(child); @@ -216,7 +211,7 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X repr = doc->createElement("svg:flowRoot"); } - GSList *l = NULL; + std::vector<Inkscape::XML::Node *> l; for (auto& child: children) { Inkscape::XML::Node *c_repr = NULL; @@ -226,14 +221,13 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X } if ( c_repr ) { - l = g_slist_prepend(l, c_repr); + l.push_back(c_repr); } } - while ( l ) { - repr->addChild((Inkscape::XML::Node *) l->data, NULL); - Inkscape::GC::release((Inkscape::XML::Node *) l->data); - l = g_slist_remove(l, l->data); + for (auto i=l.rbegin();i!=l.rend();++i) { + repr->addChild(*i, NULL); + Inkscape::GC::release(*i); } } else { for (auto& child: children) { diff --git a/src/sp-item.cpp b/src/sp-item.cpp index dd98ee1a4..a780f1a29 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -711,19 +711,18 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X // in the case of SP_OBJECT_WRITE_BUILD, the item should always be newly created, // so we need to add any children from the underlying object to the new repr if (flags & SP_OBJECT_WRITE_BUILD) { - GSList *l = NULL; + std::vector<Inkscape::XML::Node *>l; for (auto& child: object->children) { if (dynamic_cast<SPTitle *>(&child) || dynamic_cast<SPDesc *>(&child)) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { - l = g_slist_prepend (l, crepr); + l.push_back(crepr); } } } - while (l) { - repr->addChild((Inkscape::XML::Node *) l->data, NULL); - Inkscape::GC::release((Inkscape::XML::Node *) l->data); - l = g_slist_remove (l, l->data); + for (auto i = l.rbegin(); i!= l.rend(); ++i) { + repr->addChild(*i, NULL); + Inkscape::GC::release(*i); } } else { for (auto& child: object->children) { diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index c89cfcc6f..a8d9e589c 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -936,31 +936,26 @@ void SPMeshNodeArray::write( SPMeshGradient *mg ) { } // First we must delete reprs for old mesh rows and patches. - GSList *descendant_reprs = NULL; - GSList *descendant_objects = NULL; + std::vector<SPObject*> descendant_objects; + std::vector<Inkscape::XML::Node *> descendant_reprs; for (auto& row: mg_array->children) { - descendant_reprs = g_slist_prepend (descendant_reprs, row.getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, &row); + descendant_reprs.push_back(row.getRepr()); + descendant_objects.push_back(&row); for (auto& patch: row.children) { - descendant_reprs = g_slist_prepend (descendant_reprs, patch.getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, &patch); + descendant_reprs.push_back(patch.getRepr()); + descendant_objects.push_back(&patch); for (auto& stop: patch.children) { - descendant_reprs = g_slist_prepend (descendant_reprs, stop.getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, &stop); + descendant_reprs.push_back(stop.getRepr()); + descendant_objects.push_back(&stop); } } } - for ( GSList *i = descendant_objects; i != NULL; i = i->next ) { - SPObject *descendant = SP_OBJECT (i->data); - descendant->deleteObject(); - } - - for ( GSList *i = descendant_reprs; i != NULL; i = i->next ) { - Inkscape::XML::Node *repr = (Inkscape::XML::Node *) i->data; - sp_repr_unparent( repr ); - } + for (auto i:descendant_objects) + i->deleteObject(); + for (auto i:descendant_reprs) + sp_repr_unparent(i); // Now we build new reprs Inkscape::XML::Node *mesh = mg->getRepr(); diff --git a/src/sp-mesh-row.cpp b/src/sp-mesh-row.cpp index 5ac349c27..8204aff65 100644 --- a/src/sp-mesh-row.cpp +++ b/src/sp-mesh-row.cpp @@ -78,23 +78,16 @@ void SPMeshrow::set(unsigned int /*key*/, const gchar* /*value*/) { void SPMeshrow::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = NULL; - + std::vector<SPObject *> l; for (auto& child: children) { sp_object_ref(&child); - l = g_slist_prepend(l, &child); + l.push_back(&child); } - l = g_slist_reverse(l); - - while (l) { - SPObject *child = SP_OBJECT(l->data); - l = g_slist_remove(l, child); - + for (auto child:l) { if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); } - sp_object_unref(child); } } diff --git a/src/sp-script.cpp b/src/sp-script.cpp index bd1ab512b..144c8d76a 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -73,47 +73,6 @@ Inkscape::XML::Node* SPScript::write(Inkscape::XML::Document* /*doc*/, Inkscape: return repr; } -//static Inkscape::XML::Node *sp_script_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -//{ -/* -TODO: - code copied from sp-defs - decide what to do here! - - if (flags & SP_OBJECT_WRITE_BUILD) { - - if (!repr) { - repr = xml_doc->createElement("svg:script"); - } - - GSList *l = NULL; - for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); - if (crepr) { - l = g_slist_prepend(l, crepr); - } - } - - while (l) { - repr->addChild((Inkscape::XML::Node *) l->data, NULL); - Inkscape::GC::release((Inkscape::XML::Node *) l->data); - l = g_slist_remove(l, l->data); - } - - } else { - for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { - child->updateRepr(flags); - } - } - - if (((SPObjectClass *) (parent_class))->write) { - (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, flags); - } -*/ -// -// return ((SPScript*)object)->cscript->onWrite(xml_doc, repr, flags); -//} - /* Local Variables: mode:c++ diff --git a/src/sp-text.cpp b/src/sp-text.cpp index a13adbf0b..7bc120985 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -150,24 +150,17 @@ void SPText::update(SPCtx *ctx, guint flags) { } // Create temporary list of children - GSList *l = NULL; - + std::vector<SPObject *> l; for (auto& child: children) { sp_object_ref(&child, this); - l = g_slist_prepend (l, &child); + l.push_back(&child); } - l = g_slist_reverse (l); - - while (l) { - SPObject *child = reinterpret_cast<SPObject*>(l->data); // We just built this list, so cast is safe. - l = g_slist_remove (l, child); - + for (auto child:l) { if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { /* fixme: Do we need transform? */ child->updateDisplay(ctx, childflags); } - sp_object_unref(child, this); } @@ -230,23 +223,16 @@ void SPText::modified(guint flags) { } // Create temporary list of children - GSList *l = NULL; - + std::vector<SPObject *> l; for (auto& child: children) { sp_object_ref(&child, this); - l = g_slist_prepend (l, &child); + l.push_back(&child); } - l = g_slist_reverse (l); - - while (l) { - SPObject *child = reinterpret_cast<SPObject*>(l->data); // We just built this list, so cast is safe. - l = g_slist_remove (l, child); - + for (auto child:l) { if (cflags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(cflags); } - sp_object_unref(child, this); } } @@ -257,7 +243,7 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X repr = xml_doc->createElement("svg:text"); } - GSList *l = NULL; + std::vector<Inkscape::XML::Node *> l; for (auto& child: children) { if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { @@ -273,14 +259,13 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X } if (crepr) { - l = g_slist_prepend (l, crepr); + l.push_back(crepr); } } - while (l) { - repr->addChild((Inkscape::XML::Node *) l->data, NULL); - Inkscape::GC::release((Inkscape::XML::Node *) l->data); - l = g_slist_remove (l, l->data); + for (auto i=l.rbegin();i!=l.rend();++i) { + repr->addChild(*i, NULL); + Inkscape::GC::release(*i); } } else { for (auto& child: children) { diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 014876478..2655e219b 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -502,16 +502,12 @@ sp_tref_convert_to_tspan(SPObject *obj) // RECURSIVE CASE //////////////////// else { - GSList *l = NULL; + std::vector<SPObject *> l; for (auto& child: obj->children) { sp_object_ref(&child, obj); - l = g_slist_prepend (l, &child); + l.push_back(&child); } - l = g_slist_reverse (l); - while (l) { - SPObject *child = reinterpret_cast<SPObject *>(l->data); // We just built this list, so cast is safe. - l = g_slist_remove (l, child); - + for(auto child:l) { // Note that there may be more than one conversion happening here, so if it's not a // tref being passed into this function, the returned value can't be specifically known new_tspan = sp_tref_convert_to_tspan(child); diff --git a/src/ui/contextmenu.cpp b/src/ui/contextmenu.cpp index 1bc87574e..3ca752c82 100644 --- a/src/ui/contextmenu.cpp +++ b/src/ui/contextmenu.cpp @@ -253,7 +253,7 @@ context_menu_item_on_my_deselect(void */*object*/, SPAction *action) // TODO: Update this to allow radio items to be used -void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group) +void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb) { SPAction *action; SPDesktop *view = _desktop; diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 5c9b31fb1..71edcf259 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1993,18 +1993,16 @@ void CloneTiler::remove(bool do_undo/* = true*/) SPObject *parent = obj->parent; // remove old tiling - GSList *to_delete = NULL; + std::vector<SPObject *> to_delete; for (auto& child: parent->children) { if (is_a_clone_of (&child, obj)) { - to_delete = g_slist_prepend (to_delete, &child); + to_delete.push_back(&child); } } - for (GSList *i = to_delete; i; i = i->next) { - SPObject *obj = reinterpret_cast<SPObject *>(i->data); + for (auto obj:to_delete) { g_assert(obj != NULL); obj->deleteObject(); } - g_slist_free (to_delete); change_selection (selection); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 6e08645cf..c16e60c5f 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -298,15 +298,14 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h std::vector<SPItem*>::iterator it = sorted.begin(); for (row_cnt=0; ((it != sorted.end()) && (row_cnt<NoOfRows)); ++row_cnt) { - GSList *current_row = NULL; + std::vector<SPItem *> current_row; col_cnt = 0; for(;it!=sorted.end()&&col_cnt<NoOfCols;++it) { - current_row = g_slist_append (current_row, *it); + current_row.push_back(*it); col_cnt++; } - for (; current_row != NULL; current_row = current_row->next) { - SPItem *item=SP_ITEM(current_row->data); + for (auto item:current_row) { Inkscape::XML::Node *repr = item->getRepr(); Geom::OptRect b = item->documentVisualBounds(); Geom::Point min; @@ -330,10 +329,9 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); item->set_i2d_affine(item->i2dt_affine() * affine); item->doWriteTransform(item->transform); - SP_OBJECT (current_row->data)->updateRepr(); + item->updateRepr(); cnt +=1; } - g_slist_free (current_row); } DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_ARRANGE, diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 176719995..5a5417eb5 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -1103,14 +1103,6 @@ void TagsPanel::setDesktop( SPDesktop* desktop ) setDocument(_desktop, _desktop->doc()); } } -/* - GSList const *layers = _desktop->doc()->getResourceList( "layer" ); - g_message( "layers list starts at %p", layers ); - for ( GSList const *iter=layers ; iter ; iter = iter->next ) { - SPObject *layer=static_cast<SPObject *>(iter->data); - g_message(" {%s} [%s]", layer->id, layer->label() ); - } -*/ deskTrack.setBase(desktop); } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 7a9b92378..f6a353b33 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -25,6 +25,8 @@ #include "ui/dialog/dialog-manager.h" #include <gtkmm/icontheme.h> +#include <gtkmm/radiomenuitem.h> +#include <gtkmm/separatormenuitem.h> #include "file.h" #include <glibmm/miscutils.h> @@ -220,19 +222,14 @@ sp_create_window(SPViewWidget *vw, bool editable) if ( completeDropTargets == 0 || completeDropTargetsCount == 0 ) { - std::vector<gchar*> types; - - GSList *list = gdk_pixbuf_get_formats(); - while ( list ) { - int i = 0; - GdkPixbufFormat *one = (GdkPixbufFormat*)list->data; - gchar** typesXX = gdk_pixbuf_format_get_mime_types(one); - for ( i = 0; typesXX[i]; i++ ) { - types.push_back(g_strdup(typesXX[i])); - } - g_strfreev(typesXX); + std::vector<Glib::ustring> types; - list = g_slist_next(list); + std::vector<Gdk::PixbufFormat> list = Gdk::Pixbuf::get_formats(); + for (auto one:list) { + std::vector<Glib::ustring> typesXX = one.get_mime_types(); + for (auto i:typesXX) { + types.push_back(i); + } } completeDropTargetsCount = nui_drop_target_entries + types.size(); completeDropTargets = new GtkTargetEntry[completeDropTargetsCount]; @@ -241,8 +238,8 @@ sp_create_window(SPViewWidget *vw, bool editable) } int pos = nui_drop_target_entries; - for (std::vector<gchar*>::iterator it = types.begin() ; it != types.end() ; ++it) { - completeDropTargets[pos].target = *it; + for (std::vector<Glib::ustring>::iterator it = types.begin() ; it != types.end() ; ++it) { + completeDropTargets[pos].target = g_strdup((*it).c_str()); completeDropTargets[pos].flags = 0; completeDropTargets[pos].info = IMAGE_DATA; pos++; @@ -451,14 +448,14 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men Inkscape::UI::View::View *view, bool show_icon = false, bool radio = false, - GSList *group = NULL) + Gtk::RadioMenuItem::Group *group = NULL) { - GtkWidget *item; + Gtk::Widget *item; // Just create a menu separator if this isn't a real action. // Otherwise, create a real menu item if (verb->get_code() == SP_VERB_NONE) { - item = gtk_separator_menu_item_new(); + item = new Gtk::SeparatorMenuItem(); } else { SPAction *action = verb->get_action(Inkscape::ActionContext(view)); @@ -467,9 +464,9 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men // Create the menu item itself, either as a radio menu item, or just // a regular menu item depending on whether the "radio" flag is set if (radio) { - item = gtk_radio_menu_item_new(group); + item = new Gtk::RadioMenuItem(*group); } else { - item = gtk_menu_item_new(); + item = new Gtk::MenuItem(); } // Create a box to contain all the widgets (icon, label, accelerator) @@ -490,8 +487,8 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men GtkAccelGroup *accel_group = sp_shortcut_get_accel_group(); gtk_menu_set_accel_group(menu, accel_group); - sp_shortcut_add_accelerator(item, sp_shortcut_get_primary(verb)); - gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), item); + sp_shortcut_add_accelerator(item->gobj(), sp_shortcut_get_primary(verb)); + gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), item->gobj()); GtkWidget *icon; @@ -508,33 +505,34 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); // Finally, pack all the widgets into the menu item - gtk_container_add(GTK_CONTAINER(item), box); + gtk_container_add(GTK_CONTAINER(item->gobj()), box); action->signal_set_sensitive.connect( sigc::bind<0>( sigc::ptr_fun(>k_widget_set_sensitive), - item)); + item->gobj())); action->signal_set_name.connect( sigc::bind<0>( sigc::ptr_fun(&sp_ui_menu_item_set_name), - item)); + item->gobj())); if (!action->sensitive) { - gtk_widget_set_sensitive(item, FALSE); + item->set_sensitive(false); } - gtk_widget_set_events(item, GDK_KEY_PRESS_MASK); - g_object_set_data(G_OBJECT(item), "view", (gpointer) view); - g_signal_connect( G_OBJECT(item), "activate", G_CALLBACK(sp_ui_menu_activate), action ); - g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select_action), action ); - g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect_action), action ); + gtk_widget_set_events(item->gobj(), GDK_KEY_PRESS_MASK); + + g_object_set_data(G_OBJECT(item->gobj()), "view", (gpointer) view); + g_signal_connect( G_OBJECT(item->gobj()), "activate", G_CALLBACK(sp_ui_menu_activate), action ); + g_signal_connect( G_OBJECT(item->gobj()), "select", G_CALLBACK(sp_ui_menu_select_action), action ); + g_signal_connect( G_OBJECT(item->gobj()), "deselect", G_CALLBACK(sp_ui_menu_deselect_action), action ); } - gtk_widget_show_all(item); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + item->show_all(); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item->gobj()); - return item; + return item->gobj(); } // end of sp_ui_menu_append_item_from_verb @@ -769,25 +767,24 @@ static void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view) 0, 0 }; - GSList *group = 0; + Gtk::RadioMenuItem::Group group; int count = 0; gint active = Inkscape::UI::UXManager::getInstance()->getDefaultTask( dynamic_cast<SPDesktop*>(view) ); for (gchar const **strs = data; strs[0]; strs += 2, count++) { - GtkWidget *item = gtk_radio_menu_item_new_with_label( group, strs[0] ); - group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item) ); + Gtk::RadioMenuItem *item = new Gtk::RadioMenuItem(group,Glib::ustring(strs[0])); if ( count == active ) { - gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(item), TRUE ); + item->set_active(); } - g_object_set_data( G_OBJECT(item), "view", view ); - g_signal_connect( G_OBJECT(item), "toggled", reinterpret_cast<GCallback>(taskToggled), GINT_TO_POINTER(count) ); - g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), const_cast<gchar*>(strs[1]) ); - g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), 0 ); + g_object_set_data( G_OBJECT(item->gobj()), "view", view ); + g_signal_connect( G_OBJECT(item->gobj()), "toggled", reinterpret_cast<GCallback>(taskToggled), GINT_TO_POINTER(count) ); + g_signal_connect( G_OBJECT(item->gobj()), "select", G_CALLBACK(sp_ui_menu_select), const_cast<gchar*>(strs[1]) ); + g_signal_connect( G_OBJECT(item->gobj()), "deselect", G_CALLBACK(sp_ui_menu_deselect), 0 ); - gtk_widget_show( item ); - gtk_menu_shell_append( GTK_MENU_SHELL(menu), item ); + item->show(); + gtk_menu_shell_append( GTK_MENU_SHELL(menu), GTK_WIDGET(item->gobj()) ); } } @@ -831,7 +828,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I { if (menus == NULL) return; if (menu == NULL) return; - GSList *group = NULL; + Gtk::RadioMenuItem::Group group; for (Inkscape::XML::Node *menu_pntr = menus; menu_pntr != NULL; @@ -863,8 +860,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I if (verb != NULL) { if (menu_pntr->attribute("radio") != NULL) { - GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, show_icon, true, group); - group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item)); + GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, show_icon, true, &group); if (menu_pntr->attribute("default") != NULL) { gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); } @@ -880,7 +876,8 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I } } else { sp_ui_menu_append_item_from_verb(GTK_MENU(menu), verb, view, show_icon); - group = NULL; + Gtk::RadioMenuItem::Group group2; + group = group2; } } else { gchar string[120]; diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index a4df8187f..ba333d0ed 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -22,6 +22,7 @@ #include <glibmm/i18n.h> #include <gtkmm/label.h> #include <gtkmm/notebook.h> +#include <gtkmm/radiobutton.h> #include "preferences.h" #include "widgets/spw-utilities.h" @@ -325,8 +326,8 @@ void ColorNotebook::_addPage(Page &page) _buttons[page_num] = gtk_radio_button_new_with_label(NULL, mode_name.c_str()); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(_buttons[page_num]), FALSE); if (page_num > 0) { - GSList *group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(_buttons[0])); - gtk_radio_button_set_group(GTK_RADIO_BUTTON(_buttons[page_num]), group); + auto g = Glib::wrap(GTK_RADIO_BUTTON(_buttons[0]))->get_group(); + Glib::wrap(GTK_RADIO_BUTTON(_buttons[page_num]))->set_group(g); } gtk_widget_show(_buttons[page_num]); gtk_box_pack_start(GTK_BOX(_buttonbox), _buttons[page_num], TRUE, TRUE, 0); diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp index 09a4a542b..fc72f00c7 100644 --- a/src/widgets/ege-adjustment-action.cpp +++ b/src/widgets/ege-adjustment-action.cpp @@ -45,6 +45,7 @@ #include <algorithm> #include <gtkmm/container.h> +#include <gtkmm/radiomenuitem.h> #include <gdk/gdkkeysyms.h> #include "icon-size.h" @@ -626,7 +627,7 @@ static void process_menu_action( GtkWidget* obj, gpointer data ) } } -static void create_single_menu_item( GCallback toggleCb, int val, GtkWidget* menu, EgeAdjustmentAction* act, GtkWidget** dst, GSList** group, gdouble num, gboolean active ) +static void create_single_menu_item( GCallback toggleCb, int val, GtkWidget* menu, EgeAdjustmentAction* act, GtkWidget** dst, Gtk::RadioMenuItem::Group *group, gdouble num, gboolean active ) { char* str = 0; EgeAdjustmentDescr* marker = 0; @@ -647,10 +648,8 @@ static void create_single_menu_item( GCallback toggleCb, int val, GtkWidget* men ((marker && marker->descr) ? ": " : ""), ((marker && marker->descr) ? marker->descr : "")); - *dst = gtk_radio_menu_item_new_with_label( *group, str ); - if ( !*group) { - *group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(*dst) ); - } + auto rmi = new Gtk::RadioMenuItem(*group,Glib::ustring(str)); + *dst = GTK_WIDGET(rmi->gobj()); if ( active ) { gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(*dst), TRUE ); } @@ -669,7 +668,7 @@ static int flush_explicit_items( std::vector<EgeAdjustmentDescr*> descriptions, GtkWidget* menu, EgeAdjustmentAction* act, GtkWidget** dst, - GSList** group, + Gtk::RadioMenuItem::Group *group, gdouble num ) { if(pos >= descriptions.size() || pos < 0) return pos; @@ -693,7 +692,7 @@ static GtkWidget* create_popup_number_menu( EgeAdjustmentAction* act ) { GtkWidget* menu = gtk_menu_new(); - GSList* group = 0; + Gtk::RadioMenuItem::Group group; GtkWidget* single = 0; std::vector<EgeAdjustmentDescr*> list = act->private_data->descriptions; int addOns = list.size() - 1; diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 0c5f3cf47..fdba2b56d 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -268,17 +268,16 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) gvs->store->clear(); /* Pick up all gradients with vectors */ - GSList *gl = NULL; + std::vector<SPGradient *> gl; if (gvs->gr) { std::vector<SPObject *> gradients = gvs->gr->document->getResourceList("gradient"); for (std::vector<SPObject *>::const_iterator it = gradients.begin(); it != gradients.end(); ++it) { SPGradient* grad = SP_GRADIENT(*it); if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) { - gl = g_slist_prepend(gl, *it); + gl.push_back(SP_GRADIENT(*it)); } } } - gl = g_slist_reverse(gl); /* Get usage count of all the gradients */ std::map<SPGradient *, gint> usageCount; @@ -288,7 +287,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) Gtk::TreeModel::Row row = *(gvs->store->append()); row[gvs->columns->name] = _("No document selected"); - } else if (!gl) { + } else if (gl.empty()) { Gtk::TreeModel::Row row = *(gvs->store->append()); row[gvs->columns->name] = _("No gradients in document"); @@ -297,11 +296,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) row[gvs->columns->name] = _("No gradient selected"); } else { - while (gl) { - SPGradient *gr; - gr = SP_GRADIENT(gl->data); - gl = g_slist_remove(gl, gr); - + for (auto gr:gl) { unsigned long hhssll = sp_gradient_to_hhssll(gr); GdkPixbuf *pixb = sp_gradient_to_pixbuf (gr, 64, 18); Glib::ustring label = gr_prepare_label(gr); @@ -312,7 +307,6 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) row[gvs->columns->refcount] = usageCount[gr]; row[gvs->columns->data] = gr; row[gvs->columns->pixbuf] = Glib::wrap(pixb); - } } @@ -333,19 +327,14 @@ unsigned long sp_gradient_to_hhssll(SPGradient *gr) return ((int)(hsl[0]*100 * 10000)) + ((int)(hsl[1]*100 * 100)) + ((int)(hsl[2]*100 * 1)); } -static GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) +static void get_all_doc_items(std::vector<SPItem*> &list, SPObject *from) { for (auto& child: from->children) { if (SP_IS_ITEM(&child)) { - list = g_slist_prepend(list, SP_ITEM(&child)); - } - - if (ingroups || SP_IS_ITEM(&child)) { - list = get_all_doc_items(list, &child, onlyvisible, onlysensitive, ingroups, exclude); + list.push_back(SP_ITEM(&child)); } + get_all_doc_items(list, &child); } - - return list; } /* @@ -377,15 +366,10 @@ void gr_get_usage_counts(SPDocument *doc, std::map<SPGradient *, gint> *mapUsage if (!doc) return; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); - bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); - bool ingroups = TRUE; - - GSList *all_list = get_all_doc_items(NULL, doc->getRoot(), onlyvisible, onlysensitive, ingroups, NULL); + std::vector<SPItem *> all_list; + get_all_doc_items(all_list, doc->getRoot()); - for (GSList *i = all_list; i != NULL; i = i->next) { - SPItem *item = SP_ITEM(i->data); + for (auto item:all_list) { if (!item->getId()) continue; SPGradient *gr = NULL; @@ -565,34 +549,29 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s GtkTreeIter iter; /* Populate the combobox store */ - GSList *sl = NULL; + std::vector<SPStop *> sl; if ( gradient->hasStops() ) { for (auto& ochild: gradient->children) { if (SP_IS_STOP(&ochild)) { - sl = g_slist_append(sl, &ochild); + sl.push_back(SP_STOP(&ochild)); } } } - if (!sl) { + if (sl.empty()) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, NULL, 1, _("No stops in gradient"), 2, NULL, -1); gtk_widget_set_sensitive (combo_box, FALSE); } else { - for (; sl != NULL; sl = sl->next){ - if (SP_IS_STOP(sl->data)){ - SPStop *stop = SP_STOP(sl->data); - Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr(); - Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32())); - GdkPixbuf *pb = cpv->toPixbuf(64, 16); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, pb, 1, repr->attribute("id"), 2, stop, -1); - gtk_widget_set_sensitive (combo_box, FALSE); - } + for (auto stop:sl) { + Inkscape::XML::Node *repr = stop->getRepr(); + Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32())); + GdkPixbuf *pb = cpv->toPixbuf(64, 16); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, pb, 1, repr->attribute("id"), 2, stop, -1); + gtk_widget_set_sensitive (combo_box, FALSE); } - gtk_widget_set_sensitive(combo_box, TRUE); } diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 27fe4b63a..4457b712d 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -23,6 +23,7 @@ #include <cstring> #include <string> +#include <vector> #include "widgets/swatch-selector.h" #include "sp-pattern.h" @@ -789,25 +790,23 @@ static void sp_psel_mesh_change(GtkWidget * /*widget*/, SPPaintSelector *psel) /** - * Returns a list of meshes in the defs of the given source document as a GSList object - * Returns NULL if there are no meshes in the document. + * Returns a list of meshes in the defs of the given source document as a vector */ -static GSList * +static std::vector<SPMeshGradient *> ink_mesh_list_get (SPDocument *source) { + std::vector<SPMeshGradient *> pl; if (source == NULL) - return NULL; + return pl; + - GSList *pl = NULL; std::vector<SPObject *> meshes = source->getResourceList("gradient"); for (std::vector<SPObject *>::const_iterator it = meshes.begin(); it != meshes.end(); ++it) { if (SP_IS_MESHGRADIENT(*it) && SP_GRADIENT(*it) == SP_GRADIENT(*it)->getArray()) { // only if this is a root mesh - pl = g_slist_prepend(pl, *it); + pl.push_back(SP_MESHGRADIENT(*it)); } } - - pl = g_slist_reverse(pl); return pl; } @@ -815,14 +814,14 @@ ink_mesh_list_get (SPDocument *source) * Adds menu items for mesh list. */ static void -sp_mesh_menu_build (GtkWidget *combo, GSList *mesh_list, SPDocument */*source*/) +sp_mesh_menu_build (GtkWidget *combo, std::vector<SPMeshGradient *> &mesh_list, SPDocument */*source*/) { GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo))); GtkTreeIter iter; - for (; mesh_list != NULL; mesh_list = mesh_list->next) { + for (auto i:mesh_list) { - Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(mesh_list->data)->getRepr(); + Inkscape::XML::Node *repr = i->getRepr(); gchar const *meshid = repr->attribute("id"); gchar const *label = meshid; @@ -847,21 +846,8 @@ sp_mesh_menu_build (GtkWidget *combo, GSList *mesh_list, SPDocument */*source*/) */ static void sp_mesh_list_from_doc(GtkWidget *combo, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*mesh_doc*/) { - GSList *pl = ink_mesh_list_get(source); - GSList *clean_pl = NULL; - - for (; pl != NULL; pl = pl->next) { - if (!SP_IS_MESHGRADIENT(pl->data)) { - continue; - } - // Add to the list of meshes we really do wish to show - clean_pl = g_slist_prepend (clean_pl, pl->data); - } - - sp_mesh_menu_build (combo, clean_pl, source); - - g_slist_free (pl); - g_slist_free (clean_pl); + std::vector<SPMeshGradient *> pl = ink_mesh_list_get(source); + sp_mesh_menu_build (combo, pl, source); } @@ -1138,24 +1124,22 @@ static void sp_psel_pattern_change(GtkWidget * /*widget*/, SPPaintSelector *psel /** - * Returns a list of patterns in the defs of the given source document as a GSList object - * Returns NULL if there are no patterns in the document. + * Returns a list of patterns in the defs of the given source document as a vector */ -static GSList * +static std::vector<SPPattern*> ink_pattern_list_get (SPDocument *source) { + std::vector<SPPattern *> pl; if (source == NULL) - return NULL; + return pl; - GSList *pl = NULL; std::vector<SPObject *> patterns = source->getResourceList("pattern"); for (std::vector<SPObject *>::const_iterator it = patterns.begin(); it != patterns.end(); ++it) { if (SP_PATTERN(*it) == SP_PATTERN(*it)->rootPattern()) { // only if this is a root pattern - pl = g_slist_prepend(pl, *it); + pl.push_back(SP_PATTERN(*it)); } } - pl = g_slist_reverse(pl); return pl; } @@ -1163,14 +1147,14 @@ ink_pattern_list_get (SPDocument *source) * Adds menu items for pattern list - derived from marker code, left hb etc in to make addition of previews easier at some point. */ static void -sp_pattern_menu_build (GtkWidget *combo, GSList *pattern_list, SPDocument */*source*/) +sp_pattern_menu_build (GtkWidget *combo, std::vector<SPPattern *> &pl, SPDocument */*source*/) { GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo))); GtkTreeIter iter; - for (; pattern_list != NULL; pattern_list = pattern_list->next) { + for (auto i=pl.rbegin(); i!=pl.rend(); ++i) { - Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(pattern_list->data)->getRepr(); + Inkscape::XML::Node *repr = (*i)->getRepr(); // label for combobox gchar const *label; @@ -1200,22 +1184,8 @@ sp_pattern_menu_build (GtkWidget *combo, GSList *pattern_list, SPDocument */*sou */ static void sp_pattern_list_from_doc(GtkWidget *combo, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*pattern_doc*/) { - GSList *pl = ink_pattern_list_get(source); - GSList *clean_pl = NULL; - - for (; pl != NULL; pl = pl->next) { - if (!SP_IS_PATTERN(pl->data)) { - continue; - } - - // Add to the list of patterns we really do wish to show - clean_pl = g_slist_prepend (clean_pl, pl->data); - } - - sp_pattern_menu_build (combo, clean_pl, source); - - g_slist_free (pl); - g_slist_free (clean_pl); + std::vector<SPPattern *> pl = ink_pattern_list_get(source); + sp_pattern_menu_build (combo, pl, source); } |
