summaryrefslogtreecommitdiffstats
path: root/src/extension/param/enum.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/enum.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/enum.cpp')
-rw-r--r--src/extension/param/enum.cpp130
1 files changed, 77 insertions, 53 deletions
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index 9ed5aac16..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
*
@@ -49,7 +50,7 @@ public:
ParamComboBox::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) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _indent(0)
{
choices = NULL;
_value = NULL;
@@ -62,7 +63,9 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
if (!strcmp(chname, INKSCAPE_EXTENSION_NS "item") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) {
Glib::ustring newguitext, newvalue;
const char * contents = NULL;
- if (node->firstChild()) contents = node->firstChild()->content();
+ if (node->firstChild()) {
+ contents = node->firstChild()->content();
+ }
if (contents != NULL) {
// don't translate when 'item' but do translate when '_item'
// NOTE: internal extensions use build_from_mem and don't need _item but
@@ -80,10 +83,11 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
continue;
const char * val = node->attribute("value");
- if (val != NULL)
+ if (val != NULL) {
newvalue = val;
- else
+ } else {
newvalue = contents;
+ }
if ( (!newguitext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here
choices = g_slist_append( choices, new enumentry(newvalue, newguitext) );
@@ -95,20 +99,26 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
// Initialize _value with the default value from xml
// for simplicity : default to the contents of the first xml-child
const char * defaultval = NULL;
- if (xml->firstChild() && xml->firstChild()->firstChild())
+ if (xml->firstChild() && xml->firstChild()->firstChild()) {
defaultval = xml->firstChild()->attribute("value");
+ }
+
+ 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);
-
- return;
+ }
}
ParamComboBox::~ParamComboBox (void)
@@ -123,23 +133,26 @@ 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 */
+ if (in == NULL) {
+ return NULL; /* Can't have NULL string */
+ }
Glib::ustring settext;
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
@@ -150,7 +163,9 @@ ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node
}
}
if (!settext.empty()) {
- if (_value != NULL) g_free(_value);
+ if (_value != NULL) {
+ g_free(_value);
+ }
_value = g_strdup(settext.data());
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -166,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;
@@ -189,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));
@@ -200,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)
{
@@ -216,18 +226,19 @@ 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) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
label->show();
- hbox->pack_start(*label, false, false);
+ hbox->pack_start(*label, false, false, _indent);
ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal));
// add choice strings:
@@ -240,7 +251,9 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
settext = entr->guitext;
}
}
- if (!settext.empty()) combo->set_active_text(settext);
+ if (!settext.empty()) {
+ combo->set_active_text(settext);
+ }
combo->show();
hbox->pack_start(*combo, true, true);
@@ -251,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 :