diff options
| author | bulia byak <buliabyak@gmail.com> | 2009-01-08 05:37:37 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2009-01-08 05:37:37 +0000 |
| commit | c57f5f4adf5e749634b1fbe3e60e40ab580019b3 (patch) | |
| tree | 2667b222ed674e61f803ffb9068133a9bbcdafe8 /src/spiral-context.cpp | |
| parent | move shape_editor from node context to the parent class, event context (diff) | |
| download | inkscape-c57f5f4adf5e749634b1fbe3e60e40ab580019b3.tar.gz inkscape-c57f5f4adf5e749634b1fbe3e60e40ab580019b3.zip | |
switch to using shape_editor, instead of separate knotholders and listeners; fixes a lot of crashes, simplifies code
(bzr r7097)
Diffstat (limited to 'src/spiral-context.cpp')
| -rw-r--r-- | src/spiral-context.cpp | 63 |
1 files changed, 11 insertions, 52 deletions
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 9944e86b4..ce9ea1e03 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -41,6 +41,7 @@ #include "xml/node-event-vector.h" #include "preferences.h" #include "context-fns.h" +#include "shape-editor.h" static void sp_spiral_context_class_init(SPSpiralContextClass * klass); static void sp_spiral_context_init(SPSpiralContext *spiral_context); @@ -104,9 +105,6 @@ sp_spiral_context_init(SPSpiralContext *spiral_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - spiral_context->item = NULL; spiral_context->revo = 3.0; @@ -127,20 +125,12 @@ sp_spiral_context_dispose(GObject *object) sc->sel_changed_connection.disconnect(); sc->sel_changed_connection.~connection(); + delete ec->shape_editor; + ec->shape_editor = NULL; + /* fixme: This is necessary because we do not grab */ if (sc->item) sp_spiral_finish(sc); - if (ec->shape_knot_holder) { - delete ec->shape_knot_holder; - ec->shape_knot_holder = NULL; - } - - if (ec->shape_repr) { // remove old listener - sp_repr_remove_listener_by_data(ec->shape_repr, ec); - Inkscape::GC::release(ec->shape_repr); - ec->shape_repr = 0; - } - if (sc->_message_context) { delete sc->_message_context; } @@ -148,14 +138,6 @@ sp_spiral_context_dispose(GObject *object) G_OBJECT_CLASS(parent_class)->dispose(object); } -static Inkscape::XML::NodeEventVector ec_shape_repr_events = { - NULL, /* child_added */ - NULL, /* child_removed */ - ec_shape_event_attr_changed, - NULL, /* content_changed */ - NULL /* order_changed */ -}; - /** \brief Callback that processes the "changed" signal on the selection; destroys old and creates new knotholder @@ -166,27 +148,9 @@ sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer dat SPSpiralContext *sc = SP_SPIRAL_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(sc); - if (ec->shape_knot_holder) { // desktroy knotholder - delete ec->shape_knot_holder; - ec->shape_knot_holder = NULL; - } - - if (ec->shape_repr) { // remove old listener - sp_repr_remove_listener_by_data(ec->shape_repr, ec); - Inkscape::GC::release(ec->shape_repr); - ec->shape_repr = 0; - } - - SPItem *item = selection->singleItem(); - if (item) { - ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop); - Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item); - if (shape_repr) { - ec->shape_repr = shape_repr; - Inkscape::GC::anchor(shape_repr); - sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec); - } - } + ec->shape_editor->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } static void @@ -201,19 +165,14 @@ sp_spiral_context_setup(SPEventContext *ec) sp_event_context_read(ec, "revolution"); sp_event_context_read(ec, "t0"); - Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); + ec->shape_editor = new ShapeEditor(ec->desktop); - SPItem *item = selection->singleItem(); + SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); if (item) { - ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop); - Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item); - if (shape_repr) { - ec->shape_repr = shape_repr; - Inkscape::GC::anchor(shape_repr); - sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec); - } + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } + Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); sc->sel_changed_connection.disconnect(); sc->sel_changed_connection = selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_spiral_context_selection_changed), (gpointer)sc)); |
