diff --git a/src/knot.cpp b/src/knot.cpp
index 6edf3d0e806a14a585a73ee4609d4829d6f87868..c8d2f2065256800e47f79d6693d8ae1d940ee642 100644 (file)
--- a/src/knot.cpp
+++ b/src/knot.cpp
*/
static void sp_knot_class_init(SPKnotClass *klass)
{
- GObjectClass *object_class = (GObjectClass *) klass;
+ GObjectClass *object_class = (GObjectClass*)klass;
parent_class = (GObjectClass*) g_type_class_peek_parent(klass);
knot->shape = SP_KNOT_SHAPE_SQUARE;
knot->mode = SP_KNOT_MODE_XOR;
knot->tip = NULL;
+ knot->_event_handler_id = 0;
knot->fill[SP_KNOT_STATE_NORMAL] = 0xffffff00;
knot->fill[SP_KNOT_STATE_MOUSEOVER] = 0xff0000ff;
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
+ if (knot->_event_handler_id > 0)
+ {
+ g_signal_handler_disconnect(G_OBJECT (knot->item), knot->_event_handler_id);
+ knot->_event_handler_id = 0;
+ }
+
if (knot->item) {
gtk_object_destroy (GTK_OBJECT (knot->item));
knot->item = NULL;
knot->tip = NULL;
}
- if (((GObjectClass *) (parent_class))->dispose) {
- (* ((GObjectClass *) (parent_class))->dispose) (object);
+ if (parent_class->dispose) {
+ (*parent_class->dispose) (object);
}
}
g_assert(knot != NULL);
g_assert(SP_IS_KNOT(knot));
+ g_object_ref(knot);
tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
gboolean consumed = FALSE;
/* Run client universal event handler, if present */
- g_signal_emit(G_OBJECT(knot), knot_signals[EVENT], 0, event, &consumed);
+ g_signal_emit(knot, knot_signals[EVENT], 0, event, &consumed);
if (consumed) {
return TRUE;
switch (event->type) {
case GDK_2BUTTON_PRESS:
if (event->button.button == 1) {
- g_signal_emit(G_OBJECT(knot), knot_signals[DOUBLECLICKED], 0, event->button.state);
+ g_signal_emit(knot, knot_signals[DOUBLECLICKED], 0, event->button.state);
grabbed = FALSE;
moved = FALSE;
sp_knot_set_flag(knot,
SP_KNOT_DRAGGING,
FALSE);
- g_signal_emit(G_OBJECT (knot),
+ g_signal_emit(knot,
knot_signals[UNGRABBED], 0,
event->button.state);
} else {
- g_signal_emit(G_OBJECT (knot),
+ g_signal_emit(knot,
knot_signals[CLICKED], 0,
event->button.state);
}
within_tolerance = false;
if (!moved) {
- g_signal_emit(G_OBJECT (knot),
+ g_signal_emit(knot,
knot_signals[GRABBED], 0,
event->motion.state);
sp_knot_set_flag(knot,
sp_knot_set_flag(knot,
SP_KNOT_DRAGGING,
FALSE);
- g_signal_emit(G_OBJECT(knot),
+ g_signal_emit(knot,
knot_signals[UNGRABBED], 0,
event->button.state);
- sp_document_undo(SP_DT_DOCUMENT(knot->desktop));
+ sp_document_undo(sp_desktop_document(knot->desktop));
knot->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Node or handle drag canceled."));
transform_escaped = true;
consumed = TRUE;
break;
}
+ g_object_unref(knot);
return consumed;
}
knot->tip = g_strdup (tip);
}
- knot->item = sp_canvas_item_new(SP_DT_CONTROLS (desktop),
+ knot->item = sp_canvas_item_new(sp_desktop_controls (desktop),
SP_TYPE_CTRL,
"anchor", GTK_ANCHOR_CENTER,
"size", 8.0,
"mode", SP_KNOT_MODE_XOR,
NULL);
- gtk_signal_connect(GTK_OBJECT(knot->item), "event",
- GTK_SIGNAL_FUNC(sp_knot_handler), knot);
+ knot->_event_handler_id = gtk_signal_connect(GTK_OBJECT(knot->item), "event",
+ GTK_SIGNAL_FUNC(sp_knot_handler), knot);
return knot;
}
gboolean done = FALSE;
- g_signal_emit(G_OBJECT (knot),
+ g_signal_emit(knot,
knot_signals[REQUEST], 0,
p,
state,
gdouble distance = NR::L2(*p - knot->pos);
- g_signal_emit(G_OBJECT(knot),
+ g_signal_emit(knot,
knot_signals[DISTANCE], 0,
p,
state,
SP_CTRL(knot->item)->moveto (*p);
}
- g_signal_emit(G_OBJECT (knot),
+ g_signal_emit(knot,
knot_signals[MOVED], 0,
p,
state);
}
/**
- * Move knot to new position, without emitting a MOVED signal. We can't be sure this artificial
- * move has moved the knot from under cursor, but it seems likely, so we clear SP_KNOT_MOUSEOVER.
+ * Move knot to new position, without emitting a MOVED signal.
*/
void sp_knot_moveto(SPKnot *knot, NR::Point *p)
{
if (knot->item) {
SP_CTRL(knot->item)->moveto (*p);
}
-
- sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, FALSE);
}
/**