summaryrefslogtreecommitdiffstats
path: root/src/extension/param/radiobutton.cpp
diff options
context:
space:
mode:
authorAndrew Higginson <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
committerAndrew <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
commit80960b623a99aae1402ab651b2974ef544ed3b03 (patch)
treeba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/extension/param/radiobutton.cpp
parenttry to fix bug (diff)
parentGDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff)
downloadinkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz
inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/extension/param/radiobutton.cpp')
-rw-r--r--src/extension/param/radiobutton.cpp119
1 files changed, 63 insertions, 56 deletions
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 23655baea..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 {
@@ -69,9 +71,7 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
Inkscape::XML::Node * xml,
AppearanceMode mode) :
Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(0),
- _mode(mode),
- choices(0)
+ _value(0), _mode(mode), _indent(0), choices(0)
{
// Read XML tree to add enumeration items:
// printf("Extension Constructor: ");
@@ -95,16 +95,17 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
} else {
newguitext = new Glib::ustring(contents);
}
- } else
+ } else {
continue;
-
+ }
const char * val = child_repr->attribute("value");
- if (val != NULL)
+ if (val != NULL) {
newvalue = new Glib::ustring(val);
- else
+ } else {
newvalue = new Glib::ustring(contents);
+ }
if ( (newguitext) && (newvalue) ) { // logical error if this is not true here
choices = g_slist_append( choices, new optionentry(newvalue, newguitext) );
@@ -117,20 +118,26 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
// Initialize _value with the default value from xml
// for simplicity : default to the contents of the first xml-child
const char * defaultval = NULL;
- if (choices)
+ if (choices) {
defaultval = ((optionentry*) choices->data)->value->c_str();
+ }
+
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
- if (!paramval.empty())
+ if (!paramval.empty()) {
defaultval = paramval.data();
- if (defaultval != NULL)
+ }
+ if (defaultval != NULL) {
_value = g_strdup(defaultval); // allocate space for _value
-
- return;
+ }
}
ParamRadioButton::~ParamRadioButton (void)
@@ -145,23 +152,26 @@ 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 */
+ if (in == NULL) {
+ return NULL; /* Can't have NULL string */
+ }
Glib::ustring * settext = NULL;
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
@@ -172,7 +182,9 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No
}
}
if (settext) {
- if (_value != NULL) g_free(_value);
+ if (_value != NULL) {
+ g_free(_value);
+ }
_value = g_strdup(settext->c_str());
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -183,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;
@@ -203,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) {
@@ -222,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();
@@ -264,19 +270,20 @@ 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;
+ if (_gui_hidden) {
+ return NULL;
+ }
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0));
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT, Gtk::ALIGN_TOP));
label->show();
- hbox->pack_start(*label, false, false);
+ hbox->pack_start(*label, false, false, _indent);
Gtk::ComboBoxText* cbt = 0;
bool comboSet = false;