diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-08-18 00:44:51 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-08-18 00:44:51 +0000 |
| commit | a62257d36b6957055ad3ddc0f5573a36f01bdbcc (patch) | |
| tree | 8d11766be4474a0d54ff586f7fa0b5fd93771fbe /src/widgets/toolbox.cpp | |
| parent | Let acceptsNumClicks() distinguish between invalid LPE and valid ones that ex... (diff) | |
| download | inkscape-a62257d36b6957055ad3ddc0f5573a36f01bdbcc.tar.gz inkscape-a62257d36b6957055ad3ddc0f5573a36f01bdbcc.zip | |
Apply a geometric construction directly to selected item if the LPE supports it
(bzr r6678)
Diffstat (limited to 'src/widgets/toolbox.cpp')
| -rw-r--r-- | src/widgets/toolbox.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 5a1690492..ad6c213f1 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -4791,23 +4791,38 @@ static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* main // this is called when the mode is changed via the toolbar (i.e., one of the subtool buttons is pressed) static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl) { + g_print ("sp_lpetool_mode_changed()\n"); using namespace Inkscape::LivePathEffect; SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop"); + SPEventContext *ec = desktop->event_context; + if (!SP_IS_LPETOOL_CONTEXT(ec)) { + g_print ("event context is not a LPEToolContext!\n"); + return; + } // only take action if run by the attr_changed listener if (!g_object_get_data(tbl, "freeze")) { // in turn, prevent listener from responding g_object_set_data(tbl, "freeze", GINT_TO_POINTER(TRUE)); - // TODO: how can we set *all* actions inactive (such that no sutool is activated?) - gint lpeToolMode = ege_select_one_action_get_active(act); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - prefs_set_int_attribute( "tools.lpetool", "mode", lpeToolMode ); + gint mode = ege_select_one_action_get_active(act); + EffectType type = lpesubtools[mode]; + + SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context); + bool success = lpetool_try_construction(lc, type); + if (success) { + // since the construction was already performed, we set the state back to inactive + ege_select_one_action_set_active(act, 0); + mode = 0; + } else { + // switch to the chosen subtool + SP_LPETOOL_CONTEXT(desktop->event_context)->mode = type; } - EffectType type = lpesubtools[lpeToolMode]; - SP_LPETOOL_CONTEXT(desktop->event_context)->mode = type; + if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { + prefs_set_int_attribute( "tools.lpetool", "mode", mode ); + } g_object_set_data(tbl, "freeze", GINT_TO_POINTER(FALSE)); } |
