summaryrefslogtreecommitdiffstats
path: root/src/extension/prefdialog/parameter-string.h
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-07-22 23:06:21 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-08-31 14:50:38 +0000
commit8f7a3a637f6a465e78e88490a03f539f0d8fdc1a (patch)
treee503502036ba4268921ded10a81ab3b4157d89d5 /src/extension/prefdialog/parameter-string.h
parentMove error classes to Parameter where they belong (diff)
downloadinkscape-8f7a3a637f6a465e78e88490a03f539f0d8fdc1a.tar.gz
inkscape-8f7a3a637f6a465e78e88490a03f539f0d8fdc1a.zip
Refactor a lot of the parameter handling code
Many fixes, improvements and simplifications to existing code. Implements the first part of the changes discussed in https://gitlab.com/inkscape/inkscape/issues/333
Diffstat (limited to 'src/extension/prefdialog/parameter-string.h')
-rw-r--r--src/extension/prefdialog/parameter-string.h35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/extension/prefdialog/parameter-string.h b/src/extension/prefdialog/parameter-string.h
index 7c094d394..476807936 100644
--- a/src/extension/prefdialog/parameter-string.h
+++ b/src/extension/prefdialog/parameter-string.h
@@ -12,33 +12,22 @@
#include "parameter.h"
+namespace Glib {
+class ustring;
+}
+
namespace Inkscape {
namespace Extension {
class ParamString : public Parameter {
-private:
- /** \brief Internal value. This should point to a string that has
- been allocated in memory. And should be free'd. */
- gchar * _value;
- /** \brief Internal value. This indicates the maximum length of the string. Zero meaning unlimited.
- */
- gint _max_length;
public:
- ParamString(const gchar * name,
- const gchar * text,
- const gchar * description,
- bool hidden,
- int indent,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml);
- ~ParamString() override;
+ ParamString(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext);
/** \brief Returns \c _value, with a \i const to protect it. */
- const gchar *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; }
-
- const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
+ const Glib::ustring& get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; }
+ const Glib::ustring& set(const Glib::ustring in, SPDocument *doc, Inkscape::XML::Node *node);
- Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override;
+ Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override;
// Explicitly call superclass version to avoid method being hidden.
void string(std::list <std::string> &list) const override { return Parameter::string(list); }
@@ -47,6 +36,14 @@ public:
void setMaxLength(int maxLength) { _max_length = maxLength; }
int getMaxLength() { return _max_length; }
+
+private:
+ /** \brief Internal value. */
+ Glib::ustring _value;
+
+ /** \brief Maximum length of the string in characters (zero meaning unlimited).
+ */
+ int _max_length = 0;
};