diff options
Diffstat (limited to 'src/gui/MachinaGUI.cpp')
-rw-r--r-- | src/gui/MachinaGUI.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index 2147c27..5044dcb 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -241,15 +241,27 @@ MachinaGUI::idle_callback() } static void -erase_node(GanvNode* node, void* data) +destroy_edge(GanvEdge* edge, void* data) { - machina::Controller* controller = (machina::Controller*)data; - NodeView* const view = dynamic_cast<NodeView*>( - Glib::wrap(GANV_NODE(node))); + MachinaGUI* gui = (MachinaGUI*)data; + EdgeView* view = dynamic_cast<EdgeView*>(Glib::wrap(edge)); if (view) { - controller->erase(view->node()->id()); - //_engine->machine()->remove_node(view->node()); - //_canvas->remove_item(view); + NodeView* tail = dynamic_cast<NodeView*>(view->get_tail()); + NodeView* head = dynamic_cast<NodeView*>(view->get_head()); + gui->controller()->disconnect(tail->node()->id(), head->node()->id()); + } +} + +static void +destroy_node(GanvNode* node, void* data) +{ + MachinaGUI* gui = (MachinaGUI*)data; + NodeView* view = dynamic_cast<NodeView*>(Glib::wrap(GANV_NODE(node))); + if (view) { + const SPtr<client::ClientObject> node = view->node(); + gui->canvas()->for_each_edge_on( + GANV_NODE(view->gobj()), destroy_edge, gui); + gui->controller()->erase(node->id()); } } @@ -258,7 +270,7 @@ MachinaGUI::scrolled_window_event(GdkEvent* event) { if (event->type == GDK_KEY_PRESS) { if (event->key.keyval == GDK_Delete) { - _canvas->for_each_selected_node(erase_node, _controller.get()); + _canvas->for_each_selected_node(destroy_node, this); return true; } } |