summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8c1601)
raw | patch | inline | side by side (parent: c8c1601)
| author | gouldtj <gouldtj@users.sourceforge.net> | |
| Tue, 2 May 2006 05:25:17 +0000 (05:25 +0000) | ||
| committer | gouldtj <gouldtj@users.sourceforge.net> | |
| Tue, 2 May 2006 05:25:17 +0000 (05:25 +0000) |
Parsing and passing scope and description values through.
| src/extension/parameter.cpp | patch | blob | history | |
| src/extension/parameter.h | patch | blob | history |
index ef0154d88caa54649ba644c1ca1a5b2279a16516..57bc98fcc55c04043d99297464a4b7b19d9446df 100644 (file)
/** \brief Internal value. */
bool _value;
public:
- ParamBool(const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
/** \brief Returns \c _value */
bool get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
bool set (bool in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
};
/** \brief Use the superclass' allocator and set the \c _value */
-ParamBool::ParamBool (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, ext), _value(false)
+ParamBool::ParamBool (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), _value(false)
{
const char * defaultval = NULL;
if (sp_repr_children(xml) != NULL)
int _min;
int _max;
public:
- ParamInt (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
/** \brief Returns \c _value */
int get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
int set (int in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
};
/** \brief Use the superclass' allocator and set the \c _value */
-ParamInt::ParamInt (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, ext), _value(0), _min(0), _max(10)
+ParamInt::ParamInt (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), _value(0), _min(0), _max(10)
{
const char * defaultval = NULL;
if (sp_repr_children(xml) != NULL)
float _min;
float _max;
public:
- ParamFloat (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
/** \brief Returns \c _value */
float get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
float set (float in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
};
/** \brief Use the superclass' allocator and set the \c _value */
-ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, ext), _value(0.0), _min(0.0), _max(10.0)
+ParamFloat::ParamFloat (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), _value(0.0), _min(0.0), _max(10.0)
{
const char * defaultval = NULL;
if (sp_repr_children(xml) != NULL)
been allocated in memory. And should be free'd. */
gchar * _value;
public:
- ParamString(const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
~ParamString(void);
/** \brief Returns \c _value, with a \i const to protect it. */
const gchar * get (const Inkscape::XML::Document * doc, const Inkscape::XML::Node * node) { return _value; }
@@ -221,27 +221,44 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
const char * name;
const char * type;
const char * guitext;
+ const char * desc;
+ const char * scope_str;
+ Parameter::_scope_t scope = Parameter::SCOPE_USER;
name = in_repr->attribute("name");
type = in_repr->attribute("type");
guitext = in_repr->attribute("gui-text");
if (guitext == NULL)
guitext = in_repr->attribute("_gui-text");
+ desc = in_repr->attribute("gui-description");
+ if (desc == NULL)
+ desc = in_repr->attribute("_gui-description");
+ scope_str = in_repr->attribute("scope");
/* In this case we just don't have enough information */
if (name == NULL || type == NULL) {
return NULL;
}
+ if (scope_str != NULL) {
+ if (!strcmp(scope_str, "user")) {
+ scope = Parameter::SCOPE_USER;
+ } else if (!strcmp(scope_str, "document")) {
+ scope = Parameter::SCOPE_DOCUMENT;
+ } else if (!strcmp(scope_str, "node")) {
+ scope = Parameter::SCOPE_NODE;
+ }
+ }
+
Parameter * param = NULL;
if (!strcmp(type, "boolean")) {
- param = new ParamBool(name, guitext, in_ext, in_repr);
+ param = new ParamBool(name, guitext, desc, scope, in_ext, in_repr);
} else if (!strcmp(type, "int")) {
- param = new ParamInt(name, guitext, in_ext, in_repr);
+ param = new ParamInt(name, guitext, desc, scope, in_ext, in_repr);
} else if (!strcmp(type, "float")) {
- param = new ParamFloat(name, guitext, in_ext, in_repr);
+ param = new ParamFloat(name, guitext, desc, scope, in_ext, in_repr);
} else if (!strcmp(type, "string")) {
- param = new ParamString(name, guitext, in_ext, in_repr);
+ param = new ParamString(name, guitext, desc, scope, in_ext, in_repr);
}
/* Note: param could equal NULL */
@@ -433,8 +450,8 @@ Parameter::set_string (const gchar * in, Inkscape::XML::Document * doc, Inkscape
}
/** \brief Initialize the object, to do that, copy the data. */
-ParamString::ParamString (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, ext), _value(NULL)
+ParamString::ParamString (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), _value(NULL)
{
const char * defaultval = NULL;
if (sp_repr_children(xml) != NULL)
index 54b5e554e3ee5a06316a6e894be05958ec123079..538889cf749083493b7185b46aa9912efe158953 100644 (file)
Inkscape::Extension::Extension * extension;
/** \brief The name of this parameter. */
gchar * _name;
+
+protected:
/** \brief Description of the parameter. */
gchar * _desc;
/** \brief List of possible scopes. */
} _scope_t;
/** \brief Scope of the parameter. */
_scope_t _scope;
-
-protected:
/** \brief Text for the GUI selection of this. */
gchar * _text;
gchar * pref_name (void);