summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d4f873d)
raw | patch | inline | side by side (parent: d4f873d)
author | gouldtj <gouldtj@users.sourceforge.net> | |
Sat, 13 May 2006 08:13:04 +0000 (08:13 +0000) | ||
committer | gouldtj <gouldtj@users.sourceforge.net> | |
Sat, 13 May 2006 08:13:04 +0000 (08:13 +0000) |
Behaving funny, but I want to back this up.
src/extension/parameter.cpp | patch | blob | history |
index a4ba31678f8990e0d0adc6bcdbb4bf984f8446a9..3fe9cac65e0895f35fafafe552116d8c97bc5721 100644 (file)
Glib::ustring * string (void);
};
+class ParamEnum : public Parameter {
+private:
+ class Choice {
+ public:
+ gchar * _gui_name;
+ gchar * _value;
+ Choice(gchar * gui_name, gchar * value) : _gui_name(NULL), _value(NULL) {
+ if (gui_name != NULL)
+ _gui_name = g_strdup(_(gui_name));
+ if (value != NULL)
+ _value = g_strdup(value);
+ return;
+ };
+ ~Choice (void) {
+ g_free(_gui_name);
+ g_free(_value);
+ };
+ }; /* class Choice */
+ /** \brief Internal value. This should point to a string that has
+ been allocated in memory. And should be free'd. */
+ Choice * _current_choice;
+ typedef std::list<Choice *> choice_list_t;
+ choice_list_t _choice_list;
+public:
+ ParamEnum(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ~ParamEnum(void);
+ /** \brief Returns \c _value, with a \i const to protect it. */
+ const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _current_choice != NULL ? _current_choice->_value : NULL; }
+ const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
+ Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node);
+ Glib::ustring * string (void);
+}; /* class ParamEnum */
+
/**
\return None
\brief This function creates a parameter that can be used later. This
@@ -275,6 +308,8 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
param = new ParamString(name, guitext, desc, scope, in_ext, in_repr);
} else if (!strcmp(type, "description")) {
param = new ParamDescription(name, guitext, desc, scope, in_ext, in_repr);
+ } else if (!strcmp(type, "enum")) {
+ param = new ParamEnum(name, guitext, desc, scope, in_ext, in_repr);
}
/* Note: param could equal NULL */
@@ -890,6 +925,35 @@ ParamDescription::ParamDescription (const gchar * name, const gchar * guitext, c
return;
}
+ParamEnum::ParamEnum (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+ Parameter(name, guitext, desc, scope, ext), _current_choice(NULL)
+{
+ return;
+}
+
+/** \brief Return the value as a string */
+Glib::ustring *
+ParamEnum::string (void)
+{
+ Glib::ustring * mystring = new Glib::ustring("");
+ *mystring += "\"";
+ *mystring += this->get(NULL, NULL);
+ *mystring += "\"";
+ return mystring;
+}
+
+Gtk::Widget *
+ParamEnum::get_widget (SPDocument * doc, Inkscape::XML::Node * node)
+{
+ return NULL;
+}
+
+const gchar *
+ParamEnum::set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node)
+{
+ return NULL;
+}
+
} /* namespace Extension */
} /* namespace Inkscape */