diff options
author | David Robillard <d@drobilla.net> | 2011-12-08 01:19:22 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-12-08 01:19:22 +0000 |
commit | 3382158d77d904bfdec50c30c3dfdec22d46df3b (patch) | |
tree | 359ab8beb3f7fb044216c4ea6378c6e32729dc14 /src | |
parent | 1acfac387f6851c881ef89ba4728d69a9e115b22 (diff) | |
download | ganv-3382158d77d904bfdec50c30c3dfdec22d46df3b.tar.gz ganv-3382158d77d904bfdec50c30c3dfdec22d46df3b.tar.bz2 ganv-3382158d77d904bfdec50c30c3dfdec22d46df3b.zip |
Fix node moving (inform user via "moved" signal).
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3833 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/Canvas.cpp | 12 | ||||
-rw-r--r-- | src/ganv-private.h | 10 | ||||
-rw-r--r-- | src/node.c | 22 |
3 files changed, 36 insertions, 8 deletions
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 */ @@ -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; |