summaryrefslogtreecommitdiffstats
path: root/src/extension/prefdialog/widget.cpp
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-08-04 22:53:57 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-08-31 14:50:38 +0000
commit40df9f6ef495c4577958502ffb4f23a4a4e1092f (patch)
treec8d16021ba5a2305687b02cd62385f6889e8f01c /src/extension/prefdialog/widget.cpp
parentTranslatable enum can be protected (diff)
downloadinkscape-40df9f6ef495c4577958502ffb4f23a4a4e1092f.tar.gz
inkscape-40df9f6ef495c4577958502ffb4f23a4a4e1092f.zip
Switch Inkscape::Extension to use InxWidgets instead of InxParameters
Diffstat (limited to 'src/extension/prefdialog/widget.cpp')
-rw-r--r--src/extension/prefdialog/widget.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/extension/prefdialog/widget.cpp b/src/extension/prefdialog/widget.cpp
index 1297edb1c..ae85b9fbd 100644
--- a/src/extension/prefdialog/widget.cpp
+++ b/src/extension/prefdialog/widget.cpp
@@ -10,9 +10,12 @@
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
+#include "parameter.h"
#include "widget.h"
#include "widget-label.h"
+#include <algorithm>
+
#include <sigc++/sigc++.h>
#include "extension/extension.h"
@@ -28,11 +31,20 @@ InxWidget *InxWidget::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex
InxWidget *widget = nullptr;
const char *name = in_repr->name();
+ if (!strncmp(name, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
+ name += strlen(INKSCAPE_EXTENSION_NS);
+ }
+ if (name[0] == '_') { // allow leading underscore in tag names for backwards-compatibility
+ name++;
+ }
+
if (!name) {
// we can't create a widget without name
g_warning("InxWidget without name in extension '%s'.", in_ext->get_id());
} else if (!strcmp(name, "description")) {
widget = new WidgetLabel(in_repr, in_ext);
+ } else if (!strcmp(name, "param")) {
+ widget = InxParameter::make(in_repr, in_ext);
} else {
g_warning("Unknown widget name ('%s') in extension '%s'", name, in_ext->get_id());
}
@@ -41,6 +53,19 @@ InxWidget *InxWidget::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex
return widget;
}
+bool InxWidget::is_valid_widget_name(const char *name)
+{
+ // keep in sync with names supported in InxWidget::make() above
+ static const std::vector<std::string> valid_names = {"description", "param"};
+
+ if (std::find(valid_names.begin(), valid_names.end(), name) != valid_names.end()) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
InxWidget::InxWidget (Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext)
: _extension(ext)
{