summaryrefslogtreecommitdiffstats
path: root/src/extension/prefdialog/widget.cpp
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-08-04 18:21:06 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-08-31 14:50:38 +0000
commit33c31cdcdb285b20ed0286f2ec6f87e39d666666 (patch)
tree99657d7b50c6b7eefaaa4d7c2541e737b15ceace /src/extension/prefdialog/widget.cpp
parentImplement "translationdomain" attribute for extensions (diff)
downloadinkscape-33c31cdcdb285b20ed0286f2ec6f87e39d666666.tar.gz
inkscape-33c31cdcdb285b20ed0286f2ec6f87e39d666666.zip
Create new InxWidget base class for extension widgets.
Diffstat (limited to 'src/extension/prefdialog/widget.cpp')
-rw-r--r--src/extension/prefdialog/widget.cpp111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/extension/prefdialog/widget.cpp b/src/extension/prefdialog/widget.cpp
new file mode 100644
index 000000000..ea02970ca
--- /dev/null
+++ b/src/extension/prefdialog/widget.cpp
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * Parameters for extensions.
+ *//*
+ * Author:
+ * Patrick Storz <eduard.braun2@gmx.de>
+ *
+ * Copyright (C) 2019 Authors
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#include "widget.h"
+
+#include <sigc++/sigc++.h>
+
+#include "extension/extension.h"
+
+#include "xml/node.h"
+
+
+namespace Inkscape {
+namespace Extension {
+
+InxWidget *InxWidget::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext)
+{
+ InxWidget *widget = nullptr;
+
+ // Note: param could equal nullptr
+ return widget;
+}
+
+InxWidget::InxWidget (Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext)
+ : _extension(ext)
+{
+ // translatable (optional)
+ const char *translatable = in_repr->attribute("translatable");
+ if (translatable) {
+ if (!strcmp(translatable, "yes")) {
+ _translatable = YES;
+ } else if (!strcmp(translatable, "no")) {
+ _translatable = NO;
+ } else {
+ g_warning("Invalid value ('%s') for translatable attribute of widget '%s' in extension '%s'",
+ translatable, in_repr->name(), _extension->get_id());
+ }
+ }
+
+ // context (optional)
+ const char *context = in_repr->attribute("context");
+ if (!context) {
+ context = in_repr->attribute("msgctxt"); // backwards-compatibility with previous name
+ }
+ if (context) {
+ _context = g_strdup(context);
+ }
+
+ // gui-hidden (optional)
+ const char *gui_hidden = in_repr->attribute("gui-hidden");
+ if (gui_hidden != nullptr) {
+ if (strcmp(gui_hidden, "true") == 0) {
+ _hidden = true;
+ }
+ }
+
+ // indent (optional)
+ const char *indent = in_repr->attribute("indent");
+ if (indent != nullptr) {
+ _indent = strtol(indent, nullptr, 0);
+ }
+
+ // appearance (optional, does not apply to all parameters)
+ const char *appearance = in_repr->attribute("appearance");
+ if (appearance) {
+ _appearance = g_strdup(appearance);
+ }
+}
+
+InxWidget::~InxWidget()
+{
+ g_free(_context);
+ _context = nullptr;
+
+ g_free(_appearance);
+ _appearance = nullptr;
+}
+
+/** Basically, if there is no widget pass a NULL. */
+Gtk::Widget *
+InxWidget::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
+{
+ return nullptr;
+}
+
+const char *InxWidget::get_translation(const char* msgid) {
+ return _extension->get_translation(msgid, _context);
+}
+
+} // namespace Extension
+} // namespace Inkscape
+
+/*
+ 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:fileencoding=utf-8:textwidth=99 :