summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-01-02 09:41:30 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-01-02 09:41:30 +0000
commit169dff19d4da8d76e69b8e896aa25b0013639c03 (patch)
treea0c070fa95188b5cde708ac285e6a2db9df4a83f /src/widgets
parentAvoid creating a new document before opening an old document. (diff)
downloadinkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.tar.gz
inkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.zip
modernize loops
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/desktop-widget.cpp4
-rw-r--r--src/widgets/ege-paint-def.cpp12
-rw-r--r--src/widgets/fill-style.cpp42
-rw-r--r--src/widgets/gradient-selector.cpp32
-rw-r--r--src/widgets/stroke-marker-selector.cpp5
-rw-r--r--src/widgets/toolbox.cpp8
6 files changed, 51 insertions, 52 deletions
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 50f3b02f5..3a96da37e 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -197,8 +197,8 @@ void CMSPrefWatcher::hook(EgeColorProfTracker * /*tracker*/, gint /*monitor*/, C
void CMSPrefWatcher::_refreshAll()
{
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- for ( std::list<SPDesktopWidget*>::iterator it = _widget_list.begin(); it != _widget_list.end(); ++it ) {
- (*it)->requestCanvasUpdate();
+ for (auto & it : _widget_list) {
+ it->requestCanvasUpdate();
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
}
diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp
index 7cc951c4a..fa654cb72 100644
--- a/src/widgets/ege-paint-def.cpp
+++ b/src/widgets/ege-paint-def.cpp
@@ -263,11 +263,11 @@ bool PaintDef::fromMIMEData(std::string const & type, char const * data, int len
}
if ( changed ) {
// beware of callbacks changing things
- for ( std::vector<HookData*>::iterator it = _listeners.begin(); it != _listeners.end(); ++it )
+ for (auto & _listener : _listeners)
{
- if ( (*it)->_cb )
+ if ( _listener->_cb )
{
- (*it)->_cb( (*it)->_data );
+ _listener->_cb( _listener->_data );
}
}
}
@@ -282,11 +282,11 @@ void PaintDef::setRGB( unsigned int r, unsigned int g, unsigned int b )
this->b = b;
// beware of callbacks changing things
- for ( std::vector<HookData*>::iterator it = _listeners.begin(); it != _listeners.end(); ++it )
+ for (auto & _listener : _listeners)
{
- if ( (*it)->_cb )
+ if ( _listener->_cb )
{
- (*it)->_cb( (*it)->_data );
+ _listener->_cb( _listener->_data );
}
}
}
diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp
index f4d439f29..f8eb00d7a 100644
--- a/src/widgets/fill-style.cpp
+++ b/src/widgets/fill-style.cpp
@@ -574,39 +574,39 @@ void FillNStroke::updateFromPaint()
}
}
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
+ for(auto item : items){
//FIXME: see above
if (kind == FILL) {
- sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
+ sp_repr_css_change_recursive(item->getRepr(), css, "style");
}
if (!vector) {
SPGradient *gr = sp_gradient_vector_for_object( document,
desktop,
- reinterpret_cast<SPObject*>(*i),
+ reinterpret_cast<SPObject*>(item),
(kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE,
createSwatch );
if ( gr && createSwatch ) {
gr->setSwatch();
}
- sp_item_set_gradient(*i,
+ sp_item_set_gradient(item,
gr,
gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE);
} else {
- sp_item_set_gradient(*i, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE);
+ sp_item_set_gradient(item, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE);
}
}
} else {
// We have changed from another gradient type, or modified spread/units within
// this gradient type.
vector = sp_gradient_ensure_vector_normalized(vector);
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
+ for(auto item : items){
//FIXME: see above
if (kind == FILL) {
- sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
+ sp_repr_css_change_recursive(item->getRepr(), css, "style");
}
- SPGradient *gr = sp_item_set_gradient(*i, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE);
+ SPGradient *gr = sp_item_set_gradient(item, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE);
psel->pushAttrsToGradient( gr );
}
}
@@ -639,16 +639,16 @@ void FillNStroke::updateFromPaint()
SPMeshGradient * mesh = psel->getMeshGradient();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
+ for(auto item : items){
//FIXME: see above
if (kind == FILL) {
- sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
+ sp_repr_css_change_recursive(item->getRepr(), css, "style");
}
// Check if object already has mesh.
bool has_mesh = false;
- SPStyle *style = (*i)->style;
+ SPStyle *style = item->style;
if (style) {
SPPaintServer *server =
(kind==FILL) ? style->getFillPaintServer():style->getStrokePaintServer();
@@ -672,11 +672,11 @@ void FillNStroke::updateFromPaint()
// Get corresponding object
SPMeshGradient *mg = static_cast<SPMeshGradient *>(document->getObjectByRepr(repr));
- mg->array.create(mg, *i, (kind==FILL) ?
- (*i)->geometricBounds() : (*i)->visualBounds());
+ mg->array.create(mg, item, (kind==FILL) ?
+ item->geometricBounds() : item->visualBounds());
- bool isText = SP_IS_TEXT(*i);
- sp_style_set_property_url (*i, ((kind == FILL) ? "fill":"stroke"),
+ bool isText = SP_IS_TEXT(item);
+ sp_style_set_property_url (item, ((kind == FILL) ? "fill":"stroke"),
mg, isText);
// (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG|SP_OBJECT_STYLE_MODIFIED_FLAG);
@@ -702,11 +702,11 @@ void FillNStroke::updateFromPaint()
mg->array.read(mg);
Geom::OptRect item_bbox = (kind==FILL) ?
- (*i)->geometricBounds() : (*i)->visualBounds();
+ item->geometricBounds() : item->visualBounds();
mg->array.fill_box( item_bbox );
- bool isText = SP_IS_TEXT(*i);
- sp_style_set_property_url (*i, ((kind == FILL) ? "fill":"stroke"),
+ bool isText = SP_IS_TEXT(item);
+ sp_style_set_property_url (item, ((kind == FILL) ? "fill":"stroke"),
mg, isText);
}
}
@@ -747,12 +747,12 @@ void FillNStroke::updateFromPaint()
// cannot just call sp_desktop_set_style, because we don't want to touch those
// objects who already have the same root pattern but through a different href
// chain. FIXME: move this to a sp_item_set_pattern
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
- Inkscape::XML::Node *selrepr = (*i)->getRepr();
+ for(auto item : items){
+ Inkscape::XML::Node *selrepr = item->getRepr();
if ( (kind == STROKE) && !selrepr) {
continue;
}
- SPObject *selobj = *i;
+ SPObject *selobj = item;
SPStyle *style = selobj->style;
if (style && ((kind == FILL) ? style->fill : style->stroke).isPaintserver()) {
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index e35424430..b4a58fe4d 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -251,13 +251,13 @@ void SPGradientSelector::setMode(SelectorMode mode)
if (mode != this->mode) {
this->mode = mode;
if (mode == MODE_SWATCH) {
- for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ for (auto & it : nonsolid)
{
- gtk_widget_hide(*it);
+ gtk_widget_hide(it);
}
- for (std::vector<GtkWidget*>::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it)
+ for (auto & swatch_widget : swatch_widgets)
{
- gtk_widget_show_all(*it);
+ gtk_widget_show_all(swatch_widget);
}
Gtk::TreeView::Column* icon_column = treeview->get_column(0);
@@ -266,13 +266,13 @@ void SPGradientSelector::setMode(SelectorMode mode)
SPGradientVectorSelector* vs = SP_GRADIENT_VECTOR_SELECTOR(vectors);
vs->setSwatched();
} else {
- for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ for (auto & it : nonsolid)
{
- gtk_widget_show_all(*it);
+ gtk_widget_show_all(it);
}
- for (std::vector<GtkWidget*>::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it)
+ for (auto & swatch_widget : swatch_widgets)
{
- gtk_widget_hide(*it);
+ gtk_widget_hide(swatch_widget);
}
Gtk::TreeView::Column* icon_column = treeview->get_column(0);
icon_column->set_title(_("Gradient"));
@@ -411,25 +411,25 @@ void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector)
if (vector) {
if ( (mode == MODE_SWATCH) && vector->isSwatch() ) {
if ( vector->isSolid() ) {
- for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ for (auto & it : nonsolid)
{
- gtk_widget_hide(*it);
+ gtk_widget_hide(it);
}
} else {
- for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ for (auto & it : nonsolid)
{
- gtk_widget_show_all(*it);
+ gtk_widget_show_all(it);
}
}
} else if (mode != MODE_SWATCH) {
- for (std::vector<GtkWidget*>::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it)
+ for (auto & swatch_widget : swatch_widgets)
{
- gtk_widget_hide(*it);
+ gtk_widget_hide(swatch_widget);
}
- for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ for (auto & it : nonsolid)
{
- gtk_widget_show_all(*it);
+ gtk_widget_show_all(it);
}
}
diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp
index 8ab358ce3..5bfebb799 100644
--- a/src/widgets/stroke-marker-selector.cpp
+++ b/src/widgets/stroke-marker-selector.cpp
@@ -421,9 +421,8 @@ MarkerComboBox::update_marker_image(gchar const *mname)
}
sandbox->getRoot()->invoke_hide(visionkey);
- for(Gtk::TreeIter iter = marker_store->children().begin();
- iter != marker_store->children().end(); ++iter) {
- Gtk::TreeModel::Row row = (*iter);
+ for(const auto & iter : marker_store->children()) {
+ Gtk::TreeModel::Row row = iter;
if (row[marker_columns.marker] && row[marker_columns.history] &&
!strcmp(row[marker_columns.marker], mname)) {
row[marker_columns.image] = prv;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index fe105aea6..ddf395ccd 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -357,8 +357,8 @@ void VerbAction::set_active(bool active)
{
this->active = active;
Glib::SListHandle<Gtk::Widget*> proxies = get_proxies();
- for ( Glib::SListHandle<Gtk::Widget*>::iterator it = proxies.begin(); it != proxies.end(); ++it ) {
- Gtk::ToolItem* ti = dynamic_cast<Gtk::ToolItem*>(*it);
+ for (auto proxie : proxies) {
+ Gtk::ToolItem* ti = dynamic_cast<Gtk::ToolItem*>(proxie);
if (ti) {
// *should* have one child that is the Inkscape::UI::Widget::Button
auto child = dynamic_cast<Inkscape::UI::Widget::Button *>(ti->get_child());
@@ -607,8 +607,8 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
desktop->connectDestroy(&desktopDestructHandler);
}
- for ( guint i = 0; i < G_N_ELEMENTS(verbsToUse); i++ ) {
- Inkscape::Verb* verb = Inkscape::Verb::get(verbsToUse[i]);
+ for (int i : verbsToUse) {
+ Inkscape::Verb* verb = Inkscape::Verb::get(i);
if ( verb ) {
if (!mainActions->get_action(verb->get_id())) {
GtkAction* act = create_action_for_verb( verb, view, toolboxSize );