12#include <glibmm/i18n.h>
44 auto action = win->lookup_action(
"tool-switch");
46 show_output(
"get_active_tool: action 'tool-switch' missing!");
50 auto saction = std::dynamic_pointer_cast<Gio::SimpleAction>(action);
52 show_output(
"get_active_tool: action 'tool-switch' not SimpleAction!");
56 saction->get_state(state);
89 if (is<SPRect>(
item)) {
91 }
else if (is<SPGenericEllipse>(
item)) {
93 }
else if (is<SPStar>(
item)) {
95 }
else if (is<SPBox3D>(
item)) {
97 }
else if (is<SPSpiral>(
item)) {
99 }
else if (is<SPMarker>(
item)) {
101 }
else if (is<SPPath>(
item)) {
108 }
else if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
116 }
else if (is<SPOffset>(
item)) {
129 auto tool_it = tool_data.find(tool);
130 if (tool_it == tool_data.end()) {
131 show_output(Glib::ustring(
"tool-switch: invalid tool name: ") + tool.raw());
142 auto action = win->lookup_action(
"tool-switch");
144 show_output(
"tool-switch: action 'tool-switch' missing!");
148 auto saction = std::dynamic_pointer_cast<Gio::SimpleAction>(action);
150 show_output(
"tool-switch: action 'tool-switch' not SimpleAction!");
156 Glib::ustring current_tool;
157 saction->get_state(current_tool);
158 if (current_tool == tool)
162 saction->set_enabled(
false);
163 saction->change_state(tool);
164 saction->set_enabled(
true);
170 dt->
setTool(tool_data.at(tool).pref_path);
172 if (
auto new_tool = dt->
getTool()) {
173 new_tool->set_last_active_tool(current_tool);
185 auto tool_it = tool_data.find(tool);
186 if (tool_it == tool_data.end()) {
187 show_output(Glib::ustring(
"tool-preferences: invalid tool name: ") + tool.raw());
199 prefs->setInt(
"/dialogs/preferences/page", tool_it->second.pref);
227 auto action = win->lookup_action(
"tool-switch");
229 show_output(
"tool_toggle: action 'tool_switch' missing!");
233 auto saction = std::dynamic_pointer_cast<Gio::SimpleAction>(action);
235 show_output(
"tool_toogle: action 'tool_switch' not SimpleAction!");
239 static Glib::ustring old_tool =
"Select";
241 Glib::ustring current_tool;
242 saction->get_state(current_tool);
243 if (current_tool == tool) {
244 current_tool = old_tool;
246 old_tool = current_tool;
277const Glib::ustring
SECTION = NC_(
"Action Section",
"Tool Switch");
282 {
"win.tool-switch('Select')", N_(
"Selector Tool"),
SECTION, N_(
"Select and transform objects") },
283 {
"win.tool-switch('Node')", N_(
"Node Tool"),
SECTION, N_(
"Edit paths by nodes") },
284 {
"win.tool-switch('Booleans')", N_(
"Shape Builder Tool"),
SECTION, N_(
"Build shapes with the Boolean tool") },
286 {
"win.tool-switch('Rect')", N_(
"Rectangle Tool"),
SECTION, N_(
"Create rectangles and squares") },
287 {
"win.tool-switch('Arc')", N_(
"Ellipse/Arc Tool"),
SECTION, N_(
"Create circles, ellipses and arcs") },
288 {
"win.tool-switch('Star')", N_(
"Star/Polygon Tool"),
SECTION, N_(
"Create stars and polygons") },
289 {
"win.tool-switch('3DBox')", N_(
"3D Box Tool"),
SECTION, N_(
"Create 3D Boxes") },
290 {
"win.tool-switch('Spiral')", N_(
"Spiral Tool"),
SECTION, N_(
"Create spirals") },
291 {
"win.tool-switch('Marker')", N_(
"Marker Tool"),
SECTION, N_(
"Edit markers") },
293 {
"win.tool-switch('Pen')", N_(
"Pen Tool"),
SECTION, N_(
"Draw Bezier curves and straight lines") },
294 {
"win.tool-switch('Pencil')", N_(
"Pencil Tool"),
SECTION, N_(
"Draw freehand lines") },
295 {
"win.tool-switch('Calligraphic')", N_(
"Calligraphy Tool"),
SECTION, N_(
"Draw calligraphic or brush strokes") },
296 {
"win.tool-switch('Text')", N_(
"Text Tool"),
SECTION, N_(
"Create and edit text objects") },
298 {
"win.tool-switch('Gradient')", N_(
"Gradient Tool"),
SECTION, N_(
"Create and edit gradients") },
299 {
"win.tool-switch('Mesh')", N_(
"Mesh Tool"),
SECTION, N_(
"Create and edit meshes") },
300 {
"win.tool-switch('Dropper')", N_(
"Dropper Tool"),
SECTION, N_(
"Pick colors from image") },
301 {
"win.tool-switch('PaintBucket')", N_(
"Paint Bucket Tool"),
SECTION, N_(
"Fill bounded areas") },
303 {
"win.tool-switch('Tweak')", N_(
"Tweak Tool"),
SECTION, N_(
"Tweak objects by sculpting or painting") },
304 {
"win.tool-switch('Spray')", N_(
"Spray Tool"),
SECTION, N_(
"Spray copies or clones of objects") },
305 {
"win.tool-switch('Eraser')", N_(
"Eraser Tool"),
SECTION, N_(
"Erase objects or paths") },
306 {
"win.tool-switch('Connector')", N_(
"Connector Tool"),
SECTION, N_(
"Create diagram connectors") },
307 {
"win.tool-switch('LPETool')", N_(
"LPE Tool"),
SECTION, N_(
"Do geometric constructions") },
309 {
"win.tool-switch('Zoom')", N_(
"Zoom Tool"),
SECTION, N_(
"Zoom in or out") },
310 {
"win.tool-switch('Measure')", N_(
"Measure Tool"),
SECTION, N_(
"Measure objects") },
311 {
"win.tool-switch('Pages')", N_(
"Pages Tool"),
SECTION, N_(
"Create and edit document pages") },
313 {
"win.tool-toggle('Select')", N_(
"Toggle Selector Tool"),
SECTION, N_(
"Toggle between Selector tool and last used tool") },
314 {
"win.tool-toggle('Dropper')", N_(
"Toggle Dropper"),
SECTION, N_(
"Toggle between Dropper tool and last used tool")},
323 win->add_action_radio_string (
"tool-switch", sigc::bind(sigc::ptr_fun(&
tool_switch), win),
"Select");
324 win->add_action_radio_string (
"tool-toggle", sigc::bind(sigc::ptr_fun(&
tool_toggle), win),
"Select");
void show_output(Glib::ustring const &data, bool const is_cerr)
Two-dimensional point that doubles as a vector.
static InkscapeApplication * instance()
Singleton instance.
SPDesktop * get_desktop()
void set(MessageType type, char const *message)
pushes a message on the stack, replacing our old message
static Preferences * get()
Access the singleton Preferences object.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned contain...
DialogWindow * new_floating_dialog(const Glib::ustring &dialog_type)
Add a new floating dialog (or reuse existing one if it's already up)
static DialogManager & singleton()
DialogBase * find_floating_dialog(const Glib::ustring &dialog_type)
To do: update description of desktop.
void setTool(std::string const &toolName)
Replaces the currently active tool with a new one.
InkscapeWindow const * getInkscapeWindow() const
Inkscape::MessageContext * tipsMessageContext() const
Inkscape::UI::Dialog::DialogContainer * getContainer()
Inkscape::UI::Tools::ToolBase * getTool() const
Base class for visual SVG elements.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned.
Inkscape Preferences dialog.
Inkscape - An SVG editor.
Interface for locally managing a current status message.
TODO: insert short description here.
auto SP_TEXT_CONTEXT(Inkscape::UI::Tools::ToolBase *tool)