diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2011-08-06 18:48:21 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2011-08-06 18:48:21 +0000 |
| commit | ec8d0b742153e4715efd13fb19607c3167cc2092 (patch) | |
| tree | d26d7c4e09e293481d9cf5af322b4178f6deb605 /src/extension/param/enum.cpp | |
| parent | Patch from Yu-Jie Lin for bug 820863 to add the option to disable libwpg (diff) | |
| download | inkscape-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/enum.cpp')
| -rw-r--r-- | src/extension/param/enum.cpp | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 9ed5aac16..e25559eeb 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -49,7 +49,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 +62,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 +82,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,18 +98,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; } @@ -139,7 +150,9 @@ ParamComboBox::~ParamComboBox (void) 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(); @@ -221,13 +236,15 @@ ParamComboBoxEntry::changed (void) 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 +257,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); |
