summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 52f6315)
raw | patch | inline | side by side (parent: 52f6315)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 27 Jan 2007 21:02:57 +0000 (21:02 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 27 Jan 2007 21:02:57 +0000 (21:02 +0000) |
index 9881d63317af1df0ef49d1465cea7d437c871a74..b04456a8bad03b5bc151c4200f52487fd251f8a2 100644 (file)
<!-- <param name="orient" type="boolean" _gui-text="Keep text orientation upright">true</param>-->
<!--<param name="unit" type="string" _gui-text="Unit {km|m|cm|mm|in|px|pt}">mm</param>-->
<param name="unit" type="enum" _gui-text="Length Unit: ">
- <item>px</item>
- <item>pt</item>
- <item>in</item>
- <item>mm</item>
- <item>cm</item>
- <item>m</item>
+ <item value="px">px</item>
+ <item value="pt">pt</item>
+ <item value="in">in</item>
+ <item value="mm">mm</item>
+ <item value="cm">cm</item>
+ <item value="m">m</item>
<item>km</item>
</param>
</page>
index f7e728f0dad10fd929d899eaf29b2c9654e54343..ce489a9e2c2e260b458bf3b6c3e11b6a6a984f88 100644 (file)
<param name="title" type="description">This effect bends a pattern object along an arbitrary "skeleton" path. The pattern can be a path or a group of paths. First, select the pattern object; then add to selection the skeleton path; then call this effect.</param>\r
\r
<param name="copymode" type="enum" _gui-text="Copies of the pattern:">\r
- <item>Single</item>\r
- <item>Single, stretched</item>\r
- <item>Repeated</item>\r
- <item>Repeated, stretched</item>\r
+ <item value="Single">Single</item>\r
+ <item value="Single, stretched">Single, stretched</item>\r
+ <item value="Repeated">Repeated</item>\r
+ <item value="Repeated, stretched">Repeated, stretched</item>\r
</param>\r
\r
<param name="kind" type="enum" _gui-text="Deformation type:">\r
- <item>Snake</item>\r
- <item>Ribbon</item>\r
+ <item value="Snake">Snake</item>\r
+ <item value="Ribbon">Ribbon</item>\r
</param>\r
\r
<param name="space" type="float" _gui-text="Space between copies:" min="-10000.0" max="10000.0" >0.0</param>\r
index 631ab43fe2e61703d5195f4867601c7040e89811..8ab5c1d9ace9cc2a960633fbdefae77479131385 100644 (file)
*param_string += *paramstr;
delete paramstr;
}
+ //g_message("paramstring=%s", param_string->c_str());
return param_string;
}
index 849447427c5188bed439871dc32f5a807ee0baa0..bd8d0b14eed801e0be3fdfc1e4cba0d0739202bc 100644 (file)
/** \file\r
- * extension parameter for enumerations. \r
+ * extension parameter for enumerations.\r
*\r
* It uses a Gtk:ComboBoxText widget in the extension UI.\r
*/\r
* Author:\r
* Johan Engelen <johan@shouraizou.nl>\r
*\r
- * Copyright (C) 2006 Author\r
+ * Copyright (C) 2006-2007 Johan Engelen\r
*\r
* Released under GNU GPL, read the file 'COPYING' for more information\r
*/\r
namespace Inkscape {\r
namespace Extension {\r
\r
+/* For internal use only.\r
+ Note that value and guitext MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */\r
+class enumentry {\r
+public:\r
+ enumentry (Glib::ustring * val, Glib::ustring * text) {\r
+ value = val;\r
+ guitext = text;\r
+ }\r
+ ~enumentry() {\r
+ delete value;\r
+ delete guitext;\r
+ }\r
+\r
+ Glib::ustring * value;\r
+ Glib::ustring * guitext;\r
+};\r
+\r
+\r
ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :\r
Parameter(name, guitext, desc, scope, ext)\r
-{ \r
+{\r
choices = NULL;\r
_value = NULL;\r
- \r
+\r
// Read XML tree to add enumeration items:\r
// printf("Extension Constructor: ");\r
if (xml != NULL) {\r
@@ -54,22 +72,28 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
while (child_repr != NULL) {\r
char const * chname = child_repr->name();\r
if (!strcmp(chname, "item")) {\r
- Glib::ustring * newitem = NULL;\r
+ Glib::ustring * newguitext = NULL;\r
+ Glib::ustring * newvalue = NULL;\r
const char * contents = sp_repr_children(child_repr)->content();\r
if (contents != NULL)\r
- newitem = new Glib::ustring(contents);\r
- if (newitem != NULL) choices = g_slist_append(choices, newitem);\r
+ newguitext = new Glib::ustring( _(contents) );\r
+ const char * val = child_repr->attribute("value");\r
+ if (val != NULL)\r
+ newvalue = new Glib::ustring(val);\r
+ if ( (newguitext) && (newvalue) ) {\r
+ choices = g_slist_append( choices, new enumentry(newvalue, newguitext) );\r
+ }\r
}\r
child_repr = sp_repr_next(child_repr);\r
}\r
}\r
- \r
+\r
// Initialize _value with the default value from xml\r
// for simplicity : default to the contents of the first xml-child\r
const char * defaultval = NULL;\r
if (sp_repr_children(sp_repr_children(xml)) != NULL)\r
- defaultval = sp_repr_children(sp_repr_children(xml))->content();\r
- \r
+ defaultval = sp_repr_children(xml)->attribute("value");\r
+\r
gchar * pref_name = this->pref_name();\r
const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);\r
g_free(pref_name);\r
@@ -78,16 +102,15 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
defaultval = paramval;\r
if (defaultval != NULL)\r
_value = g_strdup(defaultval); // allocate space for _value\r
- \r
+\r
return;\r
}\r
\r
ParamComboBox::~ParamComboBox (void)\r
-{ \r
+{\r
//destroy choice strings\r
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {\r
- Glib::ustring * text = reinterpret_cast<Glib::ustring *>(list->data);\r
- delete text;\r
+ delete (reinterpret_cast<enumentry *>(list->data));\r
}\r
g_slist_free(choices);\r
\r
@@ -113,13 +136,21 @@ ParamComboBox::set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * no
{\r
if (in == NULL) return NULL; /* Can't have NULL string */\r
\r
- if (_value != NULL)\r
- g_free(_value);\r
- _value = g_strdup(in);\r
-\r
- gchar * prefname = this->pref_name();\r
- prefs_set_string_attribute(PREF_DIR, prefname, _value);\r
- g_free(prefname);\r
+ Glib::ustring * settext = NULL;\r
+ for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {\r
+ enumentry * entr = reinterpret_cast<enumentry *>(list->data);\r
+ if ( !entr->guitext->compare(in) ) {\r
+ settext = entr->value;\r
+ break; // break out of for loop\r
+ }\r
+ }\r
+ if (settext) {\r
+ if (_value != NULL) g_free(_value);\r
+ _value = g_strdup(settext->c_str());\r
+ gchar * prefname = this->pref_name();\r
+ prefs_set_string_attribute(PREF_DIR, prefname, _value);\r
+ g_free(prefname);\r
+ }\r
\r
return _value;\r
}\r
hbox->pack_start(*label, false, false);\r
\r
ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node));\r
- // add choice strings: \r
+ // add choice strings:\r
+ Glib::ustring * settext;\r
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {\r
- Glib::ustring * text = reinterpret_cast<Glib::ustring *>(list->data);\r
+ enumentry * entr = reinterpret_cast<enumentry *>(list->data);\r
+ Glib::ustring * text = entr->guitext;\r
combo->append_text(*text);\r
+ if ( !entr->value->compare(_value) ) {\r
+ settext = entr->guitext;\r
+ }\r
}\r
- combo->set_active_text(Glib::ustring(_value));\r
+ if (settext) combo->set_active_text(*settext);\r
\r
combo->show();\r
hbox->pack_start(*combo, true, true);\r
index 3c21c4065f8ce373160ba926a37b41aa46822d93..f6fea4e05717f06c2ca566fc631331cf17c32b77 100644 (file)
* Author:\r
* Johan Engelen <johan@shouraizou.nl>\r
*\r
- * Copyright (C) 2006 Author\r
+ * Copyright (C) 2006-2007 Johan Engelen\r
*\r
* Released under GNU GPL, read the file 'COPYING' for more information\r
*/\r