diff options
| author | Marcin Floryan <mfloryan@mm.waw.pl> | 2008-04-15 16:17:21 +0000 |
|---|---|---|
| committer | mfloryan <mfloryan@users.sourceforge.net> | 2008-04-15 16:17:21 +0000 |
| commit | a9178b177e16f6981499ae3f42e804a9a27fe121 (patch) | |
| tree | 06d350b808e96bbd3ea2f7ccb8c3d6e4396dbb01 /src | |
| parent | i18n: Added some comments for translators. (diff) | |
| download | inkscape-a9178b177e16f6981499ae3f42e804a9a27fe121.tar.gz inkscape-a9178b177e16f6981499ae3f42e804a9a27fe121.zip | |
Fixes Bug #216584 (Effects/Color/Replace color not accepting UC) and also implements max_length attribute for string parameters in inx files.
(bzr r5450)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/param/parameter.cpp | 5 | ||||
| -rw-r--r-- | src/extension/param/string.cpp | 5 | ||||
| -rw-r--r-- | src/extension/param/string.h | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 7e071e7e3..b356c297e 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -128,6 +128,11 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } else if (!strcmp(type, "string")) { param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + const gchar * max_length = in_repr->attribute("max_length"); + if (max_length != NULL) { + ParamString * ps = dynamic_cast<ParamString *>(param); + ps->setMaxLength(atoi(max_length)); + } } else if (!strcmp(type, "description")) { param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } else if (!strcmp(type, "enum")) { diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 36c3ce115..3dd2a2328 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -84,11 +84,13 @@ ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar defaultval = paramval; if (defaultval != NULL) _value = g_strdup(defaultval); + + _max_length = 0; return; } -/** \brief A special category of Gtk::Entry to handle string parameteres */ +/** \brief A special type of Gtk::Entry to handle string parameteres */ class ParamStringEntry : public Gtk::Entry { private: ParamString * _pref; @@ -104,6 +106,7 @@ public: Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { if (_pref->get(NULL, NULL) != NULL) this->set_text(Glib::ustring(_pref->get(NULL, NULL))); + this->set_max_length(_pref->getMaxLength()); //Set the max lenght - default zero means no maximum this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text)); }; void changed_text (void); diff --git a/src/extension/param/string.h b/src/extension/param/string.h index 0a1a0f2a3..10f45e5ac 100644 --- a/src/extension/param/string.h +++ b/src/extension/param/string.h @@ -21,6 +21,9 @@ 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 leght of the string. Zero meaning unlimited. + */ + gint _max_length; public: ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); virtual ~ParamString(void); @@ -29,6 +32,8 @@ public: const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); void string (std::string &string); + void setMaxLength(int maxLenght) { _max_length = maxLenght; } + int getMaxLength(void) { return _max_length; } }; |
