summaryrefslogtreecommitdiffstats
path: root/src/flood-context.cpp
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2009-01-08 05:37:37 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2009-01-08 05:37:37 +0000
commitc57f5f4adf5e749634b1fbe3e60e40ab580019b3 (patch)
tree2667b222ed674e61f803ffb9068133a9bbcdafe8 /src/flood-context.cpp
parentmove shape_editor from node context to the parent class, event context (diff)
downloadinkscape-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/flood-context.cpp')
-rw-r--r--src/flood-context.cpp48
1 files changed, 10 insertions, 38 deletions
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index a45ec5dfe..7b6223384 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -46,6 +46,7 @@
#include "preferences.h"
#include "context-fns.h"
#include "rubberband.h"
+#include "shape-editor.h"
#include "display/nr-arena-item.h"
#include "display/nr-arena.h"
@@ -133,9 +134,6 @@ static void sp_flood_context_init(SPFloodContext *flood_context)
event_context->within_tolerance = false;
event_context->item_to_select = NULL;
- event_context->shape_repr = NULL;
- event_context->shape_knot_holder = NULL;
-
flood_context->item = NULL;
new (&flood_context->sel_changed_connection) sigc::connection();
@@ -149,17 +147,14 @@ static void sp_flood_context_dispose(GObject *object)
rc->sel_changed_connection.disconnect();
rc->sel_changed_connection.~connection();
+ delete ec->shape_editor;
+ ec->shape_editor = NULL;
+
/* fixme: This is necessary because we do not grab */
if (rc->item) {
sp_flood_finish(rc);
}
- 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 (rc->_message_context) {
delete rc->_message_context;
}
@@ -167,14 +162,6 @@ static void sp_flood_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
@@ -184,21 +171,9 @@ void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer
SPFloodContext *rc = SP_FLOOD_CONTEXT(data);
SPEventContext *ec = SP_EVENT_CONTEXT(rc);
- 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) {
- 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_flood_context_setup(SPEventContext *ec)
@@ -209,14 +184,11 @@ static void sp_flood_context_setup(SPEventContext *ec)
((SPEventContextClass *) parent_class)->setup(ec);
}
+ ec->shape_editor = new ShapeEditor(ec->desktop);
+
SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
if (item) {
- 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);
}
rc->sel_changed_connection.disconnect();