summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2011-12-19 06:54:08 +0000
committerJon A. Cruz <jon@joncruz.org>2011-12-19 06:54:08 +0000
commitaf07ce24271fc904e432cdf77714f49b8cbc8db8 (patch)
tree7744dbace5c21eb373a5225e03757c8d403ab5ae /src
parentRemove more deprecated GTK macros (diff)
downloadinkscape-af07ce24271fc904e432cdf77714f49b8cbc8db8.tar.gz
inkscape-af07ce24271fc904e432cdf77714f49b8cbc8db8.zip
Const correctness fixes that also correct bug #893146.
Fixed bugs: - https://launchpad.net/bugs/893146 (bzr r10783)
Diffstat (limited to 'src')
-rw-r--r--src/extension/extension.cpp43
-rw-r--r--src/extension/extension.h39
-rw-r--r--src/extension/param/bool.h7
-rw-r--r--src/extension/param/color.cpp6
-rw-r--r--src/extension/param/color.h39
-rw-r--r--src/extension/param/enum.cpp89
-rw-r--r--src/extension/param/enum.h12
-rw-r--r--src/extension/param/float.cpp64
-rw-r--r--src/extension/param/float.h19
-rw-r--r--src/extension/param/int.cpp69
-rw-r--r--src/extension/param/int.h19
-rw-r--r--src/extension/param/notebook.cpp144
-rw-r--r--src/extension/param/notebook.h26
-rw-r--r--src/extension/param/parameter.cpp269
-rw-r--r--src/extension/param/parameter.h212
-rw-r--r--src/extension/param/radiobutton.cpp78
-rw-r--r--src/extension/param/radiobutton.h24
-rw-r--r--src/extension/param/string.cpp88
-rw-r--r--src/extension/param/string.h17
19 files changed, 684 insertions, 580 deletions
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 72db7438c..f0b266df0 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -44,8 +44,6 @@ namespace Extension {
std::vector<const gchar *> Extension::search_path;
std::ofstream Extension::error_file;
-Parameter * get_param (const gchar * name);
-
/**
\return none
\brief Constructs an Extension from a Inkscape::XML::Node
@@ -381,26 +379,7 @@ Extension::deactivated (void)
return get_state() == STATE_DEACTIVATED;
}
-/**
- \return Parameter structure with a name of 'name'
- \brief This function looks through the linked list for a parameter
- structure with the name of the passed in name
- \param name The name to search for
-
- This is an inline function that is used by all the get_param and
- set_param functions to find a param_t in the linked list with
- the passed in name.
-
- This function can throw a 'param_not_exist' exception if the
- name is not found.
-
- The first thing that this function checks is if the list is NULL.
- It could be NULL because there are no parameters for this extension
- or because all of them have been checked. If the list
- is NULL then the 'param_not_exist' exception is thrown.
-*/
-Parameter *
-Extension::get_param (const gchar * name)
+Parameter *Extension::get_param(gchar const *name)
{
if (name == NULL) {
throw Extension::param_not_exist();
@@ -427,22 +406,14 @@ g_slist_next(list)) {
throw Extension::param_not_exist();
}
-/**
- \return A constant pointer to the string held by the parameters.
- \brief Gets a parameter identified by name with the string placed
- in value. It isn't duplicated into the value string.
- \param name The name of the parameter to get
- \param doc The document to look in for document specific parameters
- \param node The node to look in for a specific parameter
+Parameter const *Extension::get_param(const gchar * name) const
+{
+ return const_cast<Extension *>(this)->get_param(name);
+}
- Look up in the parameters list, then execute the function on that
- found parameter.
-*/
-const gchar *
-Extension::get_param_string (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
+gchar const *Extension::get_param_string(gchar const *name, SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- Parameter * param;
- param = get_param(name);
+ Parameter const *param = get_param(name);
return param->get_string(doc, node);
}
diff --git a/src/extension/extension.h b/src/extension/extension.h
index 273bc79e4..13cb409a8 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -173,7 +173,28 @@ public:
private:
void make_param (Inkscape::XML::Node * paramrepr);
- Parameter * get_param (const gchar * name);
+ /**
+ * This function looks through the linked list for a parameter
+ * structure with the name of the passed in name.
+ *
+ * This is an inline function that is used by all the get_param and
+ * set_param functions to find a param_t in the linked list with
+ * the passed in name.
+ *
+ * This function can throw a 'param_not_exist' exception if the
+ * name is not found.
+ *
+ * The first thing that this function checks is if the list is NULL.
+ * It could be NULL because there are no parameters for this extension
+ * or because all of them have been checked. If the list
+ * is NULL then the 'param_not_exist' exception is thrown.
+ *
+ * @param name The name to search for.
+ * @return Parameter structure with a name of 'name'.
+ */
+ Parameter *get_param(const gchar * name);
+
+ Parameter const *get_param(const gchar * name) const;
public:
bool get_param_bool (const gchar * name,
@@ -188,9 +209,19 @@ public:
const SPDocument * doc = NULL,
const Inkscape::XML::Node * node = NULL);
- const gchar * get_param_string (const gchar * name,
- const SPDocument * doc = NULL,
- const Inkscape::XML::Node * node = NULL);
+ /**
+ * Gets a parameter identified by name with the string placed in value.
+ * It isn't duplicated into the value string. Look up in the parameters list,
+ * then execute the function on that found parameter.
+ *
+ * @param name The name of the parameter to get.
+ * @param doc The document to look in for document specific parameters.
+ * @param node The node to look in for a specific parameter.
+ * @return A constant pointer to the string held by the parameters.
+ */
+ gchar const *get_param_string(gchar const *name,
+ SPDocument const *doc = NULL,
+ Inkscape::XML::Node const *node = NULL) const;
guint32 get_param_color (const gchar * name,
const SPDocument * doc = NULL,
diff --git a/src/extension/param/bool.h b/src/extension/param/bool.h
index 2894e8085..11d06e1c0 100644
--- a/src/extension/param/bool.h
+++ b/src/extension/param/bool.h
@@ -30,7 +30,7 @@ public:
/**
* Returns the current state/value.
*/
- bool get(const SPDocument * doc, const Inkscape::XML::Node * node) const;
+ bool get(const SPDocument *doc, const Inkscape::XML::Node *node) const;
/**
* A function to set the state/value.
@@ -50,11 +50,14 @@ public:
*/
Gtk::Widget *get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
/**
* Appends 'true' or 'false'.
* @todo investigate. Returning a value that can then be appended would probably work better/safer.
*/
- void string(std::string &string) const;
+ virtual void string(std::string &string) const;
private:
/** Internal value. */
diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp
index 1e5dee51c..6600d5f2a 100644
--- a/src/extension/param/color.cpp
+++ b/src/extension/param/color.cpp
@@ -3,6 +3,7 @@
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl>
* Christopher Brown <audiere@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -73,16 +74,13 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar *
defaulthex = paramval.data();
_value = atoi(defaulthex);
-
- return;
}
-void ParamColor::string (std::string &string)
+void ParamColor::string(std::string &string) const
{
char str[16];
sprintf(str, "%i", _value);
string += str;
- return;
}
Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal )
diff --git a/src/extension/param/color.h b/src/extension/param/color.h
index e6b44fbcb..f46e26286 100644
--- a/src/extension/param/color.h
+++ b/src/extension/param/color.h
@@ -1,9 +1,10 @@
-#ifndef __INK_EXTENSION_PARAMCOLOR_H__
-#define __INK_EXTENSION_PARAMCOLOR_H__
+#ifndef SEEN_INK_EXTENSION_PARAMCOLOR_H__
+#define SEEN_INK_EXTENSION_PARAMCOLOR_H__
/*
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -21,16 +22,36 @@ private:
guint32 _value;
public:
ParamColor(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 ~ParamColor(void);
- /** \brief Returns \c _value, with a \i const to protect it. */
- guint32 get( const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/ ) { return _value; }
+
+ /** Returns \c _value, with a \i const to protect it. */
+ guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _value; }
+
guint32 set (guint32 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);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string (std::string &string) const;
+
sigc::signal<void> * _changeSignal;
-}; /* class ParamColor */
+}; // class ParamColor
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
-#endif /* __INK_EXTENSION_PARAMCOLOR_H__ */
+#endif // SEEN_INK_EXTENSION_PARAMCOLOR_H__
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index e25559eeb..755cc92ad 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -7,6 +7,7 @@
/*
* Author:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006-2007 Johan Engelen
*
@@ -118,8 +119,6 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
if (defaultval != NULL) {
_value = g_strdup(defaultval);
}
-
- return;
}
ParamComboBox::~ParamComboBox (void)
@@ -134,21 +133,22 @@ ParamComboBox::~ParamComboBox (void)
}
-/** \brief A function to set the \c _value
- \param in The value to set
- \param doc A document that should be used to set the value.
- \param node The node where the value may be placed
-
- This function sets ONLY the internal value, but it also sets the value
- in the preferences structure. To put it in the right place, \c PREF_DIR
- and \c pref_name() are used.
-
- To copy the data into _value the old memory must be free'd first.
- It is important to note that \c g_free handles \c NULL just fine. Then
- the passed in value is duplicated using \c g_strdup().
-*/
-const gchar *
-ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * This function sets ONLY the internal value, but it also sets the value
+ * in the preferences structure. To put it in the right place, \c PREF_DIR
+ * and \c pref_name() are used.
+ *
+ * To copy the data into _value the old memory must be free'd first.
+ * It is important to note that \c g_free handles \c NULL just fine. Then
+ * the passed in value is duplicated using \c g_strdup().
+ *
+ * @param in The value to set.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
if (in == NULL) {
return NULL; /* Can't have NULL string */
@@ -181,22 +181,15 @@ ParamComboBox::changed (void) {
}
-
-/**
- \brief A function to get the value of the parameter in string form
- \return A string with the 'value' as command line argument
-*/
-void
-ParamComboBox::string (std::string &string)
+void ParamComboBox::string(std::string &string) const
{
string += _value;
- return;
}
-/** \brief A special category of Gtk::Entry to handle string parameteres */
+/** A special category of Gtk::Entry to handle string parameteres. */
class ParamComboBoxEntry : public Gtk::ComboBoxText {
private:
ParamComboBox * _pref;
@@ -204,10 +197,11 @@ private:
Inkscape::XML::Node * _node;
sigc::signal<void> * _changeSignal;
public:
- /** \brief Build a string preference for the given parameter
- \param pref Where to get the string from, and where to put it
- when it changes.
- */
+ /**
+ * Build a string preference for the given parameter.
+ * @param pref Where to get the string from, and where to put it
+ * when it changes.
+ */
ParamComboBoxEntry (ParamComboBox * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
Gtk::ComboBoxText(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
this->signal_changed().connect(sigc::mem_fun(this, &ParamComboBoxEntry::changed));
@@ -215,11 +209,12 @@ public:
void changed (void);
};
-/** \brief Respond to the text box changing
-
- This function responds to the box changing by grabbing the value
- from the text box and putting it in the parameter.
-*/
+/**
+ * Respond to the text box changing.
+ *
+ * This function responds to the box changing by grabbing the value
+ * from the text box and putting it in the parameter.
+ */
void
ParamComboBoxEntry::changed (void)
{
@@ -231,12 +226,11 @@ ParamComboBoxEntry::changed (void)
}
/**
- \brief Creates a combobox widget for an enumeration parameter
-*/
-Gtk::Widget *
-ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a combobox widget for an enumeration parameter.
+ */
+Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) {
+ if (_gui_hidden) {
return NULL;
}
@@ -270,5 +264,16 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
}
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h
index ca008cda5..a598458c5 100644
--- a/src/extension/param/enum.h
+++ b/src/extension/param/enum.h
@@ -6,8 +6,9 @@
*/
/*
- * Author:
+ * Authors:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006-2007 Johan Engelen
*
@@ -40,9 +41,14 @@ public:
ParamComboBox(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 ~ParamComboBox(void);
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
- const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
+ gchar const *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; }
+
const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
void changed (void);
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index ea6a70855..2b501a9a4 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -23,7 +24,7 @@ namespace Inkscape {
namespace Extension {
-/** \brief Use the superclass' allocator and set the \c _value */
+/** Use the superclass' allocator and set the \c _value. */
ParamFloat::ParamFloat (const gchar * name,
const gchar * guitext,
const gchar * desc,
@@ -88,17 +89,18 @@ ParamFloat::ParamFloat (const gchar * name,
return;
}
-/** \brief A function to set the \c _value
- \param in The value to set to
- \param doc A document that should be used to set the value.
- \param node The node where the value may be placed
-
- This function sets the internal value, but it also sets the value
- in the preferences structure. To put it in the right place, \c PREF_DIR
- and \c pref_name() are used.
-*/
-float
-ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * This function sets the internal value, but it also sets the value
+ * in the preferences structure. To put it in the right place, \c PREF_DIR
+ * and \c pref_name() are used.
+ *
+ * @param in The value to set to.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+float ParamFloat::set(float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
_value = in;
if (_value > _max) {
@@ -116,9 +118,7 @@ ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
return _value;
}
-/** \brief Return the value as a string */
-void
-ParamFloat::string (std::string &string)
+void ParamFloat::string(std::string &string) const
{
char startstring[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr(startstring, G_ASCII_DTOSTR_BUF_SIZE, _value);
@@ -126,15 +126,15 @@ ParamFloat::string (std::string &string)
return;
}
-/** \brief A class to make an adjustment that uses Extension params */
+/** A class to make an adjustment that uses Extension params. */
class ParamFloatAdjustment : public Gtk::Adjustment {
- /** The parameter to adjust */
+ /** The parameter to adjust. */
ParamFloat * _pref;
SPDocument * _doc;
Inkscape::XML::Node * _node;
sigc::signal<void> * _changeSignal;
public:
- /** \brief Make the adjustment using an extension and the string
+ /** Make the adjustment using an extension and the string
describing the parameter. */
ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
@@ -146,14 +146,13 @@ public:
void val_changed (void);
}; /* class ParamFloatAdjustment */
-/** \brief A function to respond to the value_changed signal from the
- adjustment.
-
- This function just grabs the value from the adjustment and writes
- it to the parameter. Very simple, but yet beautiful.
-*/
-void
-ParamFloatAdjustment::val_changed (void)
+/**
+ * A function to respond to the value_changed signal from the adjustment.
+ *
+ * This function just grabs the value from the adjustment and writes
+ * it to the parameter. Very simple, but yet beautiful.
+ */
+void ParamFloatAdjustment::val_changed(void)
{
//std::cout << "Value Changed to: " << this->get_value() << std::endl;
_pref->set(this->get_value(), _doc, _node);
@@ -164,14 +163,13 @@ ParamFloatAdjustment::val_changed (void)
}
/**
- \brief Creates a Float Adjustment for a float parameter
-
- Builds a hbox with a label and a float adjustment in it.
-*/
-Gtk::Widget *
-ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a Float Adjustment for a float parameter.
+ *
+ * Builds a hbox with a label and a float adjustment in it.
+ */
+Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) {
+ if (_gui_hidden) {
return NULL;
}
diff --git a/src/extension/param/float.h b/src/extension/param/float.h
index a2c19441d..24747b5f1 100644
--- a/src/extension/param/float.h
+++ b/src/extension/param/float.h
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -30,16 +31,26 @@ public:
Inkscape::Extension::Extension * ext,
Inkscape::XML::Node * xml,
AppearanceMode mode);
- /** \brief Returns \c _value */
- float get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+ /** Returns \c _value. */
+ float get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; }
+
float set (float in, SPDocument * doc, Inkscape::XML::Node * node);
+
float max (void) { return _max; }
+
float min (void) { return _min; }
+
float precision (void) { return _precision; }
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
private:
- /** \brief Internal value. */
+ /** Internal value. */
float _value;
AppearanceMode _mode;
int _indent;
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 090441c17..cd6815c4d 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -23,7 +24,7 @@ namespace Inkscape {
namespace Extension {
-/** \brief Use the superclass' allocator and set the \c _value */
+/** Use the superclass' allocator and set the \c _value. */
ParamInt::ParamInt (const gchar * name,
const gchar * guitext,
const gchar * desc,
@@ -77,21 +78,19 @@ ParamInt::ParamInt (const gchar * name,
if (_value < _min) {
_value = _min;
}
-
- return;
}
-/** \brief A function to set the \c _value
- \param in The value to set to
- \param doc A document that should be used to set the value.
- \param node The node where the value may be placed
-
- This function sets the internal value, but it also sets the value
- in the preferences structure. To put it in the right place, \c PREF_DIR
- and \c pref_name() are used.
-*/
-int
-ParamInt::set (int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ * This function sets the internal value, but it also sets the value
+ * in the preferences structure. To put it in the right place, \c PREF_DIR
+ * and \c pref_name() are used.
+ *
+ * @param in The value to set to.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+int ParamInt::set(int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
_value = in;
if (_value > _max) {
@@ -109,48 +108,45 @@ ParamInt::set (int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
return _value;
}
-/** \brief A class to make an adjustment that uses Extension params */
+/** A class to make an adjustment that uses Extension params. */
class ParamIntAdjustment : public Gtk::Adjustment {
- /** The parameter to adjust */
+ /** The parameter to adjust. */
ParamInt * _pref;
SPDocument * _doc;
Inkscape::XML::Node * _node;
sigc::signal<void> * _changeSignal;
public:
- /** \brief Make the adjustment using an extension and the string
- describing the parameter. */
+ /** Make the adjustment using an extension and the string
+ describing the parameter. */
ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
this->set_value(_pref->get(NULL, NULL) /* \todo fix */);
this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed));
- return;
};
void val_changed (void);
}; /* class ParamIntAdjustment */
-/** \brief A function to respond to the value_changed signal from the
- adjustment.
-
- This function just grabs the value from the adjustment and writes
- it to the parameter. Very simple, but yet beautiful.
-*/
-void
-ParamIntAdjustment::val_changed (void)
+/**
+ * A function to respond to the value_changed signal from the adjustment.
+ *
+ * This function just grabs the value from the adjustment and writes
+ * it to the parameter. Very simple, but yet beautiful.
+ */
+void ParamIntAdjustment::val_changed(void)
{
//std::cout << "Value Changed to: " << this->get_value() << std::endl;
_pref->set((int)this->get_value(), _doc, _node);
if (_changeSignal != NULL) {
_changeSignal->emit();
}
- return;
}
/**
- \brief Creates a Int Adjustment for a int parameter
-
- Builds a hbox with a label and a int adjustment in it.
-*/
+ * Creates a Int Adjustment for a int parameter.
+ *
+ * Builds a hbox with a label and a int adjustment in it.
+ */
Gtk::Widget *
ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
@@ -183,18 +179,15 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
return dynamic_cast<Gtk::Widget *>(hbox);
}
-/** \brief Return the value as a string */
-void
-ParamInt::string (std::string &string)
+void ParamInt::string(std::string &string) const
{
char startstring[32];
sprintf(startstring, "%d", _value);
string += startstring;
- return;
}
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/extension/param/int.h b/src/extension/param/int.h
index 138368ff3..83fc67be9 100644
--- a/src/extension/param/int.h
+++ b/src/extension/param/int.h
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -30,15 +31,25 @@ public:
Inkscape::Extension::Extension * ext,
Inkscape::XML::Node * xml,
AppearanceMode mode);
- /** \brief Returns \c _value */
- int get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+
+ /** Returns \c _value. */
+ int get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; }
+
int set (int in, SPDocument * doc, Inkscape::XML::Node * node);
+
int max (void) { return _max; }
+
int min (void) { return _min; }
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
private:
- /** \brief Internal value. */
+ /** Internal value. */
int _value;
AppearanceMode _mode;
int _indent;
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index 637208b04..80042febc 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -3,8 +3,9 @@
*/
/*
- * Author:
+ * Authors:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006 Author
*
@@ -33,15 +34,19 @@
#include "notebook.h"
-/** \brief The root directory in the preferences database for extension
- related parameters. */
+/**
+ * The root directory in the preferences database for extension
+ * related parameters.
+ */
#define PREF_DIR "extensions"
namespace Inkscape {
namespace Extension {
-// \brief A class to represent the pages of a notebookparameter of an extension
+/**
+ * A class to represent the pages of a notebookparameter of an extension.
+ */
class ParamNotebookPage : public Parameter {
private:
GSList * parameters; /**< A table to store the parameters for this page.
@@ -85,8 +90,6 @@ ParamNotebookPage::ParamNotebookPage (const gchar * name, const gchar * guitext,
child_repr = sp_repr_next(child_repr);
}
}
-
- return;
}
ParamNotebookPage::~ParamNotebookPage (void)
@@ -100,16 +103,13 @@ ParamNotebookPage::~ParamNotebookPage (void)
g_slist_free(parameters);
}
-/** \brief Return the value as a string */
-void
-ParamNotebookPage::paramString (std::list <std::string> &list)
+/** Return the value as a string. */
+void ParamNotebookPage::paramString(std::list <std::string> &list)
{
for (GSList * plist = parameters; plist != NULL; plist = g_slist_next(plist)) {
Parameter * param = reinterpret_cast<Parameter *>(plist->data);
param->string(list);
}
-
- return;
}
@@ -193,16 +193,19 @@ ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension:
/**
- \brief Creates a notebookpage widget for a notebook
-
- Builds a notebook page (a vbox) and puts parameters on it.
-*/
-Gtk::Widget *
-ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a notebookpage widget for a notebook.
+ *
+ * Builds a notebook page (a vbox) and puts parameters on it.
+ */
+Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
- if (!_tooltips) _tooltips = new Gtk::Tooltips();
+ if (!_tooltips) {
+ _tooltips = new Gtk::Tooltips();
+ }
Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox);
vbox->set_border_width(5);
@@ -266,8 +269,6 @@ ParamNotebook::ParamNotebook (const gchar * name, const gchar * guitext, const g
defaultval = paramval.data();
if (defaultval != NULL)
_value = g_strdup(defaultval); // allocate space for _value
-
- return;
}
ParamNotebook::~ParamNotebook (void)
@@ -283,21 +284,22 @@ ParamNotebook::~ParamNotebook (void)
}
-/** \brief A function to set the \c _value
- \param in The number of the page which value must be set
- \param doc A document that should be used to set the value.
- \param node The node where the value may be placed
-
- This function sets the internal value, but it also sets the value
- in the preferences structure. To put it in the right place, \c PREF_DIR
- and \c pref_name() are used.
-
- To copy the data into _value the old memory must be free'd first.
- It is important to note that \c g_free handles \c NULL just fine. Then
- the passed in value is duplicated using \c g_strdup().
-*/
-const gchar *
-ParamNotebook::set (const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * This function sets the internal value, but it also sets the value
+ * in the preferences structure. To put it in the right place, \c PREF_DIR
+ * and \c pref_name() are used.
+ *
+ * To copy the data into _value the old memory must be free'd first.
+ * It is important to note that \c g_free handles \c NULL just fine. Then
+ * the passed in value is duplicated using \c g_strdup().
+ *
+ * @param in The number of the page which value must be set.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+const gchar *ParamNotebook::set(const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
ParamNotebookPage * page = NULL;
int i = 0;
@@ -319,13 +321,7 @@ ParamNotebook::set (const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*
return _value;
}
-
-/**
- \brief A function to get the currentpage and the parameters in a string form
- \return A string with the 'value' and all the parameters on all pages as command line arguments
-*/
-void
-ParamNotebook::string (std::list <std::string> &list)
+void ParamNotebook::string(std::list <std::string> &list) const
{
std::string param_string;
param_string += "--";
@@ -341,51 +337,47 @@ ParamNotebook::string (std::list <std::string> &list)
ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(pglist->data);
page->paramString(list);
}
-
- return;
}
-/** \brief A special category of Gtk::Notebook to handle notebook parameters */
+/** A special category of Gtk::Notebook to handle notebook parameters. */
class ParamNotebookWdg : public Gtk::Notebook {
private:
ParamNotebook * _pref;
SPDocument * _doc;
Inkscape::XML::Node * _node;
public:
- /** \brief Build a notebookpage preference for the given parameter
- \param pref Where to get the string (pagename) from, and where to put it
- when it changes.
- */
+ /**
+ * Build a notebookpage preference for the given parameter.
+ * @param pref Where to get the string (pagename) from, and where to put it
+ * when it changes.
+ */
ParamNotebookWdg (ParamNotebook * pref, SPDocument * doc, Inkscape::XML::Node * node) :
Gtk::Notebook(), _pref(pref), _doc(doc), _node(node), activated(false) {
// don't have to set the correct page: this is done in ParamNotebook::get_widget.
// hook function
this->signal_switch_page().connect(sigc::mem_fun(this, &ParamNotebookWdg::changed_page));
- return;
};
void changed_page(GtkNotebookPage *page, guint pagenum);
bool activated;
};
-/** \brief Respond to the selected page of notebook changing
- This function responds to the changing by reporting it to
- ParamNotebook. The change is only reported when the notebook
- is actually visible. This to exclude 'fake' changes when the
- notebookpages are added or removed.
-*/
-void
-ParamNotebookWdg::changed_page(GtkNotebookPage */*page*/,
- guint pagenum)
+/**
+ * Respond to the selected page of notebook changing.
+ * This function responds to the changing by reporting it to
+ * ParamNotebook. The change is only reported when the notebook
+ * is actually visible. This to exclude 'fake' changes when the
+ * notebookpages are added or removed.
+ */
+void ParamNotebookWdg::changed_page(GtkNotebookPage */*page*/,
+ guint pagenum)
{
if (is_visible()) {
_pref->set((int)pagenum, _doc, _node);
}
- return;
}
-/** \brief Search the parameter's name in the notebook content */
-Parameter *
-ParamNotebook::get_param(const gchar * name)
+/** Search the parameter's name in the notebook content. */
+Parameter *ParamNotebook::get_param(const gchar * name)
{
if (name == NULL) {
throw Extension::param_not_exist();
@@ -401,9 +393,8 @@ ParamNotebook::get_param(const gchar * name)
return NULL;
}
-/** \brief Search the parameter's name in the page content */
-Parameter *
-ParamNotebookPage::get_param(const gchar * name)
+/** Search the parameter's name in the page content. */
+Parameter *ParamNotebookPage::get_param(const gchar * name)
{
if (name == NULL) {
throw Extension::param_not_exist();
@@ -424,14 +415,15 @@ ParamNotebookPage::get_param(const gchar * name)
}
/**
- \brief Creates a Notebook widget for a notebook parameter
-
- Builds a notebook and puts pages in it.
-*/
-Gtk::Widget *
-ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a Notebook widget for a notebook parameter.
+ *
+ * Builds a notebook and puts pages in it.
+ */
+Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
ParamNotebookWdg * nb = Gtk::manage(new ParamNotebookWdg(this, doc, node));
@@ -456,8 +448,8 @@ ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
}
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h
index 983ad3161..23058f465 100644
--- a/src/extension/param/notebook.h
+++ b/src/extension/param/notebook.h
@@ -8,6 +8,7 @@
/*
* Author:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006 Author
*
@@ -26,12 +27,14 @@ namespace Extension {
class Extension;
-// \brief A class to represent a notebookparameter of an extension
+/** A class to represent a notebookparameter of an extension. */
class ParamNotebook : public Parameter {
private:
- /** \brief Internal value. This should point to a string that has
- been allocated in memory. And should be free'd.
- It is the name of the current page. */
+ /**
+ * Internal value. This should point to a string that has
+ * been allocated in memory. And should be free'd.
+ * It is the name of the current page.
+ */
gchar * _value;
GSList * pages; /**< A table to store the pages with parameters for this notebook.
@@ -41,7 +44,16 @@ public:
ParamNotebook(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 ~ParamNotebook(void);
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::list <std::string> &list);
+
+ /**
+ * A function to get the currentpage and the parameters in a string form.
+ * @return A string with the 'value' and all the parameters on all pages as command line arguments.
+ */
+ virtual void string (std::list <std::string> &list) const;
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::string &string) const {return Parameter::string(string);}
+
Parameter * get_param (const gchar * name);
@@ -53,8 +65,8 @@ public:
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
#endif /* INK_EXTENSION_PARAMNOTEBOOK_H_SEEN */
diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp
index 106cd76a6..063ec32be 100644
--- a/src/extension/param/parameter.cpp
+++ b/src/extension/param/parameter.cpp
@@ -1,5 +1,5 @@
/** @file
- * @brief Parameters for extensions.
+ * Parameters for extensions.
*/
/* Author:
* Ted Gould <ted@gould.cx>
@@ -42,76 +42,52 @@
namespace Inkscape {
namespace Extension {
-/**
- \return None
- \brief This function creates a parameter that can be used later. This
- is typically done in the creation of the extension and defined
- in the XML file describing the extension (it's private so people
- have to use the system) :)
- \param in_repr The XML describing the parameter
-
- This function first grabs all of the data out of the Repr and puts
- it into local variables. Actually, these are just pointers, and the
- data is not duplicated so we need to be careful with it. If there
- isn't a name or a type in the XML, then no parameter is created as
- the function just returns.
-
- From this point on, we're pretty committed as we've allocated an
- object and we're starting to fill it. The name is set first, and
- is created with a strdup to actually allocate memory for it. Then
- there is a case statement (roughly because strcmp requires 'ifs')
- based on what type of parameter this is. Depending which type it
- is, the value is interpreted differently, but they are relatively
- straight forward. In all cases the value is set to the default
- value from the XML and the type is set to the interpreted type.
-*/
-Parameter *
-Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext)
+Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext)
{
- const char * name;
- const char * type;
- const char * guitext;
- const char * desc;
- const char * scope_str;
- Parameter::_scope_t scope = Parameter::SCOPE_USER;
- bool gui_hidden = false;
- const char * gui_hide;
- const char * gui_tip;
-
- name = in_repr->attribute("name");
- type = in_repr->attribute("type");
- guitext = in_repr->attribute("gui-text");
- if (guitext == NULL)
+ const char *name = in_repr->attribute("name");
+ const char *type = in_repr->attribute("type");
+
+ // In this case we just don't have enough information
+ if (!name || !type) {
+ return NULL;
+ }
+
+ const char *guitext = in_repr->attribute("gui-text");
+ if (guitext == NULL) {
guitext = in_repr->attribute("_gui-text");
- gui_tip = in_repr->attribute("gui-tip");
- if (gui_tip == NULL)
+ }
+ const char *gui_tip = in_repr->attribute("gui-tip");
+ if (gui_tip == NULL) {
gui_tip = in_repr->attribute("_gui-tip");
- desc = in_repr->attribute("gui-description");
- if (desc == NULL)
+ }
+ const char *desc = in_repr->attribute("gui-description");
+ if (desc == NULL) {
desc = in_repr->attribute("_gui-description");
- scope_str = in_repr->attribute("scope");
- gui_hide = in_repr->attribute("gui-hidden");
- if (gui_hide != NULL) {
- if (strcmp(gui_hide, "1") == 0 ||
- strcmp(gui_hide, "true") == 0) {
- gui_hidden = true;
- }
- /* else stays false */
- }
- const gchar* appearance = in_repr->attribute("appearance");
-
- /* In this case we just don't have enough information */
- if (name == NULL || type == NULL) {
- return NULL;
}
+ bool gui_hidden = false;
+ {
+ const char *gui_hide = in_repr->attribute("gui-hidden");
+ if (gui_hide != NULL) {
+ if (strcmp(gui_hide, "1") == 0 ||
+ strcmp(gui_hide, "true") == 0) {
+ gui_hidden = true;
+ }
+ /* else stays false */
+ }
+ }
+ const gchar* appearance = in_repr->attribute("appearance");
- 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::_scope_t scope = Parameter::SCOPE_USER;
+ {
+ const char *scope_str = in_repr->attribute("scope");
+ 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;
+ }
}
}
@@ -132,10 +108,10 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
}
} 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");
+ gchar const * max_length = in_repr->attribute("max_length");
if (max_length != NULL) {
- ParamString * ps = dynamic_cast<ParamString *>(param);
- ps->setMaxLength(atoi(max_length));
+ ParamString * ps = dynamic_cast<ParamString *>(param);
+ ps->setMaxLength(atoi(max_length));
}
} else if (!strcmp(type, "description")) {
if (appearance && !strcmp(appearance, "header")) {
@@ -157,82 +133,74 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
}
- /* Note: param could equal NULL */
+ // Note: param could equal NULL
return param;
}
-/** \brief Wrapper to cast to the object and use it's function. */
-bool
-Parameter::get_bool (const SPDocument * doc, const Inkscape::XML::Node * node)
+bool Parameter::get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamBool * boolpntr = dynamic_cast<ParamBool *>(this);
- if (boolpntr == NULL)
+ ParamBool const *boolpntr = dynamic_cast<ParamBool const *>(this);
+ if (!boolpntr) {
throw Extension::param_not_bool_param();
+ }
return boolpntr->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-int
-Parameter::get_int (const SPDocument * doc, const Inkscape::XML::Node * node)
+int Parameter::get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamInt * intpntr = dynamic_cast<ParamInt *>(this);
- if (intpntr == NULL)
+ ParamInt const *intpntr = dynamic_cast<ParamInt const *>(this);
+ if (!intpntr) {
throw Extension::param_not_int_param();
+ }
return intpntr->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-float
-Parameter::get_float (const SPDocument * doc, const Inkscape::XML::Node * node)
+float Parameter::get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamFloat * floatpntr = dynamic_cast<ParamFloat *>(this);
- if (floatpntr == NULL)
+ ParamFloat const *floatpntr = dynamic_cast<ParamFloat const *>(this);
+ if (!floatpntr) {
throw Extension::param_not_float_param();
+ }
return floatpntr->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-const gchar *
-Parameter::get_string (const SPDocument * doc, const Inkscape::XML::Node * node)
+gchar const *Parameter::get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamString * stringpntr = dynamic_cast<ParamString *>(this);
- if (stringpntr == NULL)
+ ParamString const *stringpntr = dynamic_cast<ParamString const *>(this);
+ if (!stringpntr) {
throw Extension::param_not_string_param();
+ }
return stringpntr->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-const gchar *
-Parameter::get_enum (const SPDocument * doc, const Inkscape::XML::Node * node)
+gchar const *Parameter::get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamComboBox * param = dynamic_cast<ParamComboBox *>(this);
- if (param == NULL)
+ ParamComboBox const *param = dynamic_cast<ParamComboBox const *>(this);
+ if (!param) {
throw Extension::param_not_enum_param();
+ }
return param->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-gchar const *Parameter::get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const * node)
+gchar const *Parameter::get_optiongroup(SPDocument const *doc, Inkscape::XML::Node const * node) const
{
- ParamRadioButton * param = dynamic_cast<ParamRadioButton *>(this);
+ ParamRadioButton const *param = dynamic_cast<ParamRadioButton const *>(this);
if (!param) {
throw Extension::param_not_optiongroup_param();
}
return param->get(doc, node);
}
-guint32
-Parameter::get_color(const SPDocument* doc, const Inkscape::XML::Node* node)
+guint32 Parameter::get_color(const SPDocument* doc, Inkscape::XML::Node const *node) const
{
- ParamColor* param = dynamic_cast<ParamColor *>(this);
- if (param == NULL)
+ ParamColor const *param = dynamic_cast<ParamColor const *>(this);
+ if (!param) {
throw Extension::param_not_color_param();
+ }
return param->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-bool
-Parameter::set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node)
+bool Parameter::set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node)
{
ParamBool * boolpntr = dynamic_cast<ParamBool *>(this);
if (boolpntr == NULL)
@@ -240,9 +208,7 @@ Parameter::set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node)
return boolpntr->set(in, doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-int
-Parameter::set_int (int in, SPDocument * doc, Inkscape::XML::Node * node)
+int Parameter::set_int(int in, SPDocument * doc, Inkscape::XML::Node * node)
{
ParamInt * intpntr = dynamic_cast<ParamInt *>(this);
if (intpntr == NULL)
@@ -250,7 +216,7 @@ Parameter::set_int (int in, SPDocument * doc, Inkscape::XML::Node * node)
return intpntr->set(in, doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
+/** Wrapper to cast to the object and use it's function. */
float
Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node)
{
@@ -261,9 +227,9 @@ Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node)
return floatpntr->set(in, doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-const gchar *
-Parameter::set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node)
+/** Wrapper to cast to the object and use it's function. */
+gchar const *
+Parameter::set_string (gchar const * in, SPDocument * doc, Inkscape::XML::Node * node)
{
ParamString * stringpntr = dynamic_cast<ParamString *>(this);
if (stringpntr == NULL)
@@ -281,7 +247,7 @@ gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, In
}
-/** \brief Wrapper to cast to the object and use it's function. */
+/** Wrapper to cast to the object and use it's function. */
guint32
Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node)
{
@@ -292,9 +258,15 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node)
}
-/** \brief Oop, now that we need a parameter, we need it's name. */
-Parameter::Parameter (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) :
- extension(ext), _name(NULL), _desc(NULL), _scope(scope), _text(NULL), _gui_hidden(gui_hidden), _gui_tip(NULL)
+/** Oop, now that we need a parameter, we need it's name. */
+Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, gchar const * gui_tip, Inkscape::Extension::Extension * ext) :
+ _desc(0),
+ _scope(scope),
+ _text(0),
+ _gui_hidden(gui_hidden),
+ _gui_tip(0),
+ extension(ext),
+ _name(0)
{
if (name != NULL) {
_name = g_strdup(name);
@@ -316,9 +288,15 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * d
return;
}
-/** \brief Oop, now that we need a parameter, we need it's name. */
-Parameter::Parameter (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext) :
- extension(ext), _name(NULL), _desc(NULL), _scope(Parameter::SCOPE_USER), _text(NULL), _gui_hidden(false), _gui_tip(NULL)
+/** Oop, now that we need a parameter, we need it's name. */
+Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Extension::Extension * ext) :
+ _desc(0),
+ _scope(Parameter::SCOPE_USER),
+ _text(0),
+ _gui_hidden(false),
+ _gui_tip(0),
+ extension(ext),
+ _name(0)
{
if (name != NULL) {
_name = g_strdup(name);
@@ -332,19 +310,22 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, Inkscape::Exten
return;
}
-/** \brief Just free the allocated name. */
-Parameter::~Parameter (void)
+Parameter::~Parameter(void)
{
g_free(_name);
+ _name = 0;
+
g_free(_text);
- g_free(_gui_tip);
+ _text = 0;
+
+ g_free(_gui_tip);
+ _gui_tip = 0;
+
g_free(_desc);
+ _desc = 0;
}
-/** \brief Build the name to write the parameter from the extension's
- ID and the name of this parameter. */
-gchar *
-Parameter::pref_name (void)
+gchar *Parameter::pref_name(void) const
{
return g_strdup_printf("%s.%s", extension->get_id(), _name);
}
@@ -395,49 +376,43 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc)
return params;
}
-/** \brief Basically, if there is no widget pass a NULL. */
+/** Basically, if there is no widget pass a NULL. */
Gtk::Widget *
Parameter::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
{
return NULL;
}
-/** \brief If I'm not sure which it is, just don't return a value. */
-void
-Parameter::string (std::string &/*string*/)
+/** If I'm not sure which it is, just don't return a value. */
+void Parameter::string(std::string &/*string*/) const
{
- return;
+ // TODO investigate clearing the target string.
}
-void
-Parameter::string (std::list <std::string> &list)
+void Parameter::string(std::list <std::string> &list) const
{
std::string value;
string(value);
- if (value == "") {
- return;
+ if (!value.empty()) {
+ std::string final;
+ final += "--";
+ final += name();
+ final += "=";
+ final += value;
+
+ list.insert(list.end(), final);
}
-
- std::string final;
- final += "--";
- final += name();
- final += "=";
- final += value;
-
- list.insert(list.end(), final);
- return;
}
-/** All the code in Notebook::get_param to get the notebook content. */
-Parameter *Parameter::get_param(const gchar * /*name*/)
+Parameter *Parameter::get_param(gchar const * /*name*/)
{
return NULL;
}
Glib::ustring const extension_pref_root = "/extensions/";
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h
index ad07f5306..8d80e6c40 100644
--- a/src/extension/param/parameter.h
+++ b/src/extension/param/parameter.h
@@ -1,8 +1,9 @@
/** @file
- * @brief Parameters for extensions.
+ * Parameters for extensions.
*/
/* Authors:
* Ted Gould <ted@gould.cx>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2005-2006 Authors
*
@@ -27,108 +28,169 @@ class Extension;
/**
- * @brief The root directory in the preferences database for extension-related parameters
+ * The root directory in the preferences database for extension-related parameters.
*
* The directory path has both a leading and a trailing slash, so that extension_pref_root + pref_name works
* without having to append a separator.
*/
extern Glib::ustring const extension_pref_root;
-/** \brief A class to represent the parameter of an extension
-
- This is really a super class that allows them to abstract all
- the different types of parameters into some that can be passed
- around. There is also a few functions that are used by all the
- different parameters.
-*/
+/**
+ * A class to represent the parameter of an extension.
+ *
+ * This is really a super class that allows them to abstract all
+ * the different types of parameters into some that can be passed
+ * around. There is also a few functions that are used by all the
+ * different parameters.
+ */
class Parameter {
-private:
- /** \brief Which extension is this parameter attached to? */
- 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. */
+ /** List of possible scopes. */
typedef enum {
SCOPE_USER, /**< Parameter value is saved in the user's configuration file. (default) */
SCOPE_DOCUMENT, /**< Parameter value is saved in the document. */
SCOPE_NODE /**< Parameter value is attached to the node. */
} _scope_t;
- /** \brief Scope of the parameter. */
+
+public:
+ Parameter(gchar const *name,
+ gchar const *guitext,
+ gchar const *desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ gchar const *gui_tip,
+ Inkscape::Extension::Extension * ext);
+
+ Parameter(gchar const *name,
+ gchar const *guitext,
+ Inkscape::Extension::Extension * ext);
+
+ virtual ~Parameter(void);
+
+ /** Wrapper to cast to the object and use its function. */
+ bool get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ int get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ float get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ gchar const *get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ guint32 get_color(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ gchar const *get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ gchar const *get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const *node) const;
+
+
+ /** Wrapper to cast to the object and use it's function. */
+ bool set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ /** Wrapper to cast to the object and use it's function. */
+ int set_int(int in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ float set_float(float in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ gchar const *set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node);
+
+ gchar const *set_string(gchar const * in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ guint32 set_color(guint32 in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ gchar const * name(void) const {return _name;}
+
+ /**
+ * This function creates a parameter that can be used later. This
+ * is typically done in the creation of the extension and defined
+ * in the XML file describing the extension (it's private so people
+ * have to use the system) :)
+ *
+ * This function first grabs all of the data out of the Repr and puts
+ * it into local variables. Actually, these are just pointers, and the
+ * data is not duplicated so we need to be careful with it. If there
+ * isn't a name or a type in the XML, then no parameter is created as
+ * the function just returns.
+ *
+ * From this point on, we're pretty committed as we've allocated an
+ * object and we're starting to fill it. The name is set first, and
+ * is created with a strdup to actually allocate memory for it. Then
+ * there is a case statement (roughly because strcmp requires 'ifs')
+ * based on what type of parameter this is. Depending which type it
+ * is, the value is interpreted differently, but they are relatively
+ * straight forward. In all cases the value is set to the default
+ * value from the XML and the type is set to the interpreted type.
+ *
+ * @param in_repr The XML describing the parameter.
+ * @return a pointer to a new Parameter if applicable, null otherwise..
+ */
+ static Parameter *make(Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
+
+ virtual Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+
+ gchar const * get_tooltip(void) const { return _desc; }
+
+ /** Indicates if the GUI for this parameter is hidden or not */
+ bool get_gui_hidden() const { return _gui_hidden; }
+
+ virtual void string(std::list <std::string> &list) const;
+
+ /**
+ * Gets the current value of the parameter in a string form.
+ * @return A string with the 'value'.
+ */
+ virtual void string(std::string &string) const;
+
+ /** All the code in Notebook::get_param to get the notebook content. */
+ virtual Parameter *get_param(gchar const *name);
+
+protected:
+ /** Description of the parameter. */
+ gchar * _desc;
+
+ /** Scope of the parameter. */
_scope_t _scope;
- /** \brief Text for the GUI selection of this. */
+
+ /** Text for the GUI selection of this. */
gchar * _text;
- /** \brief Whether the GUI is visible */
+
+ /** Whether the GUI is visible. */
bool _gui_hidden;
- /** \brief A tip for the GUI if there is one */
+
+ /** A tip for the GUI if there is one. */
gchar * _gui_tip;
/* **** funcs **** */
- gchar * pref_name (void);
+
+ /**
+ * Build the name to write the parameter from the extension's ID and the name of this parameter.
+ */
+ gchar *pref_name(void) const;
+
Inkscape::XML::Node * find_child (Inkscape::XML::Node * adult);
+
Inkscape::XML::Node * document_param_node (SPDocument * doc);
+
Inkscape::XML::Node * new_child (Inkscape::XML::Node * parent);
-public:
- Parameter (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);
- Parameter (const gchar * name,
- const gchar * guitext,
- Inkscape::Extension::Extension * ext);
- virtual ~Parameter (void);
-
- bool get_bool (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- int get_int (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- float get_float (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- const gchar * get_string (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- guint32 get_color (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- const gchar * get_enum (const SPDocument * doc,
- const Inkscape::XML::Node * node);
-
- gchar const * get_optiongroup( SPDocument const * doc,
- Inkscape::XML::Node const * node);
-
- bool set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node);
- int set_int (int in, SPDocument * doc, Inkscape::XML::Node * node);
- float set_float (float in, SPDocument * doc, Inkscape::XML::Node * node);
- gchar const * set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node);
- const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
- guint32 set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node);
-
- const gchar * name (void) {return _name;}
-
- static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
- virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
-
- gchar const * get_tooltip (void) { return _desc; }
-
- /** \brief Indicates if the GUI for this parameter is hidden or not */
- bool get_gui_hidden () { return _gui_hidden; }
-
- virtual void string (std::list <std::string> &list);
- virtual void string (std::string &string);
-
- virtual Parameter * get_param (const gchar * name);
+private:
+ /** Which extension is this parameter attached to. */
+ Inkscape::Extension::Extension *extension;
+
+ /** The name of this parameter. */
+ gchar *_name;
};
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
-#endif /* __INK_EXTENSION_PARAM_H__ */
+#endif // SEEN_INK_EXTENSION_PARAM_H__
/*
Local Variables:
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index a805efc7e..a9fcbfd6c 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -35,8 +35,10 @@
#include "radiobutton.h"
-/** \brief The root directory in the preferences database for extension
- related parameters. */
+/**
+ * The root directory in the preferences database for extension
+ * related parameters.
+ */
#define PREF_DIR "extensions"
namespace Inkscape {
@@ -136,8 +138,6 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
if (defaultval != NULL) {
_value = g_strdup(defaultval); // allocate space for _value
}
-
- return;
}
ParamRadioButton::~ParamRadioButton (void)
@@ -152,21 +152,22 @@ ParamRadioButton::~ParamRadioButton (void)
}
-/** \brief A function to set the \c _value
- \param in The value to set
- \param doc A document that should be used to set the value.
- \param node The node where the value may be placed
-
- This function sets ONLY the internal value, but it also sets the value
- in the preferences structure. To put it in the right place, \c PREF_DIR
- and \c pref_name() are used.
-
- To copy the data into _value the old memory must be free'd first.
- It is important to note that \c g_free handles \c NULL just fine. Then
- the passed in value is duplicated using \c g_strdup().
-*/
-const gchar *
-ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * This function sets ONLY the internal value, but it also sets the value
+ * in the preferences structure. To put it in the right place, \c PREF_DIR
+ * and \c pref_name() are used.
+ *
+ * To copy the data into _value the old memory must be free'd first.
+ * It is important to note that \c g_free handles \c NULL just fine. Then
+ * the passed in value is duplicated using \c g_strdup().
+ *
+ * @param in The value to set.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
if (in == NULL) {
return NULL; /* Can't have NULL string */
@@ -194,19 +195,12 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No
return _value;
}
-
-/**
- \brief A function to get the current value of the parameter in a string form
- \return A string with the 'value' as command line argument
-*/
-void
-ParamRadioButton::string (std::string &string)
+void ParamRadioButton::string(std::string &string) const
{
string += _value;
- return;
}
-/** \brief A special radiobutton class to use in ParamRadioButton */
+/** A special radiobutton class to use in ParamRadioButton. */
class ParamRadioButtonWdg : public Gtk::RadioButton {
private:
ParamRadioButton * _pref;
@@ -214,9 +208,10 @@ private:
Inkscape::XML::Node * _node;
sigc::signal<void> * _changeSignal;
public:
- /** \brief Build a string preference for the given parameter
- \param pref Where to put the radiobutton's string when it is selected.
- */
+ /**
+ * Build a string preference for the given parameter.
+ * @param pref Where to put the radiobutton's string when it is selected.
+ */
ParamRadioButtonWdg ( Gtk::RadioButtonGroup& group, const Glib::ustring& label,
ParamRadioButton * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal ) :
Gtk::RadioButton(group, label), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
@@ -233,13 +228,13 @@ public:
void changed (void);
};
-/** \brief Respond to the selected radiobutton changing
-
- This function responds to the radiobutton selection changing by grabbing the value
- from the text box and putting it in the parameter.
-*/
-void
-ParamRadioButtonWdg::changed (void)
+/**
+ * Respond to the selected radiobutton changing.
+ *
+ * This function responds to the radiobutton selection changing by grabbing the value
+ * from the text box and putting it in the parameter.
+ */
+void ParamRadioButtonWdg::changed(void)
{
if (this->get_active()) {
Glib::ustring data = this->get_label();
@@ -275,10 +270,9 @@ protected:
};
/**
- \brief Creates a combobox widget for an enumeration parameter
-*/
-Gtk::Widget *
-ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a combobox widget for an enumeration parameter.
+ */
+Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
if (_gui_hidden) {
return NULL;
diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h
index cf33bb381..957a5b9df 100644
--- a/src/extension/param/radiobutton.h
+++ b/src/extension/param/radiobutton.h
@@ -6,8 +6,9 @@
*/
/*
- * Author:
+ * Authors:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006-2007 Johan Engelen
*
@@ -44,10 +45,15 @@ public:
AppearanceMode mode);
virtual ~ParamRadioButton(void);
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
- const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
- const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
+ const gchar *get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; }
+
+ const gchar *set(const gchar *in, SPDocument *doc, Inkscape::XML::Node *node);
private:
/** \brief Internal value. This should point to a string that has
@@ -69,3 +75,13 @@ private:
#endif /* INK_EXTENSION_PARAMRADIOBUTTON_H_SEEN */
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp
index 18cc754a6..13b8e326a 100644
--- a/src/extension/param/string.cpp
+++ b/src/extension/param/string.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -22,27 +23,29 @@ namespace Inkscape {
namespace Extension {
-/** \brief Free the allocated data. */
+/** Free the allocated data. */
ParamString::~ParamString(void)
{
g_free(_value);
+ _value = 0;
}
-/** \brief A function to set the \c _value
- \param in The value to set to
- \param doc A document that should be used to set the value.
- \param node The node where the value may be placed
-
- This function sets the internal value, but it also sets the value
- in the preferences structure. To put it in the right place, \c PREF_DIR
- and \c pref_name() are used.
-
- To copy the data into _value the old memory must be free'd first.
- It is important to note that \c g_free handles \c NULL just fine. Then
- the passed in value is duplicated using \c g_strdup().
-*/
-const gchar *
-ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * This function sets the internal value, but it also sets the value
+ * in the preferences structure. To put it in the right place, \c PREF_DIR
+ * and \c pref_name() are used.
+ *
+ * To copy the data into _value the old memory must be free'd first.
+ * It is important to note that \c g_free handles \c NULL just fine. Then
+ * the passed in value is duplicated using \c g_strdup().
+ *
+ * @param in The value to set to.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+const gchar * ParamString::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
if (in == NULL) {
return NULL; /* Can't have NULL string */
@@ -62,18 +65,14 @@ ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node *
return _value;
}
-/** \brief Return the value as a string */
-void
-ParamString::string (std::string &string)
+void ParamString::string(std::string &string) const
{
- if (_value == NULL) {
- return;
+ if (_value) {
+ string += _value;
}
- string += _value;
- return;
}
-/** \brief Initialize the object, to do that, copy the data. */
+/** Initialize the object, to do that, copy the data. */
ParamString::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) :
Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
_value(NULL), _indent(0)
@@ -101,11 +100,9 @@ ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar
}
_max_length = 0;
-
- return;
}
-/** \brief A special type of Gtk::Entry to handle string parameteres */
+/** A special type of Gtk::Entry to handle string parameteres. */
class ParamStringEntry : public Gtk::Entry {
private:
ParamString * _pref;
@@ -113,10 +110,11 @@ private:
Inkscape::XML::Node * _node;
sigc::signal<void> * _changeSignal;
public:
- /** \brief Build a string preference for the given parameter
- \param pref Where to get the string from, and where to put it
- when it changes.
- */
+ /**
+ * Build a string preference for the given parameter.
+ * @param pref Where to get the string from, and where to put it
+ * when it changes.
+ */
ParamStringEntry (ParamString * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
if (_pref->get(NULL, NULL) != NULL) {
@@ -129,31 +127,29 @@ public:
};
-/** \brief Respond to the text box changing
-
- This function responds to the box changing by grabbing the value
- from the text box and putting it in the parameter.
-*/
-void
-ParamStringEntry::changed_text (void)
+/**
+ * Respond to the text box changing.
+ *
+ * This function responds to the box changing by grabbing the value
+ * from the text box and putting it in the parameter.
+ */
+void ParamStringEntry::changed_text(void)
{
Glib::ustring data = this->get_text();
_pref->set(data.c_str(), _doc, _node);
if (_changeSignal != NULL) {
_changeSignal->emit();
}
- return;
}
/**
- \brief Creates a text box for the string parameter
-
- Builds a hbox with a label and a text box in it.
-*/
-Gtk::Widget *
-ParamString::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a text box for the string parameter.
+ *
+ * Builds a hbox with a label and a text box in it.
+ */
+Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) {
+ if (_gui_hidden) {
return NULL;
}
diff --git a/src/extension/param/string.h b/src/extension/param/string.h
index a1892fe9c..8e7f093f7 100644
--- a/src/extension/param/string.h
+++ b/src/extension/param/string.h
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -28,18 +29,26 @@ private:
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);
+
/** \brief Returns \c _value, with a \i const to protect it. */
- const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+ const gchar *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; }
+
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);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
void setMaxLength(int maxLenght) { _max_length = maxLenght; }
int getMaxLength(void) { return _max_length; }
};
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
#endif /* INK_EXTENSION_PARAMSTRING_H_SEEN */