From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/actions/actions-selection-window.cpp | 149 +++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 src/actions/actions-selection-window.cpp (limited to 'src/actions/actions-selection-window.cpp') diff --git a/src/actions/actions-selection-window.cpp b/src/actions/actions-selection-window.cpp new file mode 100644 index 0000000..c847984 --- /dev/null +++ b/src/actions/actions-selection-window.cpp @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** \file + * + * Actions related to selection which require desktop. + * + * These are linked to the desktop as they operate differently + * depending on if the node tool is in use or not. + * + * To do: Rewrite select_same_fill_and_stroke to remove desktop dependency. + * + * Authors: + * Sushant A A + * + * Copyright (C) 2021 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include +#include + +#include "actions-selection-window.h" +#include "inkscape-application.h" +#include "inkscape-window.h" +#include "desktop.h" +#include "ui/dialog/dialog-container.h" +#include "actions/actions-tools.h" +#include "selection-chemistry.h" + +void +select_all(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Select All + Inkscape::SelectionHelper::selectAll(dt); +} + +void +select_all_layers(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Select All in All Layers + Inkscape::SelectionHelper::selectAllInAll(dt); +} + +void +select_same_fill_and_stroke(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Fill and Stroke + Inkscape::SelectionHelper::selectSameFillStroke(dt); +} + +void +select_same_fill(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Fill Color + Inkscape::SelectionHelper::selectSameFillColor(dt); +} + +void +select_same_stroke_color(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Stroke Color + Inkscape::SelectionHelper::selectSameStrokeColor(dt); +} + +void +select_same_stroke_style(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Stroke Style + Inkscape::SelectionHelper::selectSameStrokeStyle(dt); +} + +void +select_same_object_type(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Object Type + Inkscape::SelectionHelper::selectSameObjectType(dt); +} + +void +select_invert(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Invert Selection + Inkscape::SelectionHelper::invert(dt); +} + +void +select_none(InkscapeWindow* win) +{ + SPDesktop* dt = win->get_desktop(); + + // Deselect + Inkscape::SelectionHelper::selectNone(dt); +} + +std::vector> raw_selection_dekstop_data = +{ + // clang-format off + {"win.select-all", N_("Select All"), "Select", N_("Select all objects or all nodes")}, + {"win.select-all-layers", N_("Select All in All Layers"), "Select", N_("Select all objects in all visible and unlocked layers")}, + {"win.select-same-fill-and-stroke", N_("Fill and Stroke"), "Select", N_("Select all objects with the same fill and stroke as the selected objects")}, + {"win.select-same-fill", N_("Fill Color"), "Select", N_("Select all objects with the same fill as the selected objects")}, + {"win.select-same-stroke-color", N_("Stroke Color"), "Select", N_("Select all objects with the same stroke as the selected objects")}, + {"win.select-same-stroke-style", N_("Stroke Style"), "Select", N_("Select all objects with the same stroke style (width, dash, markers) as the selected objects")}, + {"win.select-same-object-type", N_("Object Type"), "Select", N_("Select all objects with the same object type (rect, arc, text, path, bitmap etc) as the selected objects")}, + {"win.select-invert", N_("Invert Selection"), "Select", N_("Invert selection (unselect what is selected and select everything else)")}, + {"win.select-none", N_("Deselect"), "Select", N_("Deselect any selected objects or nodes")}, + // DO NOT ADD select-next or select-previous here as their default keys conflict with Gtk's widget navigation. + + // clang-format on +}; + +void +add_actions_select_window(InkscapeWindow* win) +{ + // clang-format off + win->add_action( "select-all", sigc::bind(sigc::ptr_fun(&select_all), win)); + win->add_action( "select-all-layers", sigc::bind(sigc::ptr_fun(&select_all_layers), win)); + win->add_action( "select-same-fill-and-stroke", sigc::bind(sigc::ptr_fun(&select_same_fill_and_stroke), win)); + win->add_action( "select-same-fill", sigc::bind(sigc::ptr_fun(&select_same_fill), win)); + win->add_action( "select-same-stroke-color", sigc::bind(sigc::ptr_fun(&select_same_stroke_color), win)); + win->add_action( "select-same-stroke-style", sigc::bind(sigc::ptr_fun(&select_same_stroke_style), win)); + win->add_action( "select-same-object-type", sigc::bind(sigc::ptr_fun(&select_same_object_type), win)); + win->add_action( "select-invert", sigc::bind(sigc::ptr_fun(&select_invert), win)); + win->add_action( "select-none", sigc::bind(sigc::ptr_fun(&select_none), win)); + // clang-format on + + auto app = InkscapeApplication::instance(); + if (!app) { + std::cerr << "add_actions_edit: no app!" << std::endl; + return; + } + app->get_action_extra_data().add_data(raw_selection_dekstop_data); +} -- cgit v1.2.3