aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/Controller.cpp2
-rw-r--r--src/gui/MachinaCanvas.cpp4
-rw-r--r--src/gui/MachinaGUI.cpp28
-rw-r--r--src/gui/MachinaGUI.hpp16
4 files changed, 30 insertions, 20 deletions
diff --git a/src/engine/Controller.cpp b/src/engine/Controller.cpp
index 7d9017e..00ad9f9 100644
--- a/src/engine/Controller.cpp
+++ b/src/engine/Controller.cpp
@@ -188,7 +188,7 @@ void
Controller::erase(uint64_t id)
{
SPtr<StatefulKey> key(new StatefulKey(id));
- Objects::iterator i = _objects.find(key);
+ Objects::iterator i = _objects.find(key);
if (i == _objects.end()) {
return;
}
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index 3413a9f..6de0217 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -170,8 +170,10 @@ MachinaCanvas::on_erase_object(SPtr<client::ClientObject> object)
{
const Raul::Atom& type = object->get(URIs::instance().rdf_type);
if (type.get<URIInt>() == URIs::instance().machina_Node) {
- // Destruction of the view will remove from the canvas
+ delete object->view();
+ object->set_view(NULL);
} else if (type.get<URIInt>() == URIs::instance().machina_Edge) {
+ remove_edge(dynamic_cast<Ganv::Edge*>(object->view()));
object->set_view(NULL);
} else {
std::cerr << "Unknown object type" << std::endl;
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;
}
}
diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp
index 4bbb238..3c10cda 100644
--- a/src/gui/MachinaGUI.hpp
+++ b/src/gui/MachinaGUI.hpp
@@ -50,22 +50,18 @@ public:
explicit MachinaGUI(SPtr<machina::Engine> engine);
~MachinaGUI();
- SPtr<MachinaCanvas> canvas() { return _canvas; }
- SPtr<machina::Engine> engine() { return _engine; }
-
- Raul::Forge& forge() { return _forge; }
-
- SPtr<Raul::Maid> maid() { return _maid; }
-
- Gtk::Window* window() { return _main_window; }
+ SPtr<MachinaCanvas> canvas() { return _canvas; }
+ SPtr<machina::Engine> engine() { return _engine; }
+ SPtr<machina::Controller> controller() { return _controller; }
+ Raul::Forge& forge() { return _forge; }
+ SPtr<Raul::Maid> maid() { return _maid; }
+ Gtk::Window* window() { return _main_window; }
void attach();
void quit() { _main_window->hide(); }
bool chain_mode() const { return _chain_mode; }
- SPtr<machina::Controller> controller() { return _controller; }
-
double default_length() const {
return 1 / (double)_quantize_spinbutton->get_value();
}