From c891194f5509c6f48a09f7be11829d59ff9754d0 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sat, 3 Mar 2007 22:04:04 +0000 Subject: [PATCH] verbify esc to deselect; enable esc and ctrl-z to cancel drawing in calligraphic --- share/keys/default.xml | 2 +- share/keys/inkscape.xml | 2 +- src/draw-context.cpp | 4 ---- src/dyna-draw-context.cpp | 36 ++++++++++++++++++++++++++++++++++-- src/flood-context.cpp | 2 -- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/share/keys/default.xml b/share/keys/default.xml index 39737a82a..077742e4c 100644 --- a/share/keys/default.xml +++ b/share/keys/default.xml @@ -299,7 +299,7 @@ override) the bindings in the main default.xml. - + diff --git a/share/keys/inkscape.xml b/share/keys/inkscape.xml index 39737a82a..077742e4c 100644 --- a/share/keys/inkscape.xml +++ b/share/keys/inkscape.xml @@ -299,7 +299,7 @@ override) the bindings in the main default.xml. - + diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 028d889d9..9390834d1 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -217,10 +217,6 @@ sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event) switch (event->type) { case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Escape: - sp_desktop_selection(desktop)->clear(); - ret = TRUE; - break; case GDK_Up: case GDK_Down: case GDK_KP_Up: diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 1ec0d7fde..ba44df3ce 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -487,6 +487,27 @@ sp_ddc_update_toolbox (SPDesktop *desktop, const gchar *id, double value) desktop->setToolboxAdjustmentValue (id, value); } +static void +calligraphic_cancel(SPDynaDrawContext *dc) +{ + SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop; + dc->dragging = FALSE; + dc->is_drawing = false; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0); + /* Remove all temporary line segments */ + while (dc->segments) { + gtk_object_destroy(GTK_OBJECT(dc->segments->data)); + dc->segments = g_slist_remove(dc->segments, dc->segments->data); + } + /* reset accumulated curve */ + sp_curve_reset(dc->accumulated); + clear_current(dc); + if (dc->repr) { + dc->repr = NULL; + } +} + + gint sp_dyna_draw_context_root_handler(SPEventContext *event_context, GdkEvent *event) @@ -635,9 +656,20 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, } break; case GDK_Escape: - sp_desktop_selection(desktop)->clear(); + if (dc->is_drawing) { + // if drawing, cancel, otherwise pass it up for deselecting + calligraphic_cancel (dc); + ret = TRUE; + } + break; + case GDK_z: + case GDK_Z: + if (MOD__CTRL_ONLY && dc->is_drawing) { + // if drawing, cancel, otherwise pass it up for undo + calligraphic_cancel (dc); + ret = TRUE; + } break; - default: break; } diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 4c9406e67..6c90dff26 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -643,8 +643,6 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven if (!MOD__CTRL_ONLY) ret = TRUE; break; - case GDK_Escape: - sp_desktop_selection(desktop)->clear(); default: break; } -- 2.30.2