summaryrefslogtreecommitdiffstats
path: root/src/actions/actions-effect.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
commitc853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch)
tree7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /src/actions/actions-effect.cpp
parentInitial commit. (diff)
downloadinkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.tar.xz
inkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.zip
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/actions/actions-effect.cpp')
-rw-r--r--src/actions/actions-effect.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/actions/actions-effect.cpp b/src/actions/actions-effect.cpp
new file mode 100644
index 0000000..fb4ebe2
--- /dev/null
+++ b/src/actions/actions-effect.cpp
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** \file
+ *
+ * Actions for Filters and Extension menu items
+ *
+ * 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-effect.h"
+#include "actions-helper.h"
+#include "inkscape-application.h"
+
+#include "extension/effect.h"
+
+void
+edit_remove_filter(InkscapeApplication *app)
+{
+ auto selection = app->get_active_selection();
+
+ // Remove Filter
+ selection->removeFilter();
+}
+
+void
+last_effect(InkscapeApplication *app)
+{
+ Inkscape::Extension::Effect *effect = Inkscape::Extension::Effect::get_last_effect();
+
+ if (effect == nullptr) {
+ return;
+ }
+
+ // Last Effect
+ effect->effect(InkscapeApplication::instance()->get_active_view());
+}
+
+void
+last_effect_pref(InkscapeApplication *app)
+{
+ Inkscape::Extension::Effect *effect = Inkscape::Extension::Effect::get_last_effect();
+
+ if (effect == nullptr) {
+ return;
+ }
+
+ // Last Effect Pref
+ effect->prefs(InkscapeApplication::instance()->get_active_view());
+}
+
+void
+enable_effect_actions(InkscapeApplication* app, bool enabled)
+{
+ auto gapp = app->gio_app();
+ auto le_action = gapp->lookup_action("last-effect");
+ auto lep_action = gapp->lookup_action("last-effect-pref");
+ auto le_saction = Glib::RefPtr<Gio::SimpleAction>::cast_dynamic(le_action);
+ auto lep_saction = Glib::RefPtr<Gio::SimpleAction>::cast_dynamic(lep_action);
+ // GTK4
+ // auto le_saction = dynamic_cast<Gio::SimpleAction*>(le_action);
+ // auto lep_saction = dynamic_cast<Gio::SimpleAction*>(lep_action);
+ if (!le_saction || !lep_saction) {
+ g_warning("Unable to find Extension actions.");
+ return;
+ }
+ // Enable/disable menu items.
+ le_saction->set_enabled(enabled);
+ lep_saction->set_enabled(enabled);
+}
+
+std::vector<std::vector<Glib::ustring>> raw_data_effect =
+{
+ // clang-format off
+ {"app.edit-remove-filter", N_("Remove Filters"), "Filters", N_("Remove any filters from selected objects")},
+ {"app.last-effect", N_("Previous Extension"), "Extensions", N_("Repeat the last extension with the same settings")},
+ {"app.last-effect-pref", N_("Previous Extension Settings"), "Extensions", N_("Repeat the last extension with new settings")}
+ // clang-format on
+};
+
+void
+add_actions_effect(InkscapeApplication* app)
+{
+ auto *gapp = app->gio_app();
+
+ // clang-format off
+ gapp->add_action( "edit-remove-filter", sigc::bind<InkscapeApplication*>(sigc::ptr_fun(&edit_remove_filter), app));
+ gapp->add_action( "last-effect", sigc::bind<InkscapeApplication*>(sigc::ptr_fun(&last_effect), app));
+ gapp->add_action( "last-effect-pref", sigc::bind<InkscapeApplication*>(sigc::ptr_fun(&last_effect_pref), app));
+ // clang-format on
+
+ if (!app) {
+ show_output("add_actions_edit: no app!");
+ return;
+ }
+ app->get_action_extra_data().add_data(raw_data_effect);
+}