diff options
| author | Patrick Storz <eduard.braun2@gmx.de> | 2019-08-07 21:47:00 +0000 |
|---|---|---|
| committer | Patrick Storz <eduard.braun2@gmx.de> | 2019-08-31 14:50:39 +0000 |
| commit | c5233cd683c7df4a31eb68634e8876ca900b9676 (patch) | |
| tree | f1756c2b4bc7c88b4dbeabc9dae04f10468819bf /src/extension/prefdialog | |
| parent | Re-implement get_param() locally using get_widgets() (diff) | |
| download | inkscape-c5233cd683c7df4a31eb68634e8876ca900b9676.tar.gz inkscape-c5233cd683c7df4a31eb68634e8876ca900b9676.zip | |
Remove completely unused "doc" and "node" parameters
Diffstat (limited to 'src/extension/prefdialog')
21 files changed, 152 insertions, 205 deletions
diff --git a/src/extension/prefdialog/parameter-bool.cpp b/src/extension/prefdialog/parameter-bool.cpp index a21c38fb4..c03bcb634 100644 --- a/src/extension/prefdialog/parameter-bool.cpp +++ b/src/extension/prefdialog/parameter-bool.cpp @@ -43,7 +43,7 @@ ParamBool::ParamBool(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *e g_free(pref_name); } -bool ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) +bool ParamBool::set(bool in) { _value = in; @@ -55,7 +55,7 @@ bool ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node return _value; } -bool ParamBool::get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const +bool ParamBool::get() const { return _value; } @@ -74,9 +74,11 @@ public: * * @param param Which parameter to adjust on changing the check button */ - ParamBoolCheckButton (ParamBool *param, char *label, SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) : - Gtk::CheckButton(label), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_active(_pref->get(nullptr, nullptr) /**\todo fix */); + ParamBoolCheckButton(ParamBool *param, char *label, sigc::signal<void> *changeSignal) + : Gtk::CheckButton(label) + , _pref(param) + , _changeSignal(changeSignal) { + this->set_active(_pref->get()); this->signal_toggled().connect(sigc::mem_fun(this, &ParamBoolCheckButton::on_toggle)); return; } @@ -90,14 +92,12 @@ public: private: /** Param to change. */ ParamBool *_pref; - SPDocument *_doc; - Inkscape::XML::Node *_node; sigc::signal<void> *_changeSignal; }; void ParamBoolCheckButton::on_toggle() { - _pref->set(this->get_active(), nullptr /**\todo fix this */, nullptr); + _pref->set(this->get_active()); if (_changeSignal != nullptr) { _changeSignal->emit(); } @@ -112,7 +112,7 @@ std::string ParamBool::value_to_string() const return "false"; } -Gtk::Widget *ParamBool::get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) +Gtk::Widget *ParamBool::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; @@ -121,7 +121,7 @@ Gtk::Widget *ParamBool::get_widget(SPDocument *doc, Inkscape::XML::Node *node, s auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, GUI_PARAM_WIDGETS_SPACING)); hbox->set_homogeneous(false); - ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, _text, doc, node, changeSignal)); + ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, _text, changeSignal)); checkbox->show(); hbox->pack_start(*checkbox, false, false); diff --git a/src/extension/prefdialog/parameter-bool.h b/src/extension/prefdialog/parameter-bool.h index 5b1b54e86..52fe06a73 100644 --- a/src/extension/prefdialog/parameter-bool.h +++ b/src/extension/prefdialog/parameter-bool.h @@ -11,8 +11,6 @@ #include "parameter.h" -class SPDocument; - namespace Gtk { class Widget; } @@ -34,25 +32,22 @@ public: /** * Returns the current state/value. */ - bool get(const SPDocument *doc, const Inkscape::XML::Node *node) const; + bool get() const; /** * A function to set the state/value. * This function sets 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. + * in the preferences structure. To put it in the right place pref_name() is used. * * @param in The value to set to - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed */ - bool set(bool in, SPDocument *doc, Inkscape::XML::Node *node); + bool set(bool in); /** * Creates a bool check button for a bool parameter. * Builds a hbox with a label and a check button in it. */ - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; /** * Appends 'true' or 'false'. diff --git a/src/extension/prefdialog/parameter-color.cpp b/src/extension/prefdialog/parameter-color.cpp index b55fcff5d..57e7486b6 100644 --- a/src/extension/prefdialog/parameter-color.cpp +++ b/src/extension/prefdialog/parameter-color.cpp @@ -58,25 +58,25 @@ ParamColor::~ParamColor() _color_released.disconnect(); } -unsigned int ParamColor::set(unsigned int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +unsigned int ParamColor::set(unsigned int in) { _color.setValue(in); return in; } -Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> *changeSignal ) +Gtk::Widget *ParamColor::get_widget(sigc::signal<void> *changeSignal) { - using Inkscape::UI::Widget::ColorNotebook; - - if (_hidden) return nullptr; + if (_hidden) { + return nullptr; + } if (changeSignal) { _changeSignal = new sigc::signal<void>(*changeSignal); } Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, GUI_PARAM_WIDGETS_SPACING)); - Gtk::Widget *selector = Gtk::manage(new ColorNotebook(_color)); + Gtk::Widget *selector = Gtk::manage(new Inkscape::UI::Widget::ColorNotebook(_color)); hbox->pack_start(*selector, true, true, 0); selector->show(); hbox->show(); diff --git a/src/extension/prefdialog/parameter-color.h b/src/extension/prefdialog/parameter-color.h index 67175838f..6e17a1c62 100644 --- a/src/extension/prefdialog/parameter-color.h +++ b/src/extension/prefdialog/parameter-color.h @@ -12,8 +12,6 @@ #include "parameter.h" #include "ui/selected-color.h" -class SPDocument; - namespace Gtk { class Widget; } @@ -38,11 +36,11 @@ public: ~ParamColor() override; /** Returns \c _value, with a \i const to protect it. */ - unsigned int get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _color.value(); } + unsigned int get() const { return _color.value(); } - unsigned int set(unsigned int in, SPDocument *doc, Inkscape::XML::Node *node); + unsigned int set(unsigned int in); - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; std::string value_to_string() const override; diff --git a/src/extension/prefdialog/parameter-float.cpp b/src/extension/prefdialog/parameter-float.cpp index 0e3fd9c35..7e363a74b 100644 --- a/src/extension/prefdialog/parameter-float.cpp +++ b/src/extension/prefdialog/parameter-float.cpp @@ -82,14 +82,11 @@ ParamFloat::ParamFloat(Inkscape::XML::Node *xml, Inkscape::Extension::Extension * A function to set the \c _value. * * This function sets 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. + * in the preferences structure. To put it in the right place \c pref_name() is used. * * @param in The value to set to. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. */ -float ParamFloat::set(float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +float ParamFloat::set(float in) { _value = in; if (_value > _max) { @@ -121,15 +118,15 @@ std::string ParamFloat::value_to_string() const class ParamFloatAdjustment : public Gtk::Adjustment { /** The parameter to adjust. */ ParamFloat *_pref; - SPDocument *_doc; - Inkscape::XML::Node *_node; sigc::signal<void> *_changeSignal; public: /** Make the adjustment using an extension and the string describing the parameter. */ - ParamFloatAdjustment (ParamFloat *param, SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_value(_pref->get(nullptr, nullptr) /* \todo fix */); + ParamFloatAdjustment(ParamFloat *param, sigc::signal<void> *changeSignal) + : Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0) + , _pref(param) + , _changeSignal(changeSignal) { + this->set_value(_pref->get()); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); return; }; @@ -145,8 +142,7 @@ public: */ void ParamFloatAdjustment::val_changed() { - //std::cout << "Value Changed to: " << this->get_value() << std::endl; - _pref->set(this->get_value(), _doc, _node); + _pref->set(this->get_value()); if (_changeSignal != nullptr) { _changeSignal->emit(); } @@ -158,7 +154,7 @@ void ParamFloatAdjustment::val_changed() * * Builds a hbox with a label and a float adjustment in it. */ -Gtk::Widget *ParamFloat::get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) +Gtk::Widget *ParamFloat::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; @@ -166,7 +162,7 @@ Gtk::Widget *ParamFloat::get_widget(SPDocument *doc, Inkscape::XML::Node *node, Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, GUI_PARAM_WIDGETS_SPACING)); - auto pfa = new ParamFloatAdjustment(this, doc, node, changeSignal); + auto pfa = new ParamFloatAdjustment(this, changeSignal); Glib::RefPtr<Gtk::Adjustment> fadjust(pfa); if (_mode == FULL) { diff --git a/src/extension/prefdialog/parameter-float.h b/src/extension/prefdialog/parameter-float.h index 0b67233f1..4c28cb54e 100644 --- a/src/extension/prefdialog/parameter-float.h +++ b/src/extension/prefdialog/parameter-float.h @@ -12,8 +12,6 @@ #include "parameter.h" -class SPDocument; - namespace Gtk { class Widget; } @@ -34,9 +32,9 @@ public: ParamFloat(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); /** Returns \c _value. */ - float get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + float get() const { return _value; } - float set (float in, SPDocument *doc, Inkscape::XML::Node *node); + float set(float in); float max () { return _max; } @@ -44,7 +42,7 @@ public: float precision () { return _precision; } - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; std::string value_to_string() const override; diff --git a/src/extension/prefdialog/parameter-int.cpp b/src/extension/prefdialog/parameter-int.cpp index 014872f12..2475a6785 100644 --- a/src/extension/prefdialog/parameter-int.cpp +++ b/src/extension/prefdialog/parameter-int.cpp @@ -75,14 +75,11 @@ ParamInt::ParamInt(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext /** * A function to set the \c _value. * This function sets 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. + * in the preferences structure. To put it in the right place \c pref_name() is used. * * @param in The value to set to. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. */ -int ParamInt::set(int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +int ParamInt::set(int in) { _value = in; if (_value > _max) { @@ -104,15 +101,15 @@ int ParamInt::set(int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) class ParamIntAdjustment : public Gtk::Adjustment { /** The parameter to adjust. */ ParamInt *_pref; - SPDocument *_doc; - Inkscape::XML::Node *_node; sigc::signal<void> *_changeSignal; public: - /** Make the adjustment using an extension and the string - describing the parameter. */ - ParamIntAdjustment (ParamInt *param, SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_value(_pref->get(nullptr, nullptr) /* \todo fix */); + /** Make the adjustment using an extension and the string describing the parameter. */ + ParamIntAdjustment(ParamInt *param, sigc::signal<void> *changeSignal) + : Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0) + , _pref(param) + , _changeSignal(changeSignal) + { + this->set_value(_pref->get()); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); }; @@ -127,8 +124,7 @@ public: */ void ParamIntAdjustment::val_changed() { - //std::cout << "Value Changed to: " << this->get_value() << std::endl; - _pref->set((int)this->get_value(), _doc, _node); + _pref->set((int)this->get_value()); if (_changeSignal != nullptr) { _changeSignal->emit(); } @@ -140,7 +136,7 @@ void ParamIntAdjustment::val_changed() * Builds a hbox with a label and a int adjustment in it. */ Gtk::Widget * -ParamInt::get_widget (SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) +ParamInt::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; @@ -148,7 +144,7 @@ ParamInt::get_widget (SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<v Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, GUI_PARAM_WIDGETS_SPACING)); - auto pia = new ParamIntAdjustment(this, doc, node, changeSignal); + auto pia = new ParamIntAdjustment(this, changeSignal); Glib::RefPtr<Gtk::Adjustment> fadjust(pia); if (_mode == FULL) { diff --git a/src/extension/prefdialog/parameter-int.h b/src/extension/prefdialog/parameter-int.h index 13ca3ce82..da43eb75f 100644 --- a/src/extension/prefdialog/parameter-int.h +++ b/src/extension/prefdialog/parameter-int.h @@ -12,8 +12,6 @@ #include "parameter.h" -class SPDocument; - namespace Gtk { class Widget; } @@ -34,15 +32,15 @@ public: ParamInt(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); /** Returns \c _value. */ - int get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + int get() const { return _value; } - int set (int in, SPDocument *doc, Inkscape::XML::Node *node); + int set(int in); int max () { return _max; } int min () { return _min; } - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; std::string value_to_string() const override; diff --git a/src/extension/prefdialog/parameter-notebook.cpp b/src/extension/prefdialog/parameter-notebook.cpp index 9cdf5df8e..b59f2a43d 100644 --- a/src/extension/prefdialog/parameter-notebook.cpp +++ b/src/extension/prefdialog/parameter-notebook.cpp @@ -61,7 +61,7 @@ ParamNotebook::ParamNotebookPage::ParamNotebookPage(Inkscape::XML::Node *xml, In * * Builds a notebook page (a vbox) and puts parameters on it. */ -Gtk::Widget *ParamNotebook::ParamNotebookPage::get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) +Gtk::Widget *ParamNotebook::ParamNotebookPage::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; @@ -73,7 +73,7 @@ Gtk::Widget *ParamNotebook::ParamNotebookPage::get_widget(SPDocument *doc, Inksc // add parameters onto page (if any) for (auto child : _children) { - Gtk::Widget *child_widget = child->get_widget(doc, node, changeSignal); + Gtk::Widget *child_widget = child->get_widget(changeSignal); if (child_widget) { int indent = child->get_indent(); child_widget->set_margin_start(indent *GUI_INDENTATION); @@ -146,14 +146,11 @@ ParamNotebook::ParamNotebook(Inkscape::XML::Node *xml, Inkscape::Extension::Exte * A function to set the \c _value. * * This function sets 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. + * in the preferences structure. To put it in the right place \c pref_name() is used. * * @param in The number of the page to set as new value. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. */ -const Glib::ustring& ParamNotebook::set(const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +const Glib::ustring& ParamNotebook::set(const int in) { int i = in < _children.size() ? in : _children.size()-1; ParamNotebookPage *page = dynamic_cast<ParamNotebookPage *>(_children[i]); @@ -180,18 +177,14 @@ std::string ParamNotebook::value_to_string() const class NotebookWidget : public Gtk::Notebook { private: ParamNotebook *_pref; - SPDocument *_doc; - Inkscape::XML::Node *_node; public: /** * Build a notebookpage preference for the given parameter. * @param pref Where to get the string (pagename) from, and where to put it when it changes. */ - NotebookWidget (ParamNotebook *pref, SPDocument *doc, Inkscape::XML::Node *node) + NotebookWidget(ParamNotebook *pref) : Gtk::Notebook() , _pref(pref) - , _doc(doc) - , _node(node) , activated(false) { // don't have to set the correct page: this is done in ParamNotebook::get_widget hook function @@ -213,7 +206,7 @@ public: void NotebookWidget::changed_page(Gtk::Widget * /*page*/, guint pagenum) { if (get_visible()) { - _pref->set((int)pagenum, _doc, _node); + _pref->set((int)pagenum); } } @@ -222,13 +215,13 @@ void NotebookWidget::changed_page(Gtk::Widget * /*page*/, guint pagenum) * * Builds a notebook and puts pages in it. */ -Gtk::Widget *ParamNotebook::get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) +Gtk::Widget *ParamNotebook::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; } - NotebookWidget *notebook = Gtk::manage(new NotebookWidget(this, doc, node)); + NotebookWidget *notebook = Gtk::manage(new NotebookWidget(this)); // add pages (if any) and switch to previously selected page int current_page = -1; @@ -239,7 +232,7 @@ Gtk::Widget *ParamNotebook::get_widget(SPDocument *doc, Inkscape::XML::Node *nod // If we receive a non-page child here something is very wrong! current_page++; - Gtk::Widget *page_widget = page->get_widget(doc, node, changeSignal); + Gtk::Widget *page_widget = page->get_widget(changeSignal); Glib::ustring page_text = page->_text; if (_translatable != NO) { // translate unless explicitly marked untranslatable diff --git a/src/extension/prefdialog/parameter-notebook.h b/src/extension/prefdialog/parameter-notebook.h index bba6cdd64..7a76520d4 100644 --- a/src/extension/prefdialog/parameter-notebook.h +++ b/src/extension/prefdialog/parameter-notebook.h @@ -48,7 +48,7 @@ private: public: ParamNotebookPage(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; // ParamNotebookPage is not a real parameter (it has no value), so make sure it does not return one std::string value_to_string() const override { return ""; }; @@ -63,12 +63,12 @@ private: public: ParamNotebook(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; std::string value_to_string() const override; - const Glib::ustring& get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } - const Glib::ustring& set (const int in, SPDocument *doc, Inkscape::XML::Node *node); + const Glib::ustring& get() { return _value; } + const Glib::ustring& set(const int in); }; /* class ParamNotebook */ diff --git a/src/extension/prefdialog/parameter-optiongroup.cpp b/src/extension/prefdialog/parameter-optiongroup.cpp index 78146568a..1358f33bb 100644 --- a/src/extension/prefdialog/parameter-optiongroup.cpp +++ b/src/extension/prefdialog/parameter-optiongroup.cpp @@ -100,16 +100,13 @@ ParamOptionGroup::~ParamOptionGroup () * 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. + * in the preferences structure. To put it in the right place \c pref_name() is used. * * @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 Glib::ustring& ParamOptionGroup::set(Glib::ustring in, SPDocument *doc, Inkscape::XML::Node *node) +const Glib::ustring& ParamOptionGroup::set(Glib::ustring in) { - if (contains(in, doc, node)) { + if (contains(in)) { _value = in; char *pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -123,7 +120,7 @@ const Glib::ustring& ParamOptionGroup::set(Glib::ustring in, SPDocument *doc, In return _value; } -bool ParamOptionGroup::contains(const Glib::ustring text, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const +bool ParamOptionGroup::contains(const Glib::ustring text) const { for (auto choice : choices) { if (choice->_value == text) { @@ -162,16 +159,12 @@ Glib::ustring ParamOptionGroup::value_from_label(const Glib::ustring label) class RadioWidget : public Gtk::RadioButton { private: ParamOptionGroup *_pref; - SPDocument *_doc; - Inkscape::XML::Node *_node; sigc::signal<void> *_changeSignal; public: RadioWidget(Gtk::RadioButtonGroup& group, const Glib::ustring& label, - ParamOptionGroup *pref, SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) + ParamOptionGroup *pref, sigc::signal<void> *changeSignal) : Gtk::RadioButton(group, label) , _pref(pref) - , _doc(doc) - , _node(node) , _changeSignal(changeSignal) { add_changesignal(); @@ -194,7 +187,7 @@ void RadioWidget::changed() { if (this->get_active()) { Glib::ustring value = _pref->value_from_label(this->get_label()); - _pref->set(value.c_str(), _doc, _node); + _pref->set(value.c_str()); } if (_changeSignal) { @@ -207,15 +200,11 @@ void RadioWidget::changed() class ComboWidget : public Gtk::ComboBoxText { private: ParamOptionGroup *_pref; - SPDocument *_doc; - Inkscape::XML::Node *_node; sigc::signal<void> *_changeSignal; public: - ComboWidget(ParamOptionGroup *pref, SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) + ComboWidget(ParamOptionGroup *pref, sigc::signal<void> *changeSignal) : _pref(pref) - , _doc(doc) - , _node(node) , _changeSignal(changeSignal) { this->signal_changed().connect(sigc::mem_fun(this, &ComboWidget::changed)); @@ -230,7 +219,7 @@ void ComboWidget::changed() { if (_pref) { Glib::ustring value = _pref->value_from_label(get_active_text()); - _pref->set(value.c_str(), _doc, _node); + _pref->set(value.c_str()); } if (_changeSignal) { @@ -243,7 +232,7 @@ void ComboWidget::changed() /** * Creates the widget for the optiongroup parameter. */ -Gtk::Widget *ParamOptionGroup::get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) +Gtk::Widget *ParamOptionGroup::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; @@ -255,7 +244,7 @@ Gtk::Widget *ParamOptionGroup::get_widget(SPDocument *doc, Inkscape::XML::Node * hbox->pack_start(*label, false, false); if (_mode == COMBOBOX) { - ComboWidget *combo = Gtk::manage(new ComboWidget(this, doc, node, changeSignal)); + ComboWidget *combo = Gtk::manage(new ComboWidget(this, changeSignal)); for (auto choice : choices) { combo->append(choice->_text); @@ -276,7 +265,7 @@ Gtk::Widget *ParamOptionGroup::get_widget(SPDocument *doc, Inkscape::XML::Node * Gtk::RadioButtonGroup group; for (auto choice : choices) { - RadioWidget *radio = Gtk::manage(new RadioWidget(group, choice->_text, this, doc, node, changeSignal)); + RadioWidget *radio = Gtk::manage(new RadioWidget(group, choice->_text, this, changeSignal)); radios->pack_start(*radio, true, true); if (choice->_value == _value) { radio->set_active(); diff --git a/src/extension/prefdialog/parameter-optiongroup.h b/src/extension/prefdialog/parameter-optiongroup.h index 16607f2fb..533b13170 100644 --- a/src/extension/prefdialog/parameter-optiongroup.h +++ b/src/extension/prefdialog/parameter-optiongroup.h @@ -45,21 +45,21 @@ public: ParamOptionGroup(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); ~ParamOptionGroup() override; - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; std::string value_to_string() const override; Glib::ustring value_from_label(const Glib::ustring label); - const Glib::ustring& get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + const Glib::ustring& get() const { return _value; } - const Glib::ustring& set(const Glib::ustring in, SPDocument *doc, Inkscape::XML::Node *node); + const Glib::ustring& set(const Glib::ustring in); /** * @returns true if text is a valid choice for this option group * @param text string value to check (this is an actual option value, not the user-visible option name!) */ - bool contains(const Glib::ustring text, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const; + bool contains(const Glib::ustring text) const; private: /** \brief Internal value. */ diff --git a/src/extension/prefdialog/parameter-string.cpp b/src/extension/prefdialog/parameter-string.cpp index 05a8bca51..337893528 100644 --- a/src/extension/prefdialog/parameter-string.cpp +++ b/src/extension/prefdialog/parameter-string.cpp @@ -58,18 +58,15 @@ ParamString::ParamString(Inkscape::XML::Node *xml, Inkscape::Extension::Extensio * A function to set the \c _value. * * This function sets 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. + * in the preferences structure. To put it in the right place \c pref_name() is 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 to. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. */ -const Glib::ustring& ParamString::set(const Glib::ustring in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +const Glib::ustring& ParamString::set(const Glib::ustring in) { _value = in; @@ -91,8 +88,6 @@ std::string ParamString::value_to_string() const class ParamStringEntry : public Gtk::Entry { private: ParamString *_pref; - SPDocument *_doc; - Inkscape::XML::Node *_node; sigc::signal<void> *_changeSignal; public: /** @@ -100,14 +95,12 @@ public: * @param pref Where to get the string from, and where to put it * when it changes. */ - ParamStringEntry(ParamString *pref, SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) + ParamStringEntry(ParamString *pref, sigc::signal<void> *changeSignal) : Gtk::Entry() , _pref(pref) - , _doc(doc) - , _node(node) , _changeSignal(changeSignal) { - this->set_text(_pref->get(nullptr, nullptr)); + this->set_text(_pref->get()); this->set_max_length(_pref->getMaxLength()); //Set the max length - default zero means no maximum this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text)); }; @@ -124,7 +117,7 @@ public: void ParamStringEntry::changed_text() { Glib::ustring data = this->get_text(); - _pref->set(data.c_str(), _doc, _node); + _pref->set(data.c_str()); if (_changeSignal != nullptr) { _changeSignal->emit(); } @@ -135,7 +128,7 @@ void ParamStringEntry::changed_text() * * Builds a hbox with a label and a text box in it. */ -Gtk::Widget *ParamString::get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) +Gtk::Widget *ParamString::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; @@ -146,7 +139,7 @@ Gtk::Widget *ParamString::get_widget(SPDocument *doc, Inkscape::XML::Node *node, label->show(); hbox->pack_start(*label, false, false); - ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal); + ParamStringEntry * textbox = new ParamStringEntry(this, changeSignal); textbox->show(); hbox->pack_start(*textbox, true, true); diff --git a/src/extension/prefdialog/parameter-string.h b/src/extension/prefdialog/parameter-string.h index a8467f10f..ef1d48821 100644 --- a/src/extension/prefdialog/parameter-string.h +++ b/src/extension/prefdialog/parameter-string.h @@ -23,10 +23,10 @@ public: ParamString(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); /** \brief Returns \c _value, with a \i const to protect it. */ - const Glib::ustring& get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; } - const Glib::ustring& set(const Glib::ustring in, SPDocument *doc, Inkscape::XML::Node *node); + const Glib::ustring& get() const { return _value; } + const Glib::ustring& set(const Glib::ustring in); - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; std::string value_to_string() const override; diff --git a/src/extension/prefdialog/parameter.cpp b/src/extension/prefdialog/parameter.cpp index d0e284ea7..4c104573a 100644 --- a/src/extension/prefdialog/parameter.cpp +++ b/src/extension/prefdialog/parameter.cpp @@ -51,9 +51,9 @@ public: , InxParameter(xml, ext) {} - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override { - return this->WidgetLabel::get_widget(doc, node, changeSignal); + return this->WidgetLabel::get_widget(changeSignal); } // Well, no, I don't have a value! That's why I should not be an InxParameter! @@ -98,117 +98,117 @@ InxParameter *InxParameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extensi return param; } -bool InxParameter::get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const +bool InxParameter::get_bool() const { ParamBool const *boolpntr = dynamic_cast<ParamBool const *>(this); if (!boolpntr) { throw param_not_bool_param(); } - return boolpntr->get(doc, node); + return boolpntr->get(); } -int InxParameter::get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const +int InxParameter::get_int() const { ParamInt const *intpntr = dynamic_cast<ParamInt const *>(this); if (!intpntr) { throw param_not_int_param(); } - return intpntr->get(doc, node); + return intpntr->get(); } -float InxParameter::get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const +float InxParameter::get_float() const { ParamFloat const *floatpntr = dynamic_cast<ParamFloat const *>(this); if (!floatpntr) { throw param_not_float_param(); } - return floatpntr->get(doc, node); + return floatpntr->get(); } -const char *InxParameter::get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const +const char *InxParameter::get_string() const { ParamString const *stringpntr = dynamic_cast<ParamString const *>(this); if (!stringpntr) { throw param_not_string_param(); } - return stringpntr->get(doc, node).c_str(); + return stringpntr->get().c_str(); } -const char *InxParameter::get_optiongroup(SPDocument const *doc, Inkscape::XML::Node const *node) const +const char *InxParameter::get_optiongroup() const { ParamOptionGroup const *param = dynamic_cast<ParamOptionGroup const *>(this); if (!param) { throw param_not_optiongroup_param(); } - return param->get(doc, node).c_str(); + return param->get().c_str(); } -bool InxParameter::get_optiongroup_contains(const char *value, SPDocument const *doc, Inkscape::XML::Node const *node) const +bool InxParameter::get_optiongroup_contains(const char *value) const { ParamOptionGroup const *param = dynamic_cast<ParamOptionGroup const *>(this); if (!param) { throw param_not_optiongroup_param(); } - return param->contains(value, doc, node); + return param->contains(value); } -unsigned int InxParameter::get_color(const SPDocument* doc, Inkscape::XML::Node const *node) const +unsigned int InxParameter::get_color() const { ParamColor const *param = dynamic_cast<ParamColor const *>(this); if (!param) { throw param_not_color_param(); } - return param->get(doc, node); + return param->get(); } -bool InxParameter::set_bool(bool in, SPDocument *doc, Inkscape::XML::Node *node) +bool InxParameter::set_bool(bool in) { ParamBool * boolpntr = dynamic_cast<ParamBool *>(this); if (boolpntr == nullptr) throw param_not_bool_param(); - return boolpntr->set(in, doc, node); + return boolpntr->set(in); } -int InxParameter::set_int(int in, SPDocument *doc, Inkscape::XML::Node *node) +int InxParameter::set_int(int in) { ParamInt *intpntr = dynamic_cast<ParamInt *>(this); if (intpntr == nullptr) throw param_not_int_param(); - return intpntr->set(in, doc, node); + return intpntr->set(in); } -float InxParameter::set_float(float in, SPDocument *doc, Inkscape::XML::Node *node) +float InxParameter::set_float(float in) { ParamFloat * floatpntr; floatpntr = dynamic_cast<ParamFloat *>(this); if (floatpntr == nullptr) throw param_not_float_param(); - return floatpntr->set(in, doc, node); + return floatpntr->set(in); } -const char *InxParameter::set_string(const char *in, SPDocument *doc, Inkscape::XML::Node *node) +const char *InxParameter::set_string(const char *in) { ParamString * stringpntr = dynamic_cast<ParamString *>(this); if (stringpntr == nullptr) throw param_not_string_param(); - return stringpntr->set(in, doc, node).c_str(); + return stringpntr->set(in).c_str(); } -const char *InxParameter::set_optiongroup(const char *in, SPDocument *doc, Inkscape::XML::Node *node) +const char *InxParameter::set_optiongroup(const char *in) { ParamOptionGroup *param = dynamic_cast<ParamOptionGroup *>(this); if (!param) { throw param_not_optiongroup_param(); } - return param->set(in, doc, node).c_str(); + return param->set(in).c_str(); } -unsigned int InxParameter::set_color(unsigned int in, SPDocument *doc, Inkscape::XML::Node *node) +unsigned int InxParameter::set_color(unsigned int in) { ParamColor*param = dynamic_cast<ParamColor *>(this); if (param == nullptr) throw param_not_color_param(); - return param->set(in, doc, node); + return param->set(in); } diff --git a/src/extension/prefdialog/parameter.h b/src/extension/prefdialog/parameter.h index 23fea0204..f9baab190 100644 --- a/src/extension/prefdialog/parameter.h +++ b/src/extension/prefdialog/parameter.h @@ -41,67 +41,55 @@ public: ~InxParameter() override; /** Wrapper to cast to the object and use its function. */ - bool get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const; + bool get_bool() const; /** Wrapper to cast to the object and use it's function. */ - int get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const; + int get_int() const; /** Wrapper to cast to the object and use it's function. */ - float get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const; + float get_float() const; /** Wrapper to cast to the object and use it's function. */ - const char *get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const; + const char *get_string() const; /** Wrapper to cast to the object and use it's function. */ - const char *get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const *node) const; - bool get_optiongroup_contains(const char *value, SPDocument const *doc, Inkscape::XML::Node const *node) const; + const char *get_optiongroup() const; + bool get_optiongroup_contains(const char *value) const; /** Wrapper to cast to the object and use it's function. */ - unsigned int get_color(SPDocument const *doc, Inkscape::XML::Node const *node) const; + unsigned int get_color() const; /** Wrapper to cast to the object and use it's function. */ - bool set_bool(bool in, SPDocument *doc, Inkscape::XML::Node *node); + bool set_bool(bool in); /** Wrapper to cast to the object and use it's function. */ - int set_int(int in, SPDocument *doc, Inkscape::XML::Node *node); + int set_int(int in); /** Wrapper to cast to the object and use it's function. */ - float set_float(float in, SPDocument *doc, Inkscape::XML::Node *node); + float set_float(float in); /** Wrapper to cast to the object and use it's function. */ - const char *set_string(const char *in, SPDocument *doc, Inkscape::XML::Node *node); + const char *set_string(const char *in); /** Wrapper to cast to the object and use it's function. */ - const char *set_optiongroup(const char *in, SPDocument *doc, Inkscape::XML::Node *node); + const char *set_optiongroup(const char *in); /** Wrapper to cast to the object and use it's function. */ - unsigned int set_color(unsigned int in, SPDocument *doc, Inkscape::XML::Node *node); + unsigned int set_color(unsigned int in); char const *name() const { return _name; } /** - * This function creates a parameter that can be used later. This - * is typically done in the creation of the extension and defined - * in the XML file describing the extension (it's private so people - * have to use the system) :) + * Creates a new extension parameter for usage in a prefdialog. * - * This function first grabs all of the data out of the Repr and puts - * it into local variables. Actually, these are just pointers, and the - * data is not duplicated so we need to be careful with it. If there - * isn't a name or a type in the XML, then no parameter is created as - * the function just returns. + * The type of widget created is parsed from the XML representation passed in, + * and the suitable subclass constructor is called. * - * From this point on, we're pretty committed as we've allocated an - * object and we're starting to fill it. The name is set first, and - * is created with a strdup to actually allocate memory for it. Then - * there is a case statement (roughly because strcmp requires 'ifs') - * based on what type of parameter this is. Depending which type it - * is, the value is interpreted differently, but they are relatively - * 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. + * Called from base-class method of the same name. * - * @param in_repr The XML describing the parameter. - * @return a pointer to a new parameter if applicable, null otherwise.. + * @param in_repr The XML representation describing the widget. + * @param in_ext The extension the widget belongs to. + * @return a pointer to a new Widget if applicable, null otherwise.. */ static InxParameter *make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext); diff --git a/src/extension/prefdialog/prefdialog.cpp b/src/extension/prefdialog/prefdialog.cpp index 81d798744..46b42e8d2 100644 --- a/src/extension/prefdialog/prefdialog.cpp +++ b/src/extension/prefdialog/prefdialog.cpp @@ -91,7 +91,7 @@ PrefDialog::PrefDialog (Glib::ustring name, Gtk::Widget * controls, Effect * eff hbox = Gtk::manage(new Gtk::HBox()); hbox->set_border_width(InxWidget::GUI_BOX_MARGIN); - _button_preview = _param_preview->get_widget(nullptr, nullptr, &_signal_preview); + _button_preview = _param_preview->get_widget(&_signal_preview); _button_preview->show(); hbox->pack_start(*_button_preview, true, true, 0); hbox->show(); @@ -144,7 +144,7 @@ PrefDialog::preview_toggle () { SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDocument *document = SP_ACTIVE_DOCUMENT; bool modified = document->isModifiedSinceSave(); - if(_param_preview->get_bool(nullptr, nullptr)) { + if(_param_preview->get_bool()) { if (_exEnv == nullptr) { set_modal(true); _exEnv = new ExecutionEnv(_effect, SP_ACTIVE_DESKTOP, nullptr, false, false); diff --git a/src/extension/prefdialog/widget-label.cpp b/src/extension/prefdialog/widget-label.cpp index 64de11463..ec4f558af 100644 --- a/src/extension/prefdialog/widget-label.cpp +++ b/src/extension/prefdialog/widget-label.cpp @@ -75,7 +75,7 @@ WidgetLabel::WidgetLabel(Inkscape::XML::Node *xml, Inkscape::Extension::Extensio } /** \brief Create a label for the description */ -Gtk::Widget *WidgetLabel::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) +Gtk::Widget *WidgetLabel::get_widget(sigc::signal<void> * /*changeSignal*/) { if (_hidden) { return nullptr; diff --git a/src/extension/prefdialog/widget-label.h b/src/extension/prefdialog/widget-label.h index b99e3d798..c456867cd 100644 --- a/src/extension/prefdialog/widget-label.h +++ b/src/extension/prefdialog/widget-label.h @@ -19,8 +19,6 @@ #include <glibmm/ustring.h> -class SPDocument; - namespace Gtk { class Widget; } @@ -41,7 +39,7 @@ public: WidgetLabel(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); - Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; private: /** \brief Internal value. */ Glib::ustring _value; diff --git a/src/extension/prefdialog/widget.cpp b/src/extension/prefdialog/widget.cpp index db5700b2e..d1035ef85 100644 --- a/src/extension/prefdialog/widget.cpp +++ b/src/extension/prefdialog/widget.cpp @@ -66,7 +66,7 @@ bool InxWidget::is_valid_widget_name(const char *name) } -InxWidget::InxWidget (Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext) +InxWidget::InxWidget(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext) : _extension(ext) { // translatable (optional) @@ -127,7 +127,7 @@ InxWidget::~InxWidget() /** Basically, if there is no widget pass a NULL. */ Gtk::Widget * -InxWidget::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) +InxWidget::get_widget(sigc::signal<void> * /*changeSignal*/) { return nullptr; } diff --git a/src/extension/prefdialog/widget.h b/src/extension/prefdialog/widget.h index 07706f8d6..6ee678f29 100644 --- a/src/extension/prefdialog/widget.h +++ b/src/extension/prefdialog/widget.h @@ -18,8 +18,6 @@ #include <sigc++/sigc++.h> -class SPDocument; - namespace Gtk { class Widget; } @@ -52,7 +50,7 @@ public: * For specialized widget types (like parameters) we defer to the subclass function of the same name. * * @param in_repr The XML representation describing the widget. - * @param in_ex t The extension the widget belongs to. + * @param in_ext The extension the widget belongs to. * @return a pointer to a new Widget if applicable, null otherwise.. */ static InxWidget *make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext); @@ -60,7 +58,14 @@ public: /** Checks if name is a valid widget name, i.e. a widget can be constructed from it using make() */ static bool is_valid_widget_name(const char *name); - virtual Gtk::Widget *get_widget(SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal); + /** Return the instances GTK::Widget representation for usage in a GUI + * + * @param changeSignal Can be used to subscribe to parameter changes. + * Will be emitted whenever a parameter value changes. + * + * @teturn A Gtk::Widget for the \a InxWidget. \c nullptr if the widget is hidden. + */ + virtual Gtk::Widget *get_widget(sigc::signal<void> *changeSignal); virtual const char *get_tooltip() const { return nullptr; } // tool-tips are exclusive to InxParameters for now |
