From: gouldtj Date: Sat, 13 May 2006 08:13:04 +0000 (+0000) Subject: r11771@tres: ted | 2006-05-12 08:51:57 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2a221e1e64f7ebf0d7e6b1681912c4671306a4a1;p=inkscape.git r11771@tres: ted | 2006-05-12 08:51:57 -0700 Behaving funny, but I want to back this up. --- diff --git a/src/extension/parameter.cpp b/src/extension/parameter.cpp index a4ba31678..3fe9cac65 100644 --- a/src/extension/parameter.cpp +++ b/src/extension/parameter.cpp @@ -206,6 +206,39 @@ public: 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_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 */