summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/extensions/color_replace.inx4
-rw-r--r--share/extensions/color_replace.py4
-rw-r--r--src/extension/param/parameter.cpp5
-rw-r--r--src/extension/param/string.cpp5
-rw-r--r--src/extension/param/string.h5
5 files changed, 18 insertions, 5 deletions
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 @@
<dependency type="executable" location="extensions">coloreffect.py</dependency>
<dependency type="executable" location="extensions">color_replace.py</dependency>
<dependency type="executable" location="extensions">simplestyle.py</dependency>
- <param name="from_color" type="string" _gui-text="Replace color (RRGGBB hex):">000000</param>
- <param name="to_color" type="string" _gui-text="By color (RRGGBB hex):">000000</param>
+ <param name="from_color" type="string" max_length="6" _gui-text="Replace color (RRGGBB hex):">000000</param>
+ <param name="to_color" type="string" max_length="6" _gui-text="By color (RRGGBB hex):">000000</param>
<effect>
<object-type>all</object-type>
<effects-menu>
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<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; }
};