Code

Make text widget for TextParams work and re-enable it
[inkscape.git] / src / live_effects / parameter / bool.cpp
index 14fd88423821c7aa406e33190b48efdd3a7ece72..505a70493941dba13ede403b3d1f026d56d40573 100644 (file)
 #include "svg/stringstream.h"
 #include <gtkmm.h>
 #include "widgets/icon.h"
-
+#include "ui/widget/registered-widget.h"
 #include "inkscape.h"
 #include "verbs.h"
 #include "helper-fns.h"
 
-#define noLPEBOOLPARAM_DEBUG
-
 namespace Inkscape {
 
 namespace LivePathEffect {
@@ -28,13 +26,10 @@ BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,
                       Effect* effect, bool default_value )
     : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
 {
-    checkwdg = NULL;
 }
 
 BoolParam::~BoolParam()
 {
-    if (checkwdg)
-        delete checkwdg;
 }
 
 void
@@ -51,32 +46,35 @@ BoolParam::param_readSVGValue(const gchar * strvalue)
 }
 
 gchar *
-BoolParam::param_writeSVGValue() const
+BoolParam::param_getSVGValue() const
 {
     gchar * str = g_strdup(value ? "true" : "false");
     return str;
 }
 
 Gtk::Widget *
-BoolParam::param_newWidget(Gtk::Tooltips * tooltips)
+BoolParam::param_newWidget(Gtk::Tooltips * /*tooltips*/)
 {
-    // WIDGET TODO: This implementation is incorrect, it should create a *new* widget for the caller, not just return an already created widget
-    g_warning("BoolParam::param_newWidget still needs recoding to work with multiple document views");
-    if (!checkwdg) {
-        checkwdg = new Inkscape::UI::Widget::RegisteredCheckButton();
-        checkwdg->init(param_label, param_tooltip, param_key, *param_wr, false, param_effect->getRepr(), param_effect->getSPDoc());
-        checkwdg->setActive(value);
-        checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
-    }
-    return dynamic_cast<Gtk::Widget *> (checkwdg->_button);
+    Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage(
+        new Inkscape::UI::Widget::RegisteredCheckButton( param_label,
+                                                         param_tooltip,
+                                                         param_key,
+                                                         *param_wr,
+                                                         false,
+                                                         param_effect->getRepr(),
+                                                         param_effect->getSPDoc()) );
+
+    checkwdg->setActive(value);
+    checkwdg->setProgrammatically = false;
+    checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
+
+    return dynamic_cast<Gtk::Widget *> (checkwdg);
 }
 
 void
 BoolParam::param_setValue(bool newvalue)
 {
     value = newvalue;
-    if (checkwdg)
-        checkwdg->setActive(newvalue);
 }
 
 } /* namespace LivePathEffect */