From c36a1de9d1b762355bbed31ab9b6672dc90aec43 Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Tue, 28 May 2019 15:08:01 +0100 Subject: Hackfest2019: Get rid of deprecated InkSelectOneAction --- src/ui/tools/tweak-tool.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/ui/tools/tweak-tool.cpp') diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index b8cf5549c..42e3520a0 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -74,6 +74,8 @@ #include "svg/svg.h" +#include "ui/toolbar/tweak-toolbar.h" + #include "ui/tools/tweak-tool.h" using Inkscape::DocumentUndo; @@ -1121,7 +1123,14 @@ sp_tweak_update_area (TweakTool *tc) static void sp_tweak_switch_mode (TweakTool *tc, gint mode, bool with_shift) { - SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode); + auto tb = dynamic_cast(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("TweakToolbar")); + + if(tb) { + tb->set_mode(mode); + } else { + std::cerr << "Could not access Tweak toolbar" << std::endl; + } + // need to set explicitly, because the prefs may not have changed by the previous tc->mode = mode; tc->update_cursor(with_shift); @@ -1133,7 +1142,15 @@ sp_tweak_switch_mode_temporarily (TweakTool *tc, gint mode, bool with_shift) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Juggling about so that prefs have the old value but tc->mode and the button show new mode: gint now_mode = prefs->getInt("/tools/tweak/mode", 0); - SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode); + + auto tb = dynamic_cast(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("TweakToolbar")); + + if(tb) { + tb->set_mode(mode); + } else { + std::cerr << "Could not access Tweak toolbar" << std::endl; + } + // button has changed prefs, restore prefs->setInt("/tools/tweak/mode", now_mode); // changing prefs changed tc->mode, restore back :) -- cgit v1.2.3