summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2017-10-01 15:49:26 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2017-10-01 15:49:26 +0000
commite0957537cd0938313803c290a2f3922a3889e6f1 (patch)
tree7f158d00a7655ee91ac094f676f6b3bd624a78b7 /src/extension
parentMerge branch 'master' of gitlab.com:inkscape/inkscape (diff)
downloadinkscape-e0957537cd0938313803c290a2f3922a3889e6f1.tar.gz
inkscape-e0957537cd0938313803c290a2f3922a3889e6f1.zip
Removed all GSList occurences in .h files
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/extension.cpp24
-rw-r--r--src/extension/extension.h5
-rw-r--r--src/extension/internal/cairo-render-context.cpp14
-rw-r--r--src/extension/internal/cairo-render-context.h2
-rw-r--r--src/extension/internal/cairo-renderer.cpp8
-rw-r--r--src/extension/param/enum.cpp32
-rw-r--r--src/extension/param/enum.h18
-rw-r--r--src/extension/param/notebook.cpp125
-rw-r--r--src/extension/param/notebook.h29
-rw-r--r--src/extension/param/radiobutton.cpp36
-rw-r--r--src/extension/param/radiobutton.h20
11 files changed, 138 insertions, 175 deletions
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index f1b328f05..d9ea5eca7 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -64,7 +64,6 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat
id = NULL;
name = NULL;
_state = STATE_UNLOADED;
- parameters = NULL;
if (in_imp == NULL) {
imp = new Implementation::Implementation();
@@ -97,7 +96,7 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat
Parameter * param;
param = Parameter::make(child_repr, this);
if (param != NULL)
- parameters = g_slist_append(parameters, param);
+ parameters.push_back(param);
} /* param || _param */
if (!strcmp(chname, "dependency")) {
_deps.push_back(new Dependency(child_repr));
@@ -146,12 +145,9 @@ Extension::~Extension (void)
/** \todo Need to do parameters here */
// delete parameters:
- for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
- Parameter * param = reinterpret_cast<Parameter *>(list->data);
+ for (auto param:parameters) {
delete param;
}
- g_slist_free(parameters);
-
for (unsigned int i = 0 ; i < _deps.size(); i++) {
delete _deps[i];
@@ -402,14 +398,11 @@ Parameter *Extension::get_param(gchar const *name)
if (name == NULL) {
throw Extension::param_not_exist();
}
- if (this->parameters == NULL) {
- // the list of parameters is empty
+ if (this->parameters.empty()) {
throw Extension::param_not_exist();
}
- for (GSList * list = this->parameters; list != NULL; list =
-g_slist_next(list)) {
- Parameter * param = static_cast<Parameter*>(list->data);
+ for( auto param:this->parameters) {
if (!strcmp(param->name(), name)) {
return param;
} else {
@@ -730,8 +723,7 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<v
agui->set_spacing(Parameter::GUI_BOX_SPACING);
//go through the list of parameters to see if there are any non-hidden ones
- for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
- Parameter * param = reinterpret_cast<Parameter *>(list->data);
+ for (auto param:parameters) {
if (param->get_hidden()) continue; //Ignore hidden parameters
Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
gchar const * tip = param->get_tooltip();
@@ -751,8 +743,7 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<v
void
Extension::paramListString (std::list <std::string> &retlist)
{
- for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
- Parameter * param = reinterpret_cast<Parameter *>(list->data);
+ for(auto param:parameters) {
param->string(retlist);
}
@@ -835,8 +826,7 @@ Extension::get_params_widget(void)
unsigned int Extension::param_visible_count ( )
{
unsigned int _visible_count = 0;
- for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
- Parameter * param = reinterpret_cast<Parameter *>(list->data);
+ for (auto param:parameters) {
if (!param->get_hidden()) _visible_count++;
}
return _visible_count;
diff --git a/src/extension/extension.h b/src/extension/extension.h
index 962c3c8a7..9ccc9869b 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -133,7 +133,7 @@ public:
/* Parameter Stuff */
private:
- GSList * parameters; /**< A table to store the parameters for this extension.
+ std::vector<Parameter *> parameters; /**< A table to store the parameters for this extension.
This only gets created if there are parameters in this
extension */
@@ -141,8 +141,7 @@ public:
/** \brief A function to get the number of parameters that
the extension has.
\return The number of parameters. */
- unsigned int param_count ( ) { return parameters == NULL ? 0 :
- g_slist_length(parameters); };
+ unsigned int param_count ( ) { return parameters.size(); };
/** \brief A function to get the number of parameters that
are visible to the user that the extension has.
\return The number of visible parameters.
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index c513744a8..3edb58a13 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -163,10 +163,10 @@ CairoRenderState* CairoRenderContext::getCurrentState(void) const
CairoRenderState* CairoRenderContext::getParentState(void) const
{
// if this is the root node just return it
- if (g_slist_length(_state_stack) == 1) {
+ if (_state_stack.size() == 1) {
return _state;
} else {
- return static_cast<CairoRenderState *>(g_slist_nth_data(_state_stack, 1));
+ return _state_stack[_state_stack.size()-2];
}
}
@@ -975,7 +975,7 @@ void CairoRenderContext::pushState(void)
CairoRenderState *new_state = _createState();
// copy current state's transform
new_state->transform = _state->transform;
- _state_stack = g_slist_prepend(_state_stack, new_state);
+ _state_stack.push_back(new_state);
_state = new_state;
}
@@ -985,11 +985,11 @@ void CairoRenderContext::popState(void)
cairo_restore(_cr);
- g_free(_state_stack->data);
- _state_stack = g_slist_remove_link(_state_stack, _state_stack);
- _state = static_cast<CairoRenderState*>(_state_stack->data);
+ g_free(_state_stack.back());
+ _state_stack.pop_back();
- g_assert( g_slist_length(_state_stack) > 0 );
+ g_assert( !_state_stack.empty());
+ _state = _state_stack.back();
}
static bool pattern_hasItemChildren(SPPattern *pat)
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index 9b976fd6d..be5169a74 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -198,7 +198,7 @@ protected:
unsigned int _clip_rule : 8;
unsigned int _clip_winding_failed : 1;
- GSList *_state_stack;
+ std::vector<CairoRenderState *> _state_stack;
CairoRenderState *_state; // the current state
CairoRenderer *_renderer;
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index a2b8fb22f..3724a5e17 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -121,13 +121,12 @@ CairoRenderer::createContext(void)
CairoRenderContext *new_context = new CairoRenderContext(this);
g_assert( new_context != NULL );
- new_context->_state_stack = NULL;
new_context->_state = NULL;
// create initial render state
CairoRenderState *state = new_context->_createState();
state->transform = Geom::identity();
- new_context->_state_stack = g_slist_prepend(new_context->_state_stack, state);
+ new_context->_state_stack.push_back(state);
new_context->_state = state;
return new_context;
@@ -517,20 +516,17 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
// Do the export
SPDocument *document = item->document;
- GSList *items = NULL;
- items = g_slist_append(items, item);
boost::scoped_ptr<Inkscape::Pixbuf> pb(
sp_generate_internal_bitmap(document, NULL,
bbox->min()[Geom::X], bbox->min()[Geom::Y], bbox->max()[Geom::X], bbox->max()[Geom::Y],
- width, height, res, res, (guint32) 0xffffff00, items ));
+ width, height, res, res, (guint32) 0xffffff00, item ));
if (pb) {
//TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL ));
ctx->renderImage(pb.get(), t, item->style);
}
- g_slist_free (items);
}
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index 7cd860465..db34a6ef9 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -32,20 +32,6 @@
namespace Inkscape {
namespace Extension {
-/* For internal use only.
- Note that value and text MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */
-class enumentry {
-public:
- enumentry (Glib::ustring &val, Glib::ustring &text) :
- value(val),
- text(text)
- {}
-
- Glib::ustring value;
- Glib::ustring text;
-};
-
-
ParamComboBox::ParamComboBox(const gchar * name,
const gchar * text,
const gchar * description,
@@ -55,7 +41,6 @@ ParamComboBox::ParamComboBox(const gchar * name,
Inkscape::XML::Node * xml)
: Parameter(name, text, description, hidden, indent, ext)
, _value(NULL)
- , choices(NULL)
{
const char *xmlval = NULL; // the value stored in XML
@@ -93,7 +78,7 @@ ParamComboBox::ParamComboBox(const gchar * name,
}
if ( (!newtext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here
- choices = g_slist_append( choices, new enumentry(newvalue, newtext) );
+ choices.push_back(new enumentry(newvalue, newtext) );
}
}
}
@@ -120,11 +105,9 @@ ParamComboBox::ParamComboBox(const gchar * name,
ParamComboBox::~ParamComboBox (void)
{
//destroy choice strings
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- delete (reinterpret_cast<enumentry *>(list->data));
+ for (auto i:choices) {
+ delete i;
}
- g_slist_free(choices);
-
g_free(_value);
}
@@ -151,8 +134,7 @@ const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape
}
Glib::ustring settext;
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- enumentry * entr = reinterpret_cast<enumentry *>(list->data);
+ for (auto entr:choices) {
if ( !entr->text.compare(in) ) {
settext = entr->value;
break; // break out of for loop
@@ -181,8 +163,7 @@ bool ParamComboBox::contains(const gchar * text, SPDocument const * /*doc*/, Ink
return false; /* Can't have NULL string */
}
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- enumentry * entr = reinterpret_cast<enumentry *>(list->data);
+ for (auto entr:choices) {
if ( !entr->text.compare(text) )
return true;
}
@@ -256,8 +237,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n
ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal));
// add choice strings:
Glib::ustring settext;
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- enumentry * entr = reinterpret_cast<enumentry *>(list->data);
+ for (auto entr:choices) {
Glib::ustring text = entr->text;
combo->append(text);
diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h
index 143a648d7..d34c0dcaa 100644
--- a/src/extension/param/enum.h
+++ b/src/extension/param/enum.h
@@ -34,7 +34,23 @@ private:
been allocated in memory. And should be free'd.
It is the value of the current selected string */
gchar * _value;
- GSList * choices; /**< A table to store the choice strings */
+
+ /* For internal use only.
+ * Note that value and text MUST be non-NULL.
+ * This is ensured by newing only at one location in the code where non-NULL checks are made.
+ */
+ class enumentry {
+ public:
+ enumentry (Glib::ustring &val, Glib::ustring &text) :
+ value(val),
+ text(text)
+ {}
+
+ Glib::ustring value;
+ Glib::ustring text;
+ };
+
+ std::vector<enumentry *> choices; /**< A table to store the choice strings */
public:
ParamComboBox(const gchar * name,
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index 4e94b5216..220d6eb32 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -42,34 +42,7 @@ namespace Inkscape {
namespace Extension {
-/**
- * A class to represent the pages of a notebookparameter of an extension.
- */
-class ParamNotebookPage : public Parameter {
-private:
- GSList * parameters; /**< A table to store the parameters for this page.
- This only gets created if there are parameters on this
- page */
-
-public:
- static ParamNotebookPage * makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
-
- ParamNotebookPage(const gchar * name,
- const gchar * text,
- const gchar * description,
- bool hidden,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml);
- ~ParamNotebookPage(void);
-
- Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void paramString (std::list <std::string> &list);
- gchar * get_text (void) {return _text;};
- Parameter * get_param (const gchar * name);
-}; /* class ParamNotebookPage */
-
-
-ParamNotebookPage::ParamNotebookPage(const gchar * name,
+ParamNotebook::ParamNotebookPage::ParamNotebookPage(const gchar * name,
const gchar * text,
const gchar * description,
bool hidden,
@@ -77,7 +50,6 @@ ParamNotebookPage::ParamNotebookPage(const gchar * name,
Inkscape::XML::Node * xml)
: Parameter(name, text, description, hidden, /*indent*/ 0, ext)
{
- parameters = NULL;
// Read XML to build page
if (xml != NULL) {
@@ -92,28 +64,25 @@ ParamNotebookPage::ParamNotebookPage(const gchar * name,
if (!strcmp(chname, "param") || !strcmp(chname, "_param")) {
Parameter * param;
param = Parameter::make(child_repr, ext);
- if (param != NULL) parameters = g_slist_append(parameters, param);
+ if (param != NULL) parameters.push_back(param);
}
child_repr = child_repr->next();
}
}
}
-ParamNotebookPage::~ParamNotebookPage (void)
+ParamNotebook::ParamNotebookPage::~ParamNotebookPage (void)
{
//destroy parameters
- for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
- Parameter * param = reinterpret_cast<Parameter *>(list->data);
+ for (auto param:parameters) {
delete param;
}
- g_slist_free(parameters);
}
/** Return the value as a string. */
-void ParamNotebookPage::paramString(std::list <std::string> &list)
+void ParamNotebook::ParamNotebookPage::paramString(std::list <std::string> &list)
{
- for (GSList * plist = parameters; plist != NULL; plist = g_slist_next(plist)) {
- Parameter * param = reinterpret_cast<Parameter *>(plist->data);
+ for (auto param:parameters) {
param->string(list);
}
}
@@ -143,8 +112,8 @@ void ParamNotebookPage::paramString(std::list <std::string> &list)
straight forward. In all cases the value is set to the default
value from the XML and the type is set to the interpreted type.
*/
-ParamNotebookPage *
-ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext)
+ParamNotebook::ParamNotebookPage *
+ParamNotebook::ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext)
{
const char * name;
const char * text;
@@ -186,7 +155,7 @@ ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension:
*
* Builds a notebook page (a vbox) and puts parameters on it.
*/
-Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+Gtk::Widget * ParamNotebook::ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
if (_hidden) {
return NULL;
@@ -197,8 +166,7 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod
vbox->set_spacing(Parameter::GUI_BOX_SPACING);
// add parameters onto page (if any)
- for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
- Parameter * param = reinterpret_cast<Parameter *>(list->data);
+ for (auto param:parameters) {
Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
if (widg) {
int indent = param->get_indent();
@@ -224,6 +192,28 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod
return dynamic_cast<Gtk::Widget *>(vbox);
}
+/** Search the parameter's name in the page content. */
+Parameter *ParamNotebook::ParamNotebookPage::get_param(const gchar * name)
+{
+ if (name == NULL) {
+ throw Extension::param_not_exist();
+ }
+ if (this->parameters.empty()) {
+ // the list of parameters is empty
+ throw Extension::param_not_exist();
+ }
+
+ for (auto param:parameters) {
+ if (!strcmp(param->name(), name)) {
+ return param;
+ }
+ }
+
+ return NULL;
+}
+
+/** End ParamNotebookPage **/
+/** ParamNotebook **/
ParamNotebook::ParamNotebook(const gchar * name,
const gchar * text,
@@ -234,8 +224,6 @@ ParamNotebook::ParamNotebook(const gchar * name,
Inkscape::XML::Node * xml)
: Parameter(name, text, description, hidden, indent, ext)
{
- pages = NULL;
-
// Read XML tree to add pages:
if (xml != NULL) {
Inkscape::XML::Node *child_repr = xml->firstChild();
@@ -249,7 +237,7 @@ ParamNotebook::ParamNotebook(const gchar * name,
if (!strcmp(chname, "page")) {
ParamNotebookPage * page;
page = ParamNotebookPage::makepage(child_repr, ext);
- if (page != NULL) pages = g_slist_append(pages, page);
+ if (page != NULL) pages.push_back(page);
}
child_repr = child_repr->next();
}
@@ -258,9 +246,8 @@ ParamNotebook::ParamNotebook(const gchar * name,
// Initialize _value with the current page
const char * defaultval = NULL;
// set first page as default
- if (pages != NULL) {
- ParamNotebookPage * defpage = reinterpret_cast<ParamNotebookPage *>(pages->data);
- defaultval = defpage->name();
+ if (!pages.empty()) {
+ defaultval = pages[0]->name();
}
gchar * pref_name = this->pref_name();
@@ -277,12 +264,9 @@ ParamNotebook::ParamNotebook(const gchar * name,
ParamNotebook::~ParamNotebook (void)
{
//destroy pages
- for (GSList * list = pages; list != NULL; list = g_slist_next(list)) {
- ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(list->data);
+ for (auto page:pages) {
delete page;
}
- g_slist_free(pages);
-
g_free(_value);
}
@@ -304,12 +288,8 @@ ParamNotebook::~ParamNotebook (void)
*/
const gchar *ParamNotebook::set(const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
- ParamNotebookPage * page = NULL;
- int i = 0;
- for (GSList * list = pages; (list != NULL) && (i <= in); list = g_slist_next(list)) {
- page = reinterpret_cast<ParamNotebookPage *>(list->data);
- i++;
- }
+ int i = in < pages.size() ? in : pages.size()-1;
+ ParamNotebookPage * page = pages[i];
if (page == NULL) return _value;
@@ -336,8 +316,7 @@ void ParamNotebook::string(std::list <std::string> &list) const
param_string += "\"";
list.insert(list.end(), param_string);
- for (GSList * pglist = pages; pglist != NULL; pglist = g_slist_next(pglist)) {
- ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(pglist->data);
+ for (auto page:pages) {
page->paramString(list);
}
}
@@ -384,8 +363,7 @@ Parameter *ParamNotebook::get_param(const gchar * name)
if (name == NULL) {
throw Extension::param_not_exist();
}
- for (GSList * pglist = pages; pglist != NULL; pglist = g_slist_next(pglist)) {
- ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(pglist->data);
+ for (auto page:pages) {
Parameter * subparam = page->get_param(name);
if (subparam) {
return subparam;
@@ -395,26 +373,6 @@ Parameter *ParamNotebook::get_param(const gchar * name)
return NULL;
}
-/** Search the parameter's name in the page content. */
-Parameter *ParamNotebookPage::get_param(const gchar * name)
-{
- if (name == NULL) {
- throw Extension::param_not_exist();
- }
- if (this->parameters == NULL) {
- // the list of parameters is empty
- throw Extension::param_not_exist();
- }
-
- for (GSList * list = this->parameters; list != NULL; list = g_slist_next(list)) {
- Parameter * param = static_cast<Parameter*>(list->data);
- if (!strcmp(param->name(), name)) {
- return param;
- }
- }
-
- return NULL;
-}
/**
* Creates a Notebook widget for a notebook parameter.
@@ -432,9 +390,8 @@ Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node *
// add pages (if any)
int i = -1;
int pagenr = i;
- for (GSList * list = pages; list != NULL; list = g_slist_next(list)) {
+ for (auto page:pages) {
i++;
- ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(list->data);
Gtk::Widget * widg = page->get_widget(doc, node, changeSignal);
nb->append_page(*widg, _(page->get_text()));
if (!strcmp(_value, page->name())) {
diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h
index 8475de61d..f1bebd372 100644
--- a/src/extension/param/notebook.h
+++ b/src/extension/param/notebook.h
@@ -37,7 +37,34 @@ private:
*/
gchar * _value;
- GSList * pages; /**< A table to store the pages with parameters for this notebook.
+ /**
+ * A class to represent the pages of a notebookparameter of an extension.
+ */
+ class ParamNotebookPage : public Parameter {
+ private:
+ std::vector<Parameter *> parameters; /**< A table to store the parameters for this page.
+ This only gets created if there are parameters on this
+ page */
+
+ public:
+ static ParamNotebookPage * makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
+
+ ParamNotebookPage(const gchar * name,
+ const gchar * text,
+ const gchar * description,
+ bool hidden,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml);
+ ~ParamNotebookPage(void);
+
+ Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+ void paramString (std::list <std::string> &list);
+ gchar * get_text (void) {return _text;};
+ Parameter * get_param (const gchar * name);
+ }; /* class ParamNotebookPage */
+
+
+ std::vector<ParamNotebookPage*> pages; /**< A table to store the pages with parameters for this notebook.
This only gets created if there are pages in this
notebook */
public:
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index a08ba6860..ca6dbb31d 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -42,20 +42,6 @@ namespace Extension {
/* For internal use only.
Note that value and text MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */
-class optionentry {
-public:
- optionentry (Glib::ustring * val, Glib::ustring * txt) {
- value = val;
- text = txt;
- }
- ~optionentry() {
- delete value;
- delete text;
- }
-
- Glib::ustring * value;
- Glib::ustring * text;
-};
ParamRadioButton::ParamRadioButton(const gchar * name,
const gchar * text,
@@ -68,7 +54,6 @@ ParamRadioButton::ParamRadioButton(const gchar * name,
: Parameter(name, text, description, hidden, indent, ext)
, _value(0)
, _mode(mode)
- , choices(0)
{
// Read XML tree to add enumeration items:
// printf("Extension Constructor: ");
@@ -105,7 +90,7 @@ ParamRadioButton::ParamRadioButton(const gchar * name,
}
if ( (newtext) && (newvalue) ) { // logical error if this is not true here
- choices = g_slist_append( choices, new optionentry(newvalue, newtext) );
+ choices.push_back(new optionentry(newvalue, newtext));
}
}
child_repr = child_repr->next();
@@ -115,8 +100,8 @@ 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) {
- defaultval = (static_cast<optionentry*> (choices->data))->value->c_str();
+ if (!choices.empty()) {
+ defaultval = (static_cast<optionentry*> (choices[0]))->value->c_str();
}
gchar * pref_name = this->pref_name();
@@ -135,11 +120,9 @@ ParamRadioButton::ParamRadioButton(const gchar * name,
ParamRadioButton::~ParamRadioButton (void)
{
//destroy choice strings
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- delete (reinterpret_cast<optionentry *>(list->data));
+ for(auto i:choices) {
+ delete i;
}
- g_slist_free(choices);
-
g_free(_value);
}
@@ -166,8 +149,7 @@ const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inksc
}
Glib::ustring * settext = NULL;
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- optionentry * entr = reinterpret_cast<optionentry *>(list->data);
+ for (auto entr:choices) {
if ( !entr->value->compare(in) ) {
settext = entr->value;
break; // break out of for loop
@@ -278,8 +260,7 @@ Glib::ustring ParamRadioButton::value_from_label(const Glib::ustring label)
{
Glib::ustring value = "";
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- optionentry * entr = reinterpret_cast<optionentry *>(list->data);
+ for ( auto entr:choices) {
if ( !entr->text->compare(label) ) {
value = *(entr->value);
break;
@@ -319,8 +300,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node
// add choice strings as radiobuttons
// and select last selected option (_value)
Gtk::RadioButtonGroup group;
- for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
- optionentry * entr = reinterpret_cast<optionentry *>(list->data);
+ for (auto entr:choices) {
Glib::ustring * text = entr->text;
switch ( _mode ) {
case MINIMAL:
diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h
index b91b11ea3..e3ced8eb8 100644
--- a/src/extension/param/radiobutton.h
+++ b/src/extension/param/radiobutton.h
@@ -27,6 +27,7 @@ namespace Extension {
class Extension;
+
// \brief A class to represent a radiobutton parameter of an extension
class ParamRadioButton : public Parameter {
public:
@@ -63,7 +64,24 @@ private:
It is the value of the current selected string */
gchar * _value;
AppearanceMode _mode;
- GSList * choices; /**< A table to store the choice strings */
+
+ /* For internal use only.
+ Note that value and text MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */
+ class optionentry {
+ public:
+ optionentry (Glib::ustring * val, Glib::ustring * txt) {
+ value = val;
+ text = txt;
+ }
+ ~optionentry() {
+ delete value;
+ delete text;
+ }
+ Glib::ustring * value;
+ Glib::ustring * text;
+ };
+
+ std::vector<optionentry*> choices; /**< A table to store the choice strings */
}; /* class ParamRadioButton */