X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftools-switch.cpp;h=f10b86f6404c1110a1af7d948043d14bff2457c3;hb=c4b828ca1807524249c2793e18be249cf2a7660d;hp=4c51f4e106a43b3cd9edae77b598916f37727ffb;hpb=2424cd391a52114584bd2517ff76f1d5f5a37c48;p=inkscape.git diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index 4c51f4e10..f10b86f64 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -43,6 +43,7 @@ #include "eraser-context.h" #include "pen-context.h" #include "pencil-context.h" +#include "lpe-tool-context.h" #include "text-context.h" #include "sp-text.h" #include "sp-flowtext.h" @@ -58,56 +59,34 @@ static char const *const tool_names[] = { NULL, - "tools.select", - "tools.nodes", - "tools.tweak", - "tools.shapes.rect", - "tools.shapes.3dbox", - "tools.shapes.arc", - "tools.shapes.star", - "tools.shapes.spiral", - "tools.freehand.pencil", - "tools.freehand.pen", - "tools.calligraphic", - "tools.text", - "tools.gradient", - "tools.zoom", - "tools.dropper", - "tools.connector", - "tools.paintbucket", - "tools.eraser", - NULL -}; - -static char const *const tool_ids[] = { - NULL, - "select", - "nodes", - "tweak", - "rect", - "3dbox", - "arc", - "star", - "spiral", - "pencil", - "pen", - "calligraphic", - "text", - "gradient", - "zoom", - "dropper", - "connector", - "paintbucket", - "eraser", + "/tools/select", + "/tools/nodes", + "/tools/tweak", + "/tools/shapes/rect", + "/tools/shapes/3dbox", + "/tools/shapes/arc", + "/tools/shapes/star", + "/tools/shapes/spiral", + "/tools/freehand/pencil", + "/tools/freehand/pen", + "/tools/calligraphic", + "/tools/text", + "/tools/gradient", + "/tools/zoom", + "/tools/dropper", + "/tools/connector", + "/tools/paintbucket", + "/tools/eraser", + "/tools/lpetool", NULL }; static int -tools_id2num(char const *id) +tools_prefpath2num(char const *id) { int i = 1; - while (tool_ids[i]) { - if (strcmp(tool_ids[i], id) == 0) + while (tool_names[i]) { + if (strcmp(tool_names[i], id) == 0) return i; else i++; } @@ -118,16 +97,16 @@ tools_id2num(char const *id) int tools_isactive(SPDesktop *dt, unsigned num) { - g_assert( num < G_N_ELEMENTS(tool_ids) ); + g_assert( num < G_N_ELEMENTS(tool_names) ); if (SP_IS_EVENT_CONTEXT(dt->event_context)) - return (!strcmp(dt->event_context->prefs_repr->attribute("id"), tool_ids[num])); + return dt->event_context->pref_observer->observed_path == tool_names[num]; else return FALSE; } int tools_active(SPDesktop *dt) { - return (tools_id2num(dt->event_context->prefs_repr->attribute("id"))); + return tools_prefpath2num(dt->event_context->pref_observer->observed_path.data()); } void @@ -246,16 +225,15 @@ tools_switch(SPDesktop *dt, int num) inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to erase.")); break; + case TOOLS_LPETOOL: + dt->set_event_context(SP_TYPE_LPETOOL_CONTEXT, tool_names[num]); + dt->activate_guides(false); + inkscape_eventcontext_set(sp_desktop_event_context(dt)); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Choose a subtool from the toolbar")); + break; } } -void -tools_switch_current(int num) -{ - SPDesktop *dt = SP_ACTIVE_DESKTOP; - if (dt) tools_switch(dt, num); -} - void tools_switch_by_item(SPDesktop *dt, SPItem *item) { if (SP_IS_RECT(item)) {