summaryrefslogtreecommitdiffstats
path: root/src/extension/param/radiobutton.cpp
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2011-08-06 18:48:21 +0000
committerJazzyNico <nicoduf@yahoo.fr>2011-08-06 18:48:21 +0000
commitec8d0b742153e4715efd13fb19607c3167cc2092 (patch)
treed26d7c4e09e293481d9cf5af322b4178f6deb605 /src/extension/param/radiobutton.cpp
parentPatch from Yu-Jie Lin for bug 820863 to add the option to disable libwpg (diff)
downloadinkscape-ec8d0b742153e4715efd13fb19607c3167cc2092.tar.gz
inkscape-ec8d0b742153e4715efd13fb19607c3167cc2092.zip
Extensions. New "indent" attribute to add an indent level to extension elements.
Filters. Adding the new "indent" attribute to parameters groups. (bzr r10529)
Diffstat (limited to 'src/extension/param/radiobutton.cpp')
-rw-r--r--src/extension/param/radiobutton.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 23655baea..a805efc7e 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -69,9 +69,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 +93,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,18 +116,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;
}
@@ -161,7 +168,9 @@ ParamRadioButton::~ParamRadioButton (void)
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 +181,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();
@@ -269,14 +280,16 @@ protected:
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;