diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/document-properties.cpp | 86 | ||||
| -rw-r--r-- | src/ui/dialog/filter-effects-dialog.cpp | 7 | ||||
| -rw-r--r-- | src/ui/dialog/layers.cpp | 8 | ||||
| -rw-r--r-- | src/ui/dialog/svg-fonts-dialog.cpp | 6 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 27 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 6 | ||||
| -rw-r--r-- | src/ui/tools/gradient-tool.cpp | 38 | ||||
| -rw-r--r-- | src/ui/tools/mesh-tool.cpp | 32 | ||||
| -rw-r--r-- | src/ui/tools/select-tool.cpp | 94 | ||||
| -rw-r--r-- | src/ui/tools/select-tool.h | 8 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 2 | ||||
| -rw-r--r-- | src/ui/widget/color-icc-selector.cpp | 7 |
12 files changed, 138 insertions, 183 deletions
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index b04e8ecc1..8af744fd3 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -511,17 +511,16 @@ void DocumentProperties::linkSelectedProfile() void DocumentProperties::populate_linked_profiles_box() { _LinkedProfilesListStore->clear(); - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); - if (current) { - _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); + if (! current.empty()) { + _emb_profiles_observer.set((*(current.begin()))->parent); } - while ( current ) { - SPObject* obj = SP_OBJECT(current->data); + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { + SPObject* obj = *it; Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); Gtk::TreeModel::Row row = *(_LinkedProfilesListStore->append()); row[_LinkedProfilesListColumns.nameColumn] = prof->name; // row[_LinkedProfilesListColumns.previewColumn] = "Color Preview"; - current = g_slist_next(current); } } @@ -594,10 +593,9 @@ void DocumentProperties::removeSelectedProfile(){ return; } } - - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); - while ( current ) { - SPObject* obj = SP_OBJECT(current->data); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { + SPObject* obj = *it; Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); if (!name.compare(prof->name)){ @@ -606,7 +604,6 @@ void DocumentProperties::removeSelectedProfile(){ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); break; // removing the color profile likely invalidates part of the traversed list, stop traversing here. } - current = g_slist_next(current); } populate_linked_profiles_box(); @@ -722,9 +719,9 @@ void DocumentProperties::build_cms() _LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release)); cms_create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile)); - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "defs" ); - if (current) { - _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "defs" ); + if (!current.empty()) { + _emb_profiles_observer.set((*(current.begin()))->parent); } _emb_profiles_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_linked_profiles_box)); onColorProfileSelectRow(); @@ -959,9 +956,9 @@ void DocumentProperties::build_scripting() #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) //TODO: review this observers code: - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - if (current) { - _scripts_observer.set(SP_OBJECT(current->data)->parent); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + if (! current.empty()) { + _scripts_observer.set((*(current.begin()))->parent); } _scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_script_lists)); onEmbeddedScriptSelectRow(); @@ -1174,9 +1171,9 @@ void DocumentProperties::removeExternalScript(){ } } - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - while ( current ) { - SPObject* obj = reinterpret_cast<SPObject *>(current->data); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { + SPObject* obj = *it; if (obj) { SPScript* script = dynamic_cast<SPScript *>(obj); if (script && (name == script->xlinkhref)) { @@ -1191,7 +1188,6 @@ void DocumentProperties::removeExternalScript(){ } } } - current = g_slist_next(current); } populate_script_lists(); @@ -1253,9 +1249,9 @@ void DocumentProperties::changeEmbeddedScript(){ } bool voidscript=true; - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - while ( current ) { - SPObject* obj = SP_OBJECT(current->data); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { + SPObject* obj = *it; if (id == obj->getId()){ int count=0; @@ -1279,7 +1275,6 @@ void DocumentProperties::changeEmbeddedScript(){ } } } - current = g_slist_next(current); } if (voidscript) @@ -1299,9 +1294,9 @@ void DocumentProperties::editEmbeddedScript(){ } Inkscape::XML::Document *xml_doc = SP_ACTIVE_DOCUMENT->getReprDoc(); - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - while ( current ) { - SPObject* obj = SP_OBJECT(current->data); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { + SPObject* obj = *it; if (id == obj->getId()){ //XML Tree being used directly here while it shouldn't be. @@ -1317,21 +1312,20 @@ void DocumentProperties::editEmbeddedScript(){ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_EMBEDDED_SCRIPT, _("Edit embedded script")); } } - current = g_slist_next(current); } } void DocumentProperties::populate_script_lists(){ _ExternalScriptsListStore->clear(); _EmbeddedScriptsListStore->clear(); - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - if (current) { - SPObject *obj = reinterpret_cast<SPObject *>(current->data); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + if (!current.empty()) { + SPObject *obj = *(current.begin()); g_assert(obj != NULL); _scripts_observer.set(obj->parent); } - while ( current ) { - SPObject* obj = reinterpret_cast<SPObject *>(current->data); + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { + SPObject* obj = *it; SPScript* script = dynamic_cast<SPScript *>(obj); g_assert(script != NULL); if (script->xlinkhref) @@ -1344,8 +1338,6 @@ void DocumentProperties::populate_script_lists(){ Gtk::TreeModel::Row row = *(_EmbeddedScriptsListStore->append()); row[_EmbeddedScriptsListColumns.idColumn] = obj->getId(); } - - current = g_slist_next(current); } } @@ -1364,12 +1356,11 @@ void DocumentProperties::update_gridspage() //add tabs bool grids_present = false; - for (GSList const * l = nv->grids; l != NULL; l = l->next) { - Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; - if (!grid->repr->attribute("id")) continue; // update_gridspage is called again when "id" is added - Glib::ustring name(grid->repr->attribute("id")); + for(std::vector<Inkscape::CanvasGrid *>::const_iterator it = nv->grids.begin(); it != nv->grids.end(); ++it) { + if (!(*it)->repr->attribute("id")) continue; // update_gridspage is called again when "id" is added + Glib::ustring name((*it)->repr->attribute("id")); const char *icon = NULL; - switch (grid->getGridType()) { + switch ((*it)->getGridType()) { case GRID_RECTANGULAR: icon = "grid-rectangular"; break; @@ -1379,7 +1370,7 @@ void DocumentProperties::update_gridspage() default: break; } - _grids_notebook.append_page(*grid->newWidget(), _createPageTabLabel(name, icon)); + _grids_notebook.append_page(*(*it)->newWidget(), _createPageTabLabel(name, icon)); grids_present = true; } _grids_notebook.show_all(); @@ -1639,14 +1630,9 @@ void DocumentProperties::onRemoveGrid() SPDesktop *dt = getDesktop(); SPNamedView *nv = dt->getNamedView(); Inkscape::CanvasGrid * found_grid = NULL; - int i = 0; - for (GSList const * l = nv->grids; l != NULL; l = l->next, i++) { // not a very nice fix, but works. - Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; - if (pagenum == i) { - found_grid = grid; - break; // break out of for-loop - } - } + if( pagenum < nv->grids.size()) + found_grid = nv->grids[pagenum]; + if (found_grid) { // delete the grid that corresponds with the selected tab // when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer! diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 08a58291d..e3196bf59 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1589,13 +1589,14 @@ void FilterEffectsDialog::FilterModifier::update_filters() { SPDesktop* desktop = _dialog.getDesktop(); SPDocument* document = desktop->getDocument(); - const GSList* filters = document->getResourceList("filter"); + + std::set<SPObject *> filters = document->getResourceList( "filter" ); _model->clear(); - for(const GSList *l = filters; l; l = l->next) { + for (std::set<SPObject *>::const_iterator it = filters.begin(); it != filters.end(); ++it) { Gtk::TreeModel::Row row = *_model->append(); - SPFilter* f = SP_FILTER(l->data); + SPFilter* f = SP_FILTER(*it); row[_columns.filter] = f; const gchar* lbl = f->label(); const gchar* id = f->getId(); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 3f5e80f8d..f4152e556 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -1040,14 +1040,6 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) _layersChanged(); } } -/* - 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/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 12b423602..46e045c14 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -266,12 +266,12 @@ void SvgFontsDialog::update_fonts() { SPDesktop* desktop = this->getDesktop(); SPDocument* document = desktop->getDocument(); - const GSList* fonts = document->getResourceList("font"); + std::set<SPObject *> fonts = document->getResourceList( "fonts" ); _model->clear(); - for(const GSList *l = fonts; l; l = l->next) { + for (std::set<SPObject *>::const_iterator it = fonts.begin(); it != fonts.end(); ++it) { Gtk::TreeModel::Row row = *_model->append(); - SPFont* f = SP_FONT(l->data); + SPFont* f = SP_FONT(*it); row[_columns.spfont] = f; row[_columns.svgfont] = new SvgFont(f); const gchar* lbl = f->label(); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 72677c07e..ed1cd2079 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -171,9 +171,9 @@ static void editGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ ) SPDocument *doc = desktop ? desktop->doc() : 0; if (doc) { std::string targetName(bounceTarget->def.descr); - const GSList *gradients = doc->getResourceList("gradient"); - for (const GSList *item = gradients; item; item = item->next) { - SPGradient* grad = SP_GRADIENT(item->data); + std::set<SPObject *> gradients = doc->getResourceList("gradient"); + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { + SPGradient* grad = SP_GRADIENT(*item); if ( targetName == grad->getId() ) { editGradientImpl( desktop, grad ); break; @@ -192,10 +192,10 @@ void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer us gint index = GPOINTER_TO_INT(userData); if ( doc && (index >= 0) && (static_cast<guint>(index) < popupItems.size()) ) { Glib::ustring targetName = popupItems[index]; + std::set<SPObject *> gradients = doc->getResourceList("gradient"); + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { + SPGradient* grad = SP_GRADIENT(*item); - const GSList *gradients = doc->getResourceList("gradient"); - for (const GSList *item = gradients; item; item = item->next) { - SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { grad->setSwatch(); DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, @@ -326,10 +326,10 @@ gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, g SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(wdgt); if ( dtw && dtw->desktop ) { // Pick up all gradients with vectors - const GSList *gradients = (dtw->desktop->doc())->getResourceList("gradient"); + std::set<SPObject *> gradients = (dtw->desktop->doc())->getResourceList("gradient"); gint index = 0; - for (const GSList *curr = gradients; curr; curr = curr->next) { - SPGradient* grad = SP_GRADIENT(curr->data); + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { + SPGradient* grad = SP_GRADIENT(*item); if ( grad->hasStops() && !grad->isSwatch() ) { //gl = g_slist_prepend(gl, curr->data); processed = true; @@ -923,12 +923,11 @@ static void recalcSwatchContents(SPDocument* doc, std::map<ColorItem*, SPGradient*> &gradMappings) { std::vector<SPGradient*> newList; - - const GSList *gradients = doc->getResourceList("gradient"); - for (const GSList *item = gradients; item; item = item->next) { - SPGradient* grad = SP_GRADIENT(item->data); + std::set<SPObject *> gradients = doc->getResourceList("gradient"); + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { + SPGradient* grad = SP_GRADIENT(*item); if ( grad->isSwatch() ) { - newList.push_back(SP_GRADIENT(item->data)); + newList.push_back(SP_GRADIENT(*item)); } } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 91301fb60..69b229519 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1116,9 +1116,9 @@ sp_ui_drag_data_received(GtkWidget *widget, unsigned int b = color.getB(); SPGradient* matches = 0; - const GSList *gradients = doc->getResourceList("gradient"); - for (const GSList *item = gradients; item; item = item->next) { - SPGradient* grad = SP_GRADIENT(item->data); + std::set<SPObject *> gradients = doc->getResourceList("gradient"); + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { + SPGradient* grad = SP_GRADIENT(*item); if ( color.descr == grad->getId() ) { if ( grad->hasStops() ) { matches = grad; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index bcb0b12b7..9d8101cc4 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -225,13 +225,13 @@ sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSLi std::vector<Geom::Point> coords; // for all selected draggers - for (GList *i = drag->selected; i != NULL; i = i->next) { - GrDragger *dragger = (GrDragger *) i->data; + for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end() ; ++i ) { + GrDragger *dragger = *i; // remember the coord of the dragger to reselect it later coords.push_back(dragger->point); // for all draggables of dragger - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { - GrDraggable *d = (GrDraggable *) j->data; + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { + GrDraggable *d = *j; // find the gradient SPGradient *gradient = getGradient(d->item, d->fill_or_stroke); @@ -315,9 +315,9 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc) if (g_slist_length(these_stops) == 0 && drag->numSelected() == 1) { // if a single stop is selected, add between that stop and the next one - GrDragger *dragger = (GrDragger *) drag->selected->data; - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { - GrDraggable *d = (GrDraggable *) j->data; + GrDragger *dragger = *(drag->selected.begin()); + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { + GrDraggable *d = *j; if (d->point_type == POINT_RG_FOCUS) { /* * There are 2 draggables at the center (start) of a radial gradient @@ -482,9 +482,9 @@ bool GradientTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlLine *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlLine*) l->data; + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { + line = *l; over_line |= sp_gradient_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); } } @@ -588,9 +588,9 @@ bool GradientTool::root_handler(GdkEvent* event) { bool over_line = false; - if (drag->lines) { - for (GSList *l = drag->lines; l != NULL; l = l->next) { - over_line |= sp_gradient_context_is_over_line (this, (SPItem*) l->data, Geom::Point(event->motion.x, event->motion.y)); + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end(); ++l) { + over_line |= sp_gradient_context_is_over_line (this, (SPItem*) (*l), Geom::Point(event->motion.x, event->motion.y)); } } @@ -613,12 +613,10 @@ bool GradientTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlLine *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlLine*) l->data; + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { + line = *l; over_line = sp_gradient_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); - if (over_line) - break; } } @@ -663,7 +661,7 @@ bool GradientTool::root_handler(GdkEvent* event) { } } else { // click in an empty space; do the same as Esc - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { selection->clear(); @@ -719,7 +717,7 @@ bool GradientTool::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { Inkscape::SelectionHelper::selectNone(desktop); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 56ba08789..7db4e09d8 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -332,11 +332,11 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) // Get list of selected draggers for each mesh. // For all selected draggers - for (GList *i = drag->selected; i != NULL; i = i->next) { - GrDragger *dragger = (GrDragger *) i->data; + for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { + GrDragger *dragger = *i; // For all draggables of dragger - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { - GrDraggable *d = (GrDraggable *) j->data; + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end() ; ++j) { + GrDraggable *d = *j; // Only mesh corners if( d->point_type != POINT_MG_CORNER ) continue; @@ -457,9 +457,9 @@ bool MeshTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlCurve *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlCurve*) l->data; + if (! drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); l++) { + line = (SPCtrlCurve*) (*l); over_line |= sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); } } @@ -593,9 +593,9 @@ bool MeshTool::root_handler(GdkEvent* event) { // Change cursor shape if over line bool over_line = false; - if (drag->lines) { - for (GSList *l = drag->lines; l != NULL; l = l->next) { - over_line |= sp_mesh_context_is_over_line (this, (SPItem*) l->data, Geom::Point(event->motion.x, event->motion.y)); + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() ; l++) { + over_line |= sp_mesh_context_is_over_line (this, (SPItem*)(*l), Geom::Point(event->motion.x, event->motion.y)); } } @@ -624,9 +624,9 @@ bool MeshTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlLine *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlLine*) l->data; + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); l++) { + line = (SPCtrlLine*)(*l); over_line = sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); if (over_line) { @@ -678,7 +678,7 @@ bool MeshTool::root_handler(GdkEvent* event) { } } else { // click in an empty space; do the same as Esc - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { selection->clear(); @@ -724,7 +724,7 @@ bool MeshTool::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { selection->clear(); @@ -841,7 +841,7 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - if ( drag->selected ) { + if ( !drag->selected.empty() ) { std::cout << "Deleting mesh stops not implemented yet" << std::endl; ret = TRUE; } diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index f06b03d91..2b85216d2 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -89,10 +89,6 @@ SelectTool::SelectTool() , button_press_shift(false) , button_press_ctrl(false) , button_press_alt(false) - , cycling_items(NULL) - , cycling_items_cmp(NULL) - , cycling_items_selected_before(NULL) - , cycling_cur_item(NULL) , cycling_wrap(true) , item(NULL) , grabbed(NULL) @@ -390,16 +386,16 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) { } void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed) { - if (!this->cycling_cur_item) { + if (this->cycling_cur_item == this->cycling_items.end()) { return; } Inkscape::DrawingItem *arenaitem; - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(cycling_cur_item->data)); + SPItem *item = *cycling_cur_item; g_assert(item != NULL); // Deactivate current item - if (!g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) { + if (std::find(cycling_items_selected_before.begin(), cycling_items_selected_before.end(), item) == cycling_items_selected_before.end() && selection->includes(item)) { selection->remove(item); } @@ -407,20 +403,20 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele arenaitem->setOpacity(0.3); // Find next item and activate it - GList *next; + std::vector<SPItem *>::iterator next = this->cycling_cur_item; if (scroll_event->direction == GDK_SCROLL_UP) { - next = this->cycling_cur_item->next; - if (next == NULL && this->cycling_wrap) - next = this->cycling_items; + next++; + if (next == this->cycling_items.end() && this->cycling_wrap) + next = this->cycling_items.begin(); } else { - next = this->cycling_cur_item->prev; - if (next == NULL && this->cycling_wrap) - next = g_list_last(this->cycling_items); + if(next == this->cycling_items.begin()) + next = this->cycling_items.end(); + next--; } - if (next) { + if (next!=this->cycling_items.end()) { this->cycling_cur_item = next; - item = dynamic_cast<SPItem *>(static_cast<SPObject *>(this->cycling_cur_item->data)); + item = *next; g_assert(item != NULL); } @@ -435,8 +431,8 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele } void SelectTool::sp_select_context_reset_opacities() { - for (GList *l = this->cycling_items; l != NULL; l = g_list_next(l)) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); + for (std::vector<SPItem *>::const_iterator l = this->cycling_items.begin(); l != this->cycling_items.end(); ++l ) { + SPItem *item = *l; if (item) { Inkscape::DrawingItem *arenaitem = item->get_arenaitem(desktop->dkey); arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(item->style->opacity.value)); @@ -445,14 +441,10 @@ void SelectTool::sp_select_context_reset_opacities() { } } - g_list_free(this->cycling_items); - g_list_free(this->cycling_items_selected_before); - g_list_free(this->cycling_items_cmp); - - this->cycling_items = NULL; - this->cycling_items_selected_before = NULL; - this->cycling_cur_item = NULL; - this->cycling_items_cmp = NULL; + this->cycling_items.clear(); + this->cycling_items_selected_before.clear(); + this->cycling_cur_item = this->cycling_items.end(); + this->cycling_items_cmp.clear(); } bool SelectTool::root_handler(GdkEvent* event) { @@ -819,70 +811,57 @@ bool SelectTool::root_handler(GdkEvent* event) { SPItem *item = desktop->getItemAtPoint(p, true, NULL); // Save pointer to current cycle-item so that we can find it again later, in the freshly built list - SPItem *tmp_cur_item = this->cycling_cur_item ? dynamic_cast<SPItem *>(static_cast<SPObject *>(this->cycling_cur_item->data)) : NULL; - g_list_free(this->cycling_items); - this->cycling_items = NULL; - this->cycling_cur_item = NULL; - + SPItem *tmp_cur_item = this->cycling_cur_item!=this->cycling_items.end() ? (*(this->cycling_cur_item)) : NULL; + this->cycling_items.clear(); + this->cycling_cur_item = this->cycling_items.end(); while(item != NULL) { - this->cycling_items = g_list_append(this->cycling_items, item); + this->cycling_items.push_back(item); item = desktop->getItemAtPoint(p, true, item); } /* Compare current item list with item list during previous scroll ... */ - GList *l1, *l2; - bool item_lists_differ = false; - - // Note that we can do an 'or' comparison in the loop because it is safe to call g_list_next with a NULL pointer. - for (l1 = this->cycling_items, l2 = this->cycling_items_cmp; l1 != NULL || l2 != NULL; l1 = g_list_next(l1), l2 = g_list_next(l2)) { - if ((l1 !=NULL && l2 == NULL) || (l1 == NULL && l2 != NULL) || (l1->data != l2->data)) { - item_lists_differ = true; - break; - } - } + bool item_lists_differ = this->cycling_items != this->cycling_items_cmp; /* If list of items under mouse pointer hasn't changed ... */ if (!item_lists_differ) { // ... find current item in the freshly built list and continue cycling ... // TODO: This wouldn't be necessary if cycling_cur_item pointed to an element of cycling_items_cmp instead - this->cycling_cur_item = g_list_find(this->cycling_items, tmp_cur_item); - g_assert(this->cycling_cur_item != NULL || this->cycling_items == NULL); + this->cycling_cur_item = std::find(this->cycling_items.begin(), this->cycling_items.end(), tmp_cur_item); + g_assert(this->cycling_cur_item != this->cycling_items.end() || this->cycling_items.empty()); } else { // ... otherwise reset opacities for outdated items ... Inkscape::DrawingItem *arenaitem; - for(GList *l = this->cycling_items_cmp; l != NULL; l = l->next) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); + for (std::vector<SPItem *>::const_iterator l = this->cycling_items_cmp.begin(); l != this->cycling_items_cmp.end(); ++l) { + SPItem *item = *l; if (item) { arenaitem = item->get_arenaitem(desktop->dkey); arenaitem->setOpacity(1.0); //if (!shift_pressed && !g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) - if (!g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) { + if (std::find(this->cycling_items_selected_before.begin(),this->cycling_items_selected_before.end(), item)==this->cycling_items_selected_before.end() && selection->includes(item)) { selection->remove(item); } } } // ... clear the lists ... - g_list_free(this->cycling_items_cmp); - g_list_free(this->cycling_items_selected_before); - this->cycling_items_cmp = NULL; - this->cycling_items_selected_before = NULL; - this->cycling_cur_item = NULL; + this->cycling_items_cmp.clear(); + this->cycling_items_selected_before.clear(); + this->cycling_cur_item = this->cycling_items.end(); // ... and rebuild them with the new items. - this->cycling_items_cmp = g_list_copy(this->cycling_items); + this->cycling_items_cmp = (this->cycling_items); - for(GList *l = this->cycling_items; l != NULL; l = l->next) { - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); + for(std::vector<SPItem *>::const_iterator l = this->cycling_items.begin(); l != this->cycling_items.end(); ++l) { + SPItem *item =*l; if (item) { arenaitem = item->get_arenaitem(desktop->dkey); arenaitem->setOpacity(0.3); if (selection->includes(item)) { // already selected items are stored separately, too - this->cycling_items_selected_before = g_list_append(this->cycling_items_selected_before, item); + this->cycling_items_selected_before.push_back(item); } } else { g_assert_not_reached(); @@ -890,7 +869,8 @@ bool SelectTool::root_handler(GdkEvent* event) { } // set the current item to the bottommost one so that the cycling step below re-starts at the top - this->cycling_cur_item = g_list_last(this->cycling_items); + this->cycling_cur_item = this->cycling_items.end(); + this->cycling_cur_item--; } this->cycling_wrap = prefs->getBool("/options/selection/cycleWrap", true); diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h index 5af99a56a..af183b1ca 100644 --- a/src/ui/tools/select-tool.h +++ b/src/ui/tools/select-tool.h @@ -40,10 +40,10 @@ public: bool button_press_ctrl; bool button_press_alt; - GList *cycling_items; - GList *cycling_items_cmp; - GList *cycling_items_selected_before; - GList *cycling_cur_item; + std::vector<SPItem *> cycling_items; + std::vector<SPItem *> cycling_items_cmp; + std::vector<SPItem *> cycling_items_selected_before; + std::vector<SPItem *>::iterator cycling_cur_item; bool cycling_wrap; SPItem *item; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index bf7b61b61..abac2c091 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -924,7 +924,7 @@ void ToolBase::enableGrDrag(bool enable) { */ bool ToolBase::deleteSelectedDrag(bool just_one) { - if (_grdrag && _grdrag->selected) { + if (_grdrag && !_grdrag->selected.empty()) { _grdrag->deleteSelected(just_one); return TRUE; } diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 1c31ae33a..2fe4a0704 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -676,9 +676,9 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const &name) gtk_combo_box_set_active(combo, 0); int index = 1; - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); - while (current) { - SPObject *obj = SP_OBJECT(current->data); + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { + SPObject *obj = *it; Inkscape::ColorProfile *prof = reinterpret_cast<Inkscape::ColorProfile *>(obj); gtk_list_store_append(store, &iter); @@ -690,7 +690,6 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const &name) } index++; - current = g_slist_next(current); } g_signal_handler_unblock(G_OBJECT(_profileSel), _profChangedID); |
