summaryrefslogtreecommitdiffstats
path: root/src/actions/actions-helper.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2018-11-19 22:49:18 +0000
committerTavmjong Bah <tavmjong@free.fr>2018-11-19 22:49:18 +0000
commit9f666963e7f574c95d26082597e7ee5fbee9780b (patch)
tree901e704d42fbcc2f98b2970bdbc7da25a72e0736 /src/actions/actions-helper.cpp
parentFix --help descriptions of "--actions", "--query-id", " and "--export-id". (diff)
downloadinkscape-9f666963e7f574c95d26082597e7ee5fbee9780b.tar.gz
inkscape-9f666963e7f574c95d26082597e7ee5fbee9780b.zip
Allow any valid Verb to be used in "--actions".
Rename "select" action to "select-via-id". Add "select-via-class", "select-via-element", "select-via-selector", and "select-clear" actions.
Diffstat (limited to 'src/actions/actions-helper.cpp')
-rw-r--r--src/actions/actions-helper.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/actions/actions-helper.cpp b/src/actions/actions-helper.cpp
new file mode 100644
index 000000000..e72a15dad
--- /dev/null
+++ b/src/actions/actions-helper.cpp
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Gio::Actions for selection tied to the application and without GUI.
+ *
+ * Copyright (C) 2018 Tavmjong Bah
+ *
+ * The contents of this file may be used under the GNU General Public License Version 2 or later.
+ *
+ */
+
+#include "actions-helper.h"
+
+#include "inkscape-application.h"
+#include "inkscape.h"
+#include "selection.h"
+
+// Helper function: returns true if both document and selection found. Maybe this should
+// work on current view. Or better, application could return the selection of the current view.
+bool
+get_document_and_selection(InkscapeApplication* app, SPDocument** document, Inkscape::Selection** selection)
+{
+ *document = app->get_active_document();
+ if (!(*document)) {
+ std::cerr << "get_document_and_selection: No document!" << std::endl;
+ return false;
+ }
+
+ // To do: get selection from active view (which could be from desktop or not).
+ Inkscape::ActionContext context = INKSCAPE.action_context_for_document(*document);
+ *selection = context.getSelection();
+ if (!*selection) {
+ std::cerr << "get_document_and_selection: No selection!" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :