diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
commit | cca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch) | |
tree | 146f39ded1c938019e1ed42d30923c2ac9e86789 /src/actions/actions-selection-window.cpp | |
parent | Initial commit. (diff) | |
download | inkscape-upstream.tar.xz inkscape-upstream.zip |
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/actions/actions-selection-window.cpp | 149 |
1 files changed, 149 insertions, 0 deletions
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 <sushant.co19@gmail.com> + * + * Copyright (C) 2021 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include <giomm.h> +#include <glibmm/i18n.h> + +#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<std::vector<Glib::ustring>> 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<InkscapeWindow*>(sigc::ptr_fun(&select_all), win)); + win->add_action( "select-all-layers", sigc::bind<InkscapeWindow*>(sigc::ptr_fun(&select_all_layers), win)); + win->add_action( "select-same-fill-and-stroke", sigc::bind<InkscapeWindow*>(sigc::ptr_fun(&select_same_fill_and_stroke), win)); + win->add_action( "select-same-fill", sigc::bind<InkscapeWindow*>(sigc::ptr_fun(&select_same_fill), win)); + win->add_action( "select-same-stroke-color", sigc::bind<InkscapeWindow*>(sigc::ptr_fun(&select_same_stroke_color), win)); + win->add_action( "select-same-stroke-style", sigc::bind<InkscapeWindow*>(sigc::ptr_fun(&select_same_stroke_style), win)); + win->add_action( "select-same-object-type", sigc::bind<InkscapeWindow*>(sigc::ptr_fun(&select_same_object_type), win)); + win->add_action( "select-invert", sigc::bind<InkscapeWindow*>(sigc::ptr_fun(&select_invert), win)); + win->add_action( "select-none", sigc::bind<InkscapeWindow*>(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); +} |