summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ganv/Node.hpp10
-rw-r--r--src/Canvas.cpp12
-rw-r--r--src/ganv-private.h10
-rw-r--r--src/node.c22
4 files changed, 44 insertions, 10 deletions
diff --git a/ganv/Node.hpp b/ganv/Node.hpp
index f83f11f..c36a8db 100644
--- a/ganv/Node.hpp
+++ b/ganv/Node.hpp
@@ -36,7 +36,9 @@ class Node : public Item {
public:
Node(Canvas* canvas, GanvNode* gobj)
: Item(GNOME_CANVAS_ITEM(g_object_ref(gobj)))
- {}
+ {
+ g_signal_connect(gobj, "moved", G_CALLBACK(on_moved), this);
+ }
~Node() {
g_object_unref(_gobj);
@@ -71,7 +73,11 @@ public:
METHOD0(ganv_node, disconnect);
- sigc::signal<void> signal_moved;
+ sigc::signal<void, double, double> signal_moved;
+
+ static void on_moved(GanvNode* node, double x, double y) {
+ Glib::wrap(node)->signal_moved.emit(x, y);
+ }
};
} // namespace Ganv
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index 5c0c082..9f326a9 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -45,6 +45,7 @@
#include "ganv/node.h"
#include "./color.h"
+#include "./ganv-private.h"
#ifdef HAVE_AGRAPH
# include <gvc.h>
@@ -310,7 +311,9 @@ GanvCanvasImpl::selection_move_finished()
{
FOREACH_ITEM(_selected_items, i) {
std::cerr << "FIXME: selection move finished" << std::endl;
- //Glib::wrap(*i)->signal_moved.emit();
+ double x, y;
+ g_object_get(*i, "x", &x, "y", &y, NULL);
+ g_signal_emit(*i, signal_moved, 0, x, y, NULL);
}
}
@@ -1106,9 +1109,6 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
} else if (!port->is_input) {
port_dragging = true;
}
- } else {
- // FIXME
- //return Glib::wrap(port)->on_click(&event->button);
}
break;
@@ -1645,7 +1645,9 @@ Canvas::arrange(bool use_length_hints)
FOREACH_ITEM(impl()->_items, i) {
std::cerr << "FIXME: arrange moved" << std::endl;
- Glib::wrap((*i))->signal_moved.emit();
+ double x, y;
+ g_object_get(*i, "x", &x, "y", &y, NULL);
+ g_signal_emit(*i, signal_moved, 0, x, y, NULL);
}
#endif
}
diff --git a/src/ganv-private.h b/src/ganv-private.h
index e90e4e8..b7e6eae 100644
--- a/src/ganv-private.h
+++ b/src/ganv-private.h
@@ -16,6 +16,12 @@
#ifndef GANV_PRIVATE_H
#define GANV_PRIVATE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern guint signal_moved;
+
void
ganv_canvas_add_node(GanvCanvas* canvas,
GanvNode* node);
@@ -64,4 +70,8 @@ ganv_canvas_port_event(GanvCanvas* canvas,
GanvPort* port,
GdkEvent* event);
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
#endif /* GANV_PRIVATE_H */
diff --git a/src/node.c b/src/node.c
index 87dc482..b9efb42 100644
--- a/src/node.c
+++ b/src/node.c
@@ -23,6 +23,8 @@
#include "./ganv-private.h"
#include "./gettext.h"
+guint signal_moved;
+
G_DEFINE_TYPE(GanvNode, ganv_node, GNOME_TYPE_CANVAS_GROUP)
static GnomeCanvasGroupClass* parent_class;
@@ -373,9 +375,13 @@ ganv_node_default_on_event(GanvNode* node,
gnome_canvas_item_ungrab(GNOME_CANVAS_ITEM(node), event->button.time);
dragging = FALSE;
if (event->button.x != drag_start_x || event->button.y != drag_start_y) {
- // Dragged
- // FIXME: emit moved signal
- ganv_canvas_selection_move_finished(canvas);
+ if (selected) {
+ ganv_canvas_selection_move_finished(canvas);
+ } else {
+ double x, y;
+ g_object_get(node, "x", &x, "y", &y, NULL);
+ g_signal_emit(node, signal_moved, 0, x, y, NULL);
+ }
} else {
// Clicked
if (selected) {
@@ -555,6 +561,16 @@ to its partner."),
0,
G_PARAM_READWRITE));
+ signal_moved = g_signal_new("moved",
+ ganv_node_get_type(),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_DOUBLE,
+ G_TYPE_DOUBLE,
+ 0);
+
object_class->destroy = ganv_node_destroy;
item_class->realize = ganv_node_realize;