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-edit-document.cpp | |
parent | Initial commit. (diff) | |
download | inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.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-edit-document.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/actions/actions-edit-document.cpp b/src/actions/actions-edit-document.cpp new file mode 100644 index 0000000..74a69d8 --- /dev/null +++ b/src/actions/actions-edit-document.cpp @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** \file + * + * Actions Related to Editing which require document + * + * 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-edit-document.h" +#include "actions/actions-extra-data.h" +#include "inkscape-application.h" +#include "document.h" +#include "inkscape.h" +#include "selection-chemistry.h" +#include "object/sp-guide.h" +#include "object/sp-namedview.h" + +void +create_guides_around_page(SPDocument* document) +{ + // Create Guides Around the Page + sp_guide_create_guides_around_page(document); +} + +void +lock_all_guides(SPDocument *document) +{ + document->getNamedView()->toggleLockGuides(); +} + +void +show_all_guides(SPDocument *document) +{ + document->getNamedView()->toggleShowGuides(); +} + +void +delete_all_guides(SPDocument* document) +{ + // Delete All Guides + sp_guide_delete_all_guides(document); +} + +void +fit_canvas_drawing(SPDocument* document) +{ + // Fit Page to Drawing + if (fit_canvas_to_drawing(document)) { + Inkscape::DocumentUndo::done(document, _("Fit Page to Drawing"), ""); + } +} + +std::vector<std::vector<Glib::ustring>> raw_data_edit_document = +{ + + // clang-format off + {"doc.create-guides-around-page", N_("Create Guides Around the Page"), "Edit Document", N_("Create four guides aligned with the page borders")}, + {"doc.lock-all-guides", N_("Lock All Guides"), "Edit Document", N_("Toggle lock of all guides in the document")}, + {"doc.show-all-guides", N_("Show All Guides"), "Edit Document", N_("Toggle visibility of all guides in the document")}, + {"doc.delete-all-guides", N_("Delete All Guides"), "Edit Document", N_("Delete all the guides in the document")}, + {"doc.fit-canvas-to-drawing", N_("Fit Page to Drawing"), "Edit Document", N_("Fit the page to the drawing")} + // clang-format on +}; + +void +add_actions_edit_document(SPDocument* document) +{ + + Glib::RefPtr<Gio::SimpleActionGroup> map = document->getActionGroup(); + + // clang-format off + map->add_action( "create-guides-around-page", sigc::bind<SPDocument*>(sigc::ptr_fun(&create_guides_around_page), document)); + map->add_action( "delete-all-guides", sigc::bind<SPDocument*>(sigc::ptr_fun(&delete_all_guides), document)); + map->add_action( "fit-canvas-to-drawing", sigc::bind<SPDocument*>(sigc::ptr_fun(&fit_canvas_drawing), document)); + map->add_action_bool( "lock-all-guides", sigc::bind<SPDocument*>(sigc::ptr_fun(&lock_all_guides), document)); + map->add_action_bool( "show-all-guides", sigc::bind<SPDocument*>(sigc::ptr_fun(&show_all_guides), document)); + // clang-format on + + // Check if there is already an application instance (GUI or non-GUI). + auto app = InkscapeApplication::instance(); + if (!app) { + std::cerr << "add_actions_edit_document: no app!" << std::endl; + return; + } + app->get_action_extra_data().add_data(raw_data_edit_document); +} |