summaryrefslogtreecommitdiffstats
path: root/src/actions/actions-helper.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/actions/actions-helper.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/actions/actions-helper.cpp b/src/actions/actions-helper.cpp
new file mode 100644
index 0000000..7dab91a
--- /dev/null
+++ b/src/actions/actions-helper.cpp
@@ -0,0 +1,45 @@
+// 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.
+ *
+ * TODO: REMOVE THIS FILE It's really not necessary.
+ */
+
+#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;
+ }
+
+ *selection = app->get_active_selection();
+ 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 :