summaryrefslogtreecommitdiffstats
path: root/src/selection-describer.cpp
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/selection-describer.cpp
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/selection-describer.cpp')
-rw-r--r--src/selection-describer.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp
index f7814fd57..0625c4002 100644
--- a/src/selection-describer.cpp
+++ b/src/selection-describer.cpp
@@ -40,14 +40,14 @@
#include "sp-spiral.h"
// Returns a list of terms for the items to be used in the statusbar
-char* collect_terms (GSList *items)
+char* collect_terms (const SelContainer &items)
{
GSList *check = NULL;
std::stringstream ss;
bool first = true;
- for (GSList *i = (GSList *)items; i != NULL; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data));
+ for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
+ SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(*iter));
if (item) {
const char *term = item->displayName();
if (term != NULL && g_slist_find (check, term) == NULL) {
@@ -61,12 +61,12 @@ char* collect_terms (GSList *items)
}
// Returns the number of terms in the list
-static int count_terms (GSList *items)
+static int count_terms (const SelContainer &items)
{
GSList *check = NULL;
int count=0;
- for (GSList *i = (GSList *)items; i != NULL; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data));
+ for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
+ SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(*iter));
if (item) {
const char *term = item->displayName();
if (term != NULL && g_slist_find (check, term) == NULL) {
@@ -79,11 +79,11 @@ static int count_terms (GSList *items)
}
// Returns the number of filtered items in the list
-static int count_filtered (GSList *items)
+static int count_filtered (const SelContainer &items)
{
int count=0;
- for (GSList *i = items; i != NULL; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>((i->data)));
+ for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
+ SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>((*iter)));
if (item) {
count += item->isFiltered();
}
@@ -122,12 +122,12 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin
}
void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) {
- GSList const *items = selection->itemList();
+ SelContainer const items = selection->itemList();
- if (!items) { // no items
+ if (items.empty()) { // no items
_context.set(Inkscape::NORMAL_MESSAGE, _when_nothing);
} else {
- SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(items->data));
+ SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(items.front()));
g_assert(item != NULL);
SPObject *layer = selection->layers()->layerForObject(item);
SPObject *root = selection->layers()->currentRoot();
@@ -188,7 +188,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
g_free (layer_name);
g_free (parent_name);
- if (!items->next) { // one item
+ if (items.size()==1) { // one item
char *item_desc = item->detailedDescription();
bool isUse = dynamic_cast<SPUse *>(item) != NULL;
@@ -228,9 +228,9 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
g_free(item_desc);
} else { // multiple items
- int objcount = g_slist_length((GSList *)items);
- char *terms = collect_terms ((GSList *)items);
- int n_terms = count_terms((GSList *)items);
+ int objcount = items.size();
+ char *terms = collect_terms (items);
+ int n_terms = count_terms(items);
gchar *objects_str = g_strdup_printf(ngettext(
"<b>%i</b> objects selected of type %s",
@@ -241,7 +241,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
// indicate all, some, or none filtered
gchar *filt_str = NULL;
- int n_filt = count_filtered((GSList *)items); //all filtered
+ int n_filt = count_filtered(items); //all filtered
if (n_filt) {
filt_str = g_strdup_printf(ngettext("; <i>%d filtered object</i> ",
"; <i>%d filtered objects</i> ", n_filt), n_filt);