From ec8d0b742153e4715efd13fb19607c3167cc2092 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 6 Aug 2011 20:48:21 +0200 Subject: Extensions. New "indent" attribute to add an indent level to extension elements. Filters. Adding the new "indent" attribute to parameters groups. (bzr r10529) --- src/extension/param/radiobutton.cpp | 41 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src/extension/param/radiobutton.cpp') 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 * 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; -- cgit v1.2.3 From af07ce24271fc904e432cdf77714f49b8cbc8db8 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 18 Dec 2011 22:54:08 -0800 Subject: Const correctness fixes that also correct bug #893146. Fixed bugs: - https://launchpad.net/bugs/893146 (bzr r10783) --- src/extension/param/radiobutton.cpp | 78 +++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 42 deletions(-) (limited to 'src/extension/param/radiobutton.cpp') 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 * _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 * 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 * changeSignal) + * Creates a combobox widget for an enumeration parameter. + */ +Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { if (_gui_hidden) { return NULL; -- cgit v1.2.3