summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/connector-toolbar.cpp10
-rw-r--r--src/widgets/desktop-widget.cpp6
-rw-r--r--src/widgets/gradient-toolbar.cpp63
-rw-r--r--src/widgets/gradient-vector.cpp8
-rw-r--r--src/widgets/mesh-toolbar.cpp8
-rw-r--r--src/widgets/paint-selector.cpp8
6 files changed, 49 insertions, 54 deletions
diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp
index 8cc254bd2..733fb34e8 100644
--- a/src/widgets/connector-toolbar.cpp
+++ b/src/widgets/connector-toolbar.cpp
@@ -200,17 +200,15 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
desktop->namedview->updateRepr();
bool modmade = false;
- GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop);
- for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) {
- SPItem *item = reinterpret_cast<SPItem *>(iter->data);
+ std::vector<SPItem *> items;
+ items = get_avoided_items(items, desktop->currentRoot(), desktop);
+ for (std::vector<SPItem *>::const_iterator iter = items.begin(); iter != items.end(); ++iter ) {
+ SPItem *item = *iter;
Geom::Affine m = Geom::identity();
avoid_item_move(&m, item);
modmade = true;
}
- if (items) {
- g_slist_free(items);
- }
if(modmade) {
DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
_("Change connector spacing"));
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 431b7a05d..85f58c830 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -1868,9 +1868,9 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/bitmapautoreload/value", true)) {
- GSList const *imageList = (desktop->doc())->getResourceList("image");
- for (GSList const *p = imageList; p; p = p->next) {
- SPImage* image = SP_IMAGE(p->data);
+ std::set<SPObject *> imageList = (desktop->doc())->getResourceList("image");
+ for (std::set<SPObject *>::const_iterator it = imageList.begin(); it != imageList.end(); ++it) {
+ SPImage* image = SP_IMAGE(*it);
sp_image_refresh_if_outdated( image );
}
}
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index b24615126..858aa05db 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -106,10 +106,10 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient
// GRADIENTFIXME: make this work for multiple selected draggers.
// First try selected dragger
- if (drag && drag->selected) {
- GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data);
- for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
- GrDraggable *draggable = static_cast<GrDraggable*>(i->data);
+ if (drag && !drag->selected.empty()) {
+ GrDragger *dragger = *(drag->selected.begin());
+ for(std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { //for all draggables of dragger
+ GrDraggable *draggable = *i;
gr_apply_gradient_to_item(draggable->item, gr, initialType, initialMode, draggable->fill_or_stroke);
}
return;
@@ -139,19 +139,18 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection
/* Clear old list, if there is any */
gtk_list_store_clear(store);
- GSList *gl = NULL;
- const GSList *gradients = document->getResourceList("gradient");
- for (const GSList *i = gradients; i != NULL; i = i->next) {
- SPGradient *grad = SP_GRADIENT(i->data);
+ std::vector<SPObject *> gl;
+ std::set<SPObject *> gradients = document->getResourceList( "gradient" );
+ for (std::set<SPObject *>::const_iterator it = gradients.begin(); it != gradients.end(); ++it) {
+ SPGradient *grad = SP_GRADIENT(*it);
if ( grad->hasStops() && !grad->isSolid() ) {
- gl = g_slist_prepend(gl, i->data);
+ gl.push_back(*it);
}
}
- gl = g_slist_reverse(gl);
guint pos = 0;
- if (!gl) {
+ if (gl.empty()) {
// The document has no gradients
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1);
@@ -180,9 +179,8 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection
}
guint idx = 0;
- while (gl) {
- SPGradient *gradient = SP_GRADIENT(gl->data);
- gl = g_slist_remove(gl, gradient);
+ for (std::vector<SPObject *>::const_iterator it = gl.begin(); it != gl.end(); ++it) {
+ SPGradient *gradient = SP_GRADIENT(*it);
Glib::ustring label = gr_prepare_label(gradient);
GdkPixbuf *pixb = sp_gradient_to_pixbuf(gradient, 64, 16);
@@ -255,11 +253,11 @@ void gr_read_selection( Inkscape::Selection *selection,
SPGradientSpread &spr_selected,
bool &spr_multi )
{
- if (drag && drag->selected) {
+ if (drag && !drag->selected.empty()) {
// GRADIENTFIXME: make this work for more than one selected dragger?
- GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data);
- for (GSList const* i = dragger->draggables; i; i = i->next) { // for all draggables of dragger
- GrDraggable *draggable = static_cast<GrDraggable *>(i->data);
+ GrDragger *dragger = *(drag->selected.begin());
+ for(std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { //for all draggables of dragger
+ GrDraggable *draggable = *i;
SPGradient *gradient = sp_item_gradient_get_vector(draggable->item, draggable->fill_or_stroke);
SPGradientSpread spread = sp_item_gradient_get_spread(draggable->item, draggable->fill_or_stroke);
@@ -394,10 +392,10 @@ static void gr_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe
}
InkAction *add = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_add_action");
- gtk_action_set_sensitive(GTK_ACTION(add), (gr_selected && !gr_multi && drag && drag->selected));
+ gtk_action_set_sensitive(GTK_ACTION(add), (gr_selected && !gr_multi && drag && !drag->selected.empty()));
InkAction *del = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_delete_action");
- gtk_action_set_sensitive(GTK_ACTION(del), (gr_selected && !gr_multi && drag && drag->selected));
+ gtk_action_set_sensitive(GTK_ACTION(del), (gr_selected && !gr_multi && drag && !drag->selected.empty()));
InkAction *reverse = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_reverse_action");
gtk_action_set_sensitive(GTK_ACTION(reverse), (gr_selected!= NULL));
@@ -649,7 +647,7 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool
GrDrag *drag = ev->get_drag();
- if (!drag || !drag->selected) {
+ if (!drag || drag->selected.empty()) {
blocked = TRUE;
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , 0);
gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data);
@@ -660,11 +658,10 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool
gint n = 0;
// for all selected draggers
- for (GList *i = drag->selected; i != NULL; i = i->next) {
- GrDragger *dragger = static_cast<GrDragger*>(i->data);
- // for all draggables of dragger
- for (GSList const* j = dragger->draggables; j != NULL; j = j->next) {
- GrDraggable *draggable = static_cast<GrDraggable*>(j->data);
+ for(std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { //for all draggables of dragger
+ GrDragger *dragger = *i;
+ for(std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { //for all draggables of dragger
+ GrDraggable *draggable = *j;
if (draggable->point_type != POINT_RG_FOCUS) {
n++;
@@ -766,25 +763,25 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S
}
/* Populate the combobox store */
- GSList *sl = NULL;
+ std::vector<SPObject *> sl;
if ( gradient->hasStops() ) {
for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
- sl = g_slist_append(sl, ochild);
+ sl.push_back(ochild);
}
}
}
- if (!sl) {
+ if (sl.empty()) {
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, _("No stops in gradient"), 1, NULL, 2, NULL, -1);
sensitive = 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();
+ for (std::vector<SPObject *>::const_iterator it = sl.begin(); it != sl.end(); ++it) {
+ if (SP_IS_STOP(*it)){
+ SPStop *stop = SP_STOP(*it);
+ Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(*it)->getRepr();
Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32()));
GdkPixbuf *pb = cpv->toPixbuf(32, 16);
Glib::ustring label = gr_ellipsize_text(repr->attribute("id"), 25);
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 8e92f589a..35c1e4a8d 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -298,11 +298,11 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)
/* Pick up all gradients with vectors */
GSList *gl = NULL;
if (gvs->gr) {
- const GSList *gradients = gvs->gr->document->getResourceList("gradient");
- for (const GSList *curr = gradients; curr; curr = curr->next) {
- SPGradient* grad = SP_GRADIENT(curr->data);
+ std::set<SPObject *> gradients = gvs->gr->document->getResourceList("gradient");
+ for (std::set<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, curr->data);
+ gl = g_slist_prepend(gl, *it);
}
}
}
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 9937b23ed..3643ce00c 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -433,14 +433,14 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
/* Number of mesh rows */
{
- gchar const* labels[] = {};
+ gchar const** labels = NULL;
gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
eact = create_adjustment_action( "MeshRowAction",
_("Rows"), _("Rows:"), _("Number of rows in new mesh"),
"/tools/mesh/mesh_rows", 1,
GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
- labels, values, G_N_ELEMENTS(labels),
+ labels, values, 0,
ms_row_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
@@ -449,14 +449,14 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
/* Number of mesh columns */
{
- gchar const* labels[] = {};
+ gchar const** labels = NULL;
gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
eact = create_adjustment_action( "MeshColumnAction",
_("Columns"), _("Columns:"), _("Number of columns in new mesh"),
"/tools/mesh/mesh_cols", 1,
GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
- labels, values, G_N_ELEMENTS(labels),
+ labels, values, 0,
ms_col_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index d8d314834..602cad3c3 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -844,10 +844,10 @@ ink_pattern_list_get (SPDocument *source)
return NULL;
GSList *pl = NULL;
- GSList const *patterns = source->getResourceList("pattern");
- for (GSList *l = const_cast<GSList *>(patterns); l != NULL; l = l->next) {
- if (SP_PATTERN(l->data) == SP_PATTERN(l->data)->rootPattern()) { // only if this is a root pattern
- pl = g_slist_prepend(pl, l->data);
+ std::set<SPObject *> patterns = source->getResourceList("pattern");
+ for (std::set<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);
}
}