diff options
Diffstat (limited to 'src/arc-context.cpp')
| -rw-r--r-- | src/arc-context.cpp | 59 |
1 files changed, 9 insertions, 50 deletions
diff --git a/src/arc-context.cpp b/src/arc-context.cpp index d7982e979..3c8a50192 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -40,6 +40,7 @@ #include "desktop-style.h" #include "context-fns.h" #include "verbs.h" +#include "shape-editor.h" #include "arc-context.h" @@ -103,9 +104,6 @@ static void sp_arc_context_init(SPArcContext *arc_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - arc_context->item = NULL; new (&arc_context->sel_changed_connection) sigc::connection(); @@ -121,16 +119,8 @@ static void sp_arc_context_dispose(GObject *object) ac->sel_changed_connection.disconnect(); ac->sel_changed_connection.~connection(); - 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; - } + delete ec->shape_editor; + ec->shape_editor = NULL; /* fixme: This is necessary because we do not grab */ if (ac->item) { @@ -142,14 +132,6 @@ static void sp_arc_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. @@ -159,27 +141,9 @@ void sp_arc_context_selection_changed(Inkscape::Selection * selection, gpointer SPArcContext *ac = SP_ARC_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(ac); - 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 ? selection->singleItem() : NULL; - 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 sp_arc_context_setup(SPEventContext *ec) @@ -191,16 +155,11 @@ static void sp_arc_context_setup(SPEventContext *ec) ((SPEventContextClass *) parent_class)->setup(ec); } - SPItem *item = selection->singleItem(); + ec->shape_editor = new ShapeEditor(ec->desktop); + 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); } ac->sel_changed_connection.disconnect(); |
