index 4ac73e48476b049e0cef28f45eb9224501858f5c..4db4363caf76ca7389de0fcfade9975ff0acdcb5 100644 (file)
*
*
* Authors:
*
*
* Authors:
+ * Johan Engelen <j.b.c.engelen@utwente.nl>
* bulia byak <buliabyak@users.sf.net>
* Bryce W. Harrington <bryce@bryceharrington.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon Phillips <jon@rejon.org>
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
*
* bulia byak <buliabyak@users.sf.net>
* Bryce W. Harrington <bryce@bryceharrington.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon Phillips <jon@rejon.org>
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
*
- * Copyright (C) 2000 - 2005 Authors
+ * Copyright (C) 2000 - 2007 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information
*/
*
* Released under GNU GPL. Read the file 'COPYING' for more information
*/
#include "ui/widget/color-picker.h"
#include "ui/widget/registry.h"
#include "ui/widget/scalar-unit.h"
#include "ui/widget/color-picker.h"
#include "ui/widget/registry.h"
#include "ui/widget/scalar-unit.h"
+#include "ui/widget/point.h"
+#include "ui/widget/random.h"
+#include "widgets/spinbutton-events.h"
#include "helper/units.h"
#include "xml/repr.h"
#include "helper/units.h"
#include "xml/repr.h"
#include "registered-widget.h"
#include "verbs.h"
#include "registered-widget.h"
#include "verbs.h"
+// for interruptability bug:
+#include "display/sp-canvas.h"
+
namespace Inkscape {
namespace UI {
namespace Widget {
namespace Inkscape {
namespace UI {
namespace Widget {
//---------------------------------------------------
//---------------------------------------------------
+void
+RegisteredWidget::write_to_xml(const char * svgstr)
+{
+ // Use local repr here. When repr is specified, use that one, but
+ // if repr==NULL, get the repr of namedview of active desktop.
+ Inkscape::XML::Node *local_repr = repr;
+ SPDocument *local_doc = doc;
+ if (!local_repr) {
+ // no repr specified, use active desktop's namedview's repr
+ SPDesktop* dt = SP_ACTIVE_DESKTOP;
+ local_repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
+ local_doc = sp_desktop_document(dt);
+ }
+
+ bool saved = sp_document_get_undo_sensitive (local_doc);
+ sp_document_set_undo_sensitive (local_doc, false);
+ if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr);
+ local_doc->rroot->setAttribute("sodipodi:modified", "true");
+ sp_document_set_undo_sensitive (local_doc, saved);
+ if (write_undo) {
+ local_repr->setAttribute(_key.c_str(), svgstr);
+ sp_document_done (local_doc, event_type, event_description);
+ }
+}
+
//====================================================
//====================================================
}
void
}
void
-RegisteredCheckButton::init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right)
+RegisteredCheckButton::init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
{
{
+ init_parent(key, wr, repr_in, doc_in);
+
_button = new Gtk::CheckButton;
_tt.set_tip (*_button, tip);
Gtk::Label *l = new Gtk::Label (label);
l->set_use_underline (true);
_button->add (*manage (l));
_button->set_alignment (right? 1.0 : 0.0, 0.5);
_button = new Gtk::CheckButton;
_tt.set_tip (*_button, tip);
Gtk::Label *l = new Gtk::Label (label);
l->set_use_underline (true);
_button->add (*manage (l));
_button->set_alignment (right? 1.0 : 0.0, 0.5);
- _key = key;
- _wr = ≀
_toggled_connection = _button->signal_toggled().connect (sigc::mem_fun (*this, &RegisteredCheckButton::on_toggled));
}
_toggled_connection = _button->signal_toggled().connect (sigc::mem_fun (*this, &RegisteredCheckButton::on_toggled));
}
RegisteredCheckButton::setActive (bool b)
{
_button->set_active (b);
RegisteredCheckButton::setActive (bool b)
{
_button->set_active (b);
+ //The slave button is greyed out if the master button is unchecked
+ for (std::list<Gtk::ToggleButton*>::const_iterator i = _slavebuttons.begin(); i != _slavebuttons.end(); i++) {
+ (*i)->set_sensitive(b);
+ }
}
void
}
void
if (_wr->isUpdating())
return;
if (_wr->isUpdating())
return;
- SPDesktop *dt = SP_ACTIVE_DESKTOP;
- if (!dt) {
- return;
- }
+ _wr->setUpdating (true);
- SPDocument *doc = sp_desktop_document(dt);
+ write_to_xml(_button->get_active() ? "true" : "false");
+ //The slave button is greyed out if the master button is unchecked
+ for (std::list<Gtk::ToggleButton*>::const_iterator i = _slavebuttons.begin(); i != _slavebuttons.end(); i++) {
+ (*i)->set_sensitive(_button->get_active());
+ }
- Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
- _wr->setUpdating (true);
+ write_to_xml(_button->get_active() ? "true" : "false");
- gboolean saved = sp_document_get_undo_sensitive (doc);
- sp_document_set_undo_sensitive (doc, FALSE);
- sp_repr_set_boolean(repr, _key.c_str(), _button->get_active());
- doc->rroot->setAttribute("sodipodi:modified", "true");
- sp_document_set_undo_sensitive (doc, saved);
- sp_document_done (doc, SP_VERB_NONE,
- /* TODO: annotate */ "registered-widget.cpp:103");
-
_wr->setUpdating (false);
}
_wr->setUpdating (false);
}
}
void
}
void
-RegisteredUnitMenu::init (const Glib::ustring& label, const Glib::ustring& key, Registry& wr)
+RegisteredUnitMenu::init (const Glib::ustring& label, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
{
{
+ init_parent(key, wr, repr_in, doc_in);
+
_label = new Gtk::Label (label, 1.0, 0.5);
_label->set_use_underline (true);
_sel = new UnitMenu ();
_label->set_mnemonic_widget (*_sel);
_sel->setUnitType (UNIT_TYPE_LINEAR);
_label = new Gtk::Label (label, 1.0, 0.5);
_label->set_use_underline (true);
_sel = new UnitMenu ();
_label->set_mnemonic_widget (*_sel);
_sel->setUnitType (UNIT_TYPE_LINEAR);
- _wr = ≀
- _key = key;
_changed_connection = _sel->signal_changed().connect (sigc::mem_fun (*this, &RegisteredUnitMenu::on_changed));
}
_changed_connection = _sel->signal_changed().connect (sigc::mem_fun (*this, &RegisteredUnitMenu::on_changed));
}
-void
+void
RegisteredUnitMenu::setUnit (const SPUnit* unit)
{
_sel->setUnit (sp_unit_get_abbreviation (unit));
RegisteredUnitMenu::setUnit (const SPUnit* unit)
{
_sel->setUnit (sp_unit_get_abbreviation (unit));
if (_wr->isUpdating())
return;
if (_wr->isUpdating())
return;
- SPDesktop *dt = SP_ACTIVE_DESKTOP;
- if (!dt)
- return;
-
Inkscape::SVGOStringStream os;
os << _sel->getUnitAbbr();
_wr->setUpdating (true);
Inkscape::SVGOStringStream os;
os << _sel->getUnitAbbr();
_wr->setUpdating (true);
- SPDocument *doc = sp_desktop_document(dt);
- gboolean saved = sp_document_get_undo_sensitive (doc);
- sp_document_set_undo_sensitive (doc, FALSE);
- Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
- repr->setAttribute(_key.c_str(), os.str().c_str());
- doc->rroot->setAttribute("sodipodi:modified", "true");
- sp_document_set_undo_sensitive (doc, saved);
- sp_document_done (doc, SP_VERB_NONE,
- /* TODO: annotate */ "registered-widget.cpp:162");
-
+ write_to_xml(os.str().c_str());
+
_wr->setUpdating (false);
}
_wr->setUpdating (false);
}
}
void
}
void
-RegisteredScalarUnit::init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr)
+RegisteredScalarUnit::init (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
{
{
+ init_parent(key, wr, repr_in, doc_in);
+
_widget = new ScalarUnit (label, tip, UNIT_TYPE_LINEAR, "", "", rum._sel);
_widget->initScalar (-1e6, 1e6);
_widget->setUnit (rum._sel->getUnitAbbr());
_widget->setDigits (2);
_widget = new ScalarUnit (label, tip, UNIT_TYPE_LINEAR, "", "", rum._sel);
_widget->initScalar (-1e6, 1e6);
_widget->setUnit (rum._sel->getUnitAbbr());
_widget->setDigits (2);
- _key = key;
_um = rum._sel;
_value_changed_connection = _widget->signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalarUnit::on_value_changed));
_um = rum._sel;
_value_changed_connection = _widget->signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalarUnit::on_value_changed));
- _wr = ≀
}
ScalarUnit*
}
ScalarUnit*
return _widget;
}
return _widget;
}
-void
+void
RegisteredScalarUnit::setValue (double val)
{
_widget->setValue (val);
RegisteredScalarUnit::setValue (double val)
{
_widget->setValue (val);
if (_wr->isUpdating())
return;
if (_wr->isUpdating())
return;
- SPDesktop *dt = SP_ACTIVE_DESKTOP;
- if (!dt)
- return;
+ _wr->setUpdating (true);
Inkscape::SVGOStringStream os;
os << _widget->getValue("");
if (_um)
os << _um->getUnitAbbr();
Inkscape::SVGOStringStream os;
os << _widget->getValue("");
if (_um)
os << _um->getUnitAbbr();
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
+
+
+RegisteredScalar::RegisteredScalar()
+{
+ _widget = NULL;
+}
+
+RegisteredScalar::~RegisteredScalar()
+{
+ if (_widget)
+ delete _widget;
+
+ _value_changed_connection.disconnect();
+}
+
+void
+RegisteredScalar::init ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument * doc_in )
+{
+ init_parent(key, wr, repr_in, doc_in);
+
+ _widget = new Scalar (label, tip);
+ _widget->setRange (-1e6, 1e6);
+ _widget->setDigits (2);
+ _widget->setIncrements(0.1, 1.0);
+ _value_changed_connection = _widget->signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalar::on_value_changed));
+}
+
+Scalar*
+RegisteredScalar::getS()
+{
+ return _widget;
+}
+
+void
+RegisteredScalar::setValue (double val)
+{
+ _widget->setValue (val);
+ on_value_changed();
+}
+
+void
+RegisteredScalar::on_value_changed()
+{
+ if (_wr->isUpdating())
+ return;
_wr->setUpdating (true);
_wr->setUpdating (true);
- SPDocument *doc = sp_desktop_document(dt);
- gboolean saved = sp_document_get_undo_sensitive (doc);
- sp_document_set_undo_sensitive (doc, FALSE);
- Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
- repr->setAttribute(_key.c_str(), os.str().c_str());
- doc->rroot->setAttribute("sodipodi:modified", "true");
- sp_document_set_undo_sensitive (doc, saved);
- sp_document_done (doc, SP_VERB_NONE,
- /* TODO: annotate */ "registered-widget.cpp:230");
-
+ // FIXME: gtk bug?
+ // disable interruptibility: see http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/ui/widget/selected-style.cpp?r1=13149&r2=13257&sortby=date
+ SPDesktop* dt = SP_ACTIVE_DESKTOP;
+ sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(dt), 0);
+
+ Inkscape::SVGOStringStream os;
+ os << _widget->getValue();
+
+ write_to_xml(os.str().c_str());
+
+ // resume interruptibility
+ sp_canvas_end_forced_full_redraws(sp_desktop_canvas(dt));
+
_wr->setUpdating (false);
}
_wr->setUpdating (false);
}
+
RegisteredColorPicker::RegisteredColorPicker()
: _label(0), _cp(0)
{
RegisteredColorPicker::RegisteredColorPicker()
: _label(0), _cp(0)
{
}
void
}
void
-RegisteredColorPicker::init (const Glib::ustring& label, const Glib::ustring& title, const Glib::ustring& tip, const Glib::ustring& ckey, const Glib::ustring& akey, Registry& wr)
+RegisteredColorPicker::init (const Glib::ustring& label, const Glib::ustring& title, const Glib::ustring& tip, const Glib::ustring& ckey, const Glib::ustring& akey, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
{
{
+ init_parent("", wr, repr_in, doc_in);
+
_label = new Gtk::Label (label, 1.0, 0.5);
_label->set_use_underline (true);
_cp = new ColorPicker (title,tip,0,true);
_label->set_mnemonic_widget (*_cp);
_ckey = ckey;
_akey = akey;
_label = new Gtk::Label (label, 1.0, 0.5);
_label->set_use_underline (true);
_cp = new ColorPicker (title,tip,0,true);
_label->set_mnemonic_widget (*_cp);
_ckey = ckey;
_akey = akey;
- _wr = ≀
_changed_connection = _cp->connectChanged (sigc::mem_fun (*this, &RegisteredColorPicker::on_changed));
}
_changed_connection = _cp->connectChanged (sigc::mem_fun (*this, &RegisteredColorPicker::on_changed));
}
-void
+void
RegisteredColorPicker::setRgba32 (guint32 rgba)
{
_cp->setRgba32 (rgba);
RegisteredColorPicker::setRgba32 (guint32 rgba)
{
_cp->setRgba32 (rgba);
void
RegisteredColorPicker::on_changed (guint32 rgba)
{
void
RegisteredColorPicker::on_changed (guint32 rgba)
{
- if (_wr->isUpdating() || !SP_ACTIVE_DESKTOP)
+ if (_wr->isUpdating())
return;
_wr->setUpdating (true);
return;
_wr->setUpdating (true);
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(SP_ACTIVE_DESKTOP));
+
+ // Use local repr here. When repr is specified, use that one, but
+ // if repr==NULL, get the repr of namedview of active desktop.
+ Inkscape::XML::Node *local_repr = repr;
+ SPDocument *local_doc = doc;
+ if (!local_repr) {
+ // no repr specified, use active desktop's namedview's repr
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (!dt)
+ return;
+ local_repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
+ local_doc = sp_desktop_document(dt);
+ }
+
gchar c[32];
sp_svg_write_color(c, 32, rgba);
gchar c[32];
sp_svg_write_color(c, 32, rgba);
- repr->setAttribute(_ckey.c_str(), c);
- sp_repr_set_css_double(repr, _akey.c_str(), (rgba & 0xff) / 255.0);
+ bool saved = sp_document_get_undo_sensitive (local_doc);
+ sp_document_set_undo_sensitive (local_doc, false);
+ local_repr->setAttribute(_ckey.c_str(), c);
+ sp_repr_set_css_double(local_repr, _akey.c_str(), (rgba & 0xff) / 255.0);
+ local_doc->rroot->setAttribute("sodipodi:modified", "true");
+ sp_document_set_undo_sensitive (local_doc, saved);
+ sp_document_done (local_doc, SP_VERB_NONE,
+ /* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed");
+
_wr->setUpdating (false);
}
RegisteredSuffixedInteger::RegisteredSuffixedInteger()
: _label(0), _sb(0),
_wr->setUpdating (false);
}
RegisteredSuffixedInteger::RegisteredSuffixedInteger()
: _label(0), _sb(0),
- _adj(0.0,0.0,100.0,1.0,1.0,1.0),
+ _adj(0.0,0.0,100.0,1.0,1.0,1.0),
_suffix(0)
{
}
_suffix(0)
{
}
}
void
}
void
-RegisteredSuffixedInteger::init (const Glib::ustring& label, const Glib::ustring& suffix, const Glib::ustring& key, Registry& wr)
+RegisteredSuffixedInteger::init (const Glib::ustring& label, const Glib::ustring& suffix, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
{
{
- _key = key;
+ init_parent(key, wr, repr_in, doc_in);
+
_label = new Gtk::Label (label);
_label->set_alignment (1.0, 0.5);
_label->set_use_underline();
_label = new Gtk::Label (label);
_label->set_alignment (1.0, 0.5);
_label->set_use_underline();
@@ -313,10 +404,9 @@ RegisteredSuffixedInteger::init (const Glib::ustring& label, const Glib::ustring
_hbox.pack_start (*_suffix, false, false, 0);
_changed_connection = _adj.signal_value_changed().connect (sigc::mem_fun(*this, &RegisteredSuffixedInteger::on_value_changed));
_hbox.pack_start (*_suffix, false, false, 0);
_changed_connection = _adj.signal_value_changed().connect (sigc::mem_fun(*this, &RegisteredSuffixedInteger::on_value_changed));
- _wr = ≀
}
}
-void
+void
RegisteredSuffixedInteger::setValue (int i)
{
_adj.set_value (i);
RegisteredSuffixedInteger::setValue (int i)
{
_adj.set_value (i);
void
RegisteredSuffixedInteger::on_value_changed()
{
void
RegisteredSuffixedInteger::on_value_changed()
{
- if (_wr->isUpdating() || !SP_ACTIVE_DESKTOP)
+ if (_wr->isUpdating())
return;
_wr->setUpdating (true);
return;
_wr->setUpdating (true);
-
- SPDesktop* dt = SP_ACTIVE_DESKTOP;
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(dt));
+
Inkscape::SVGOStringStream os;
int value = int(_adj.get_value());
os << value;
Inkscape::SVGOStringStream os;
int value = int(_adj.get_value());
os << value;
- repr->setAttribute(_key.c_str(), os.str().c_str());
- sp_document_done(sp_desktop_document(dt), SP_VERB_NONE,
- /* TODO: annotate */ "registered-widget.cpp:341");
-
+ write_to_xml(os.str().c_str());
+
_wr->setUpdating (false);
}
_wr->setUpdating (false);
}
}
void
}
void
-RegisteredRadioButtonPair::init (const Glib::ustring& label,
-const Glib::ustring& label1, const Glib::ustring& label2,
-const Glib::ustring& tip1, const Glib::ustring& tip2,
-const Glib::ustring& key, Registry& wr)
+RegisteredRadioButtonPair::init (const Glib::ustring& label,
+const Glib::ustring& label1, const Glib::ustring& label2,
+const Glib::ustring& tip1, const Glib::ustring& tip2,
+const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
{
{
+ init_parent(key, wr, repr_in, doc_in);
+
_hbox = new Gtk::HBox;
_hbox->add (*manage (new Gtk::Label (label)));
_rb1 = manage (new Gtk::RadioButton (label1, true));
_hbox = new Gtk::HBox;
_hbox->add (*manage (new Gtk::Label (label)));
_rb1 = manage (new Gtk::RadioButton (label1, true));
_rb2->set_active();
_tt.set_tip (*_rb1, tip1);
_tt.set_tip (*_rb2, tip2);
_rb2->set_active();
_tt.set_tip (*_rb1, tip1);
_tt.set_tip (*_rb2, tip2);
- _key = key;
- _wr = ≀
_changed_connection = _rb1->signal_toggled().connect (sigc::mem_fun (*this, &RegisteredRadioButtonPair::on_value_changed));
}
_changed_connection = _rb1->signal_toggled().connect (sigc::mem_fun (*this, &RegisteredRadioButtonPair::on_value_changed));
}
-void
+void
RegisteredRadioButtonPair::setValue (bool second)
{
if (second) _rb2->set_active();
RegisteredRadioButtonPair::setValue (bool second)
{
if (second) _rb2->set_active();
if (_wr->isUpdating())
return;
if (_wr->isUpdating())
return;
- SPDesktop *dt = SP_ACTIVE_DESKTOP;
- if (!dt)
+ _wr->setUpdating (true);
+
+ bool second = _rb2->get_active();
+ write_to_xml(second ? "true" : "false");
+
+ _wr->setUpdating (false);
+}
+
+/*#########################################
+ * Registered POINT
+ */
+
+RegisteredPoint::RegisteredPoint()
+{
+ _widget = NULL;
+}
+
+RegisteredPoint::~RegisteredPoint()
+{
+ if (_widget)
+ delete _widget;
+
+ _value_x_changed_connection.disconnect();
+ _value_y_changed_connection.disconnect();
+}
+
+void
+RegisteredPoint::init ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument* doc_in )
+{
+ init_parent(key, wr, repr_in, doc_in);
+
+ _widget = new Point (label, tip);
+ _widget->setRange (-1e6, 1e6);
+ _widget->setDigits (2);
+ _widget->setIncrements(0.1, 1.0);
+ _value_x_changed_connection = _widget->signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredPoint::on_value_changed));
+ _value_y_changed_connection = _widget->signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredPoint::on_value_changed));
+}
+
+Point*
+RegisteredPoint::getPoint()
+{
+ return _widget;
+}
+
+void
+RegisteredPoint::setValue (double xval, double yval)
+{
+ _widget->setValue(xval, yval);
+ on_value_changed();
+}
+
+void
+RegisteredPoint::on_value_changed()
+{
+ if (_wr->isUpdating())
return;
_wr->setUpdating (true);
return;
_wr->setUpdating (true);
-
- bool second = _rb2->get_active();
- SPDocument *doc = sp_desktop_document(dt);
- gboolean saved = sp_document_get_undo_sensitive (doc);
- sp_document_set_undo_sensitive (doc, FALSE);
- Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
- repr->setAttribute(_key.c_str(), second ? "true" : "false");
- doc->rroot->setAttribute("sodipodi:modified", "true");
- sp_document_set_undo_sensitive (doc, saved);
- sp_document_done (doc, SP_VERB_NONE,
- /* TODO: annotate */ "registered-widget.cpp:405");
-
+
+ Inkscape::SVGOStringStream os;
+ os << _widget->getXValue() << "," << _widget->getYValue();
+
+ write_to_xml(os.str().c_str());
+
_wr->setUpdating (false);
}
_wr->setUpdating (false);
}
+/*#########################################
+ * Registered RANDOM
+ */
+
+RegisteredRandom::RegisteredRandom()
+{
+ _widget = NULL;
+}
+
+RegisteredRandom::~RegisteredRandom()
+{
+ if (_widget)
+ delete _widget;
+
+ _value_changed_connection.disconnect();
+ _reseeded_connection.disconnect();
+}
+
+void
+RegisteredRandom::init ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument * doc_in )
+{
+ init_parent(key, wr, repr_in, doc_in);
+
+ _widget = new Random (label, tip);
+ _widget->setRange (-1e6, 1e6);
+ _widget->setDigits (2);
+ _widget->setIncrements(0.1, 1.0);
+ _value_changed_connection = _widget->signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredRandom::on_value_changed));
+ _reseeded_connection = _widget->signal_reseeded.connect(sigc::mem_fun(*this, &RegisteredRandom::on_value_changed));
+}
+
+Random*
+RegisteredRandom::getR()
+{
+ return _widget;
+}
+
+void
+RegisteredRandom::setValue (double val, long startseed)
+{
+ _widget->setValue (val);
+ _widget->setStartSeed(startseed);
+ on_value_changed();
+}
+
+void
+RegisteredRandom::on_value_changed()
+{
+ if (_wr->isUpdating())
+ return;
+ _wr->setUpdating (true);
+
+ // FIXME: gtk bug?
+ // disable interruptibility: see http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/ui/widget/selected-style.cpp?r1=13149&r2=13257&sortby=date
+ SPDesktop* dt = SP_ACTIVE_DESKTOP;
+ sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(dt), 0);
+
+ Inkscape::SVGOStringStream os;
+ os << _widget->getValue() << ';' << _widget->getStartSeed();
+
+ write_to_xml(os.str().c_str());
+
+ // resume interruptibility
+ sp_canvas_end_forced_full_redraws(sp_desktop_canvas(dt));
+
+ _wr->setUpdating (false);
+}
+
+
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
} // namespace Dialog
} // namespace UI
} // namespace Inkscape