From: mfloryan Date: Tue, 15 Apr 2008 16:17:21 +0000 (+0000) Subject: Fixes Bug #216584 (Effects/Color/Replace color not accepting UC) and also implements... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=72728176afefe733049f0b73dc7ad65885a5f61b;p=inkscape.git Fixes Bug #216584 (Effects/Color/Replace color not accepting UC) and also implements max_length attribute for string parameters in inx files. --- diff --git a/share/extensions/color_replace.inx b/share/extensions/color_replace.inx index c50b12811..3e6ebb91a 100644 --- a/share/extensions/color_replace.inx +++ b/share/extensions/color_replace.inx @@ -4,8 +4,8 @@ coloreffect.py color_replace.py simplestyle.py - 000000 - 000000 + 000000 + 000000 all diff --git a/share/extensions/color_replace.py b/share/extensions/color_replace.py index 118a67d58..c52d75957 100644 --- a/share/extensions/color_replace.py +++ b/share/extensions/color_replace.py @@ -11,8 +11,8 @@ class C(coloreffect.ColorEffect): def colmod(self,r,g,b): this_color = '%02x%02x%02x' % (r, g, b) - fr = self.options.from_color.strip('"').replace('#', '') - to = self.options.to_color.strip('"').replace('#', '') + fr = self.options.from_color.strip('"').replace('#', '').lower() + to = self.options.to_color.strip('"').replace('#', '').lower() #inkex.debug(this_color+"|"+fr+"|"+to) if this_color == fr: 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(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 * changeSignal); void string (std::string &string); + void setMaxLength(int maxLenght) { _max_length = maxLenght; } + int getMaxLength(void) { return _max_length; } };