summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 231d862)
raw | patch | inline | side by side (parent: 231d862)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 27 Sep 2007 12:33:10 +0000 (12:33 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 27 Sep 2007 12:33:10 +0000 (12:33 +0000) |
index 555069b4ac1067774bb36f1f59053d51dfe616e5..405e82e04d7ef468cbd2079bcfebeb5f62bfa534 100644 (file)
{
public:
ComboBoxEnum(const Util::EnumDataConverter<E>& c, const SPAttributeEnum a = SP_ATTR_INVALID)
- : AttrWidget(a), _converter(c)
+ : AttrWidget(a), setProgrammatically(false), _converter(c)
{
signal_changed().connect(signal_attr_changed().make_slot());
virtual void set_from_attribute(SPObject* o)
{
+ setProgrammatically = true;
const gchar* val = attribute_value(o);
if(val)
set_active(_converter.get_id_from_key(val));
}
void set_active_by_id(E id) {
+ setProgrammatically = true;
for(Gtk::TreeModel::iterator i = _model->children().begin();
i != _model->children().end(); ++i)
{
};
void set_active_by_key(const Glib::ustring& key) {
+ setProgrammatically = true;
set_active_by_id( _converter.get_id_from_key(key) );
};
+ bool setProgrammatically;
+
private:
class Columns : public Gtk::TreeModel::ColumnRecord
{
index cfaa4303d47eb8746175be2d6bead5aa97215c69..ae7197c29fbc9aa3bafe0897587cdc6cad87ebeb 100644 (file)
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
Glib::ustring const &icon,\r
bool mnemonic)\r
: Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
- setProgrammatically(false),\r
xwidget("X:",""),\r
ywidget("Y:","")\r
{\r
Glib::ustring const &icon,\r
bool mnemonic)\r
: Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
- setProgrammatically(false),\r
xwidget("X:","", digits),\r
ywidget("Y:","", digits)\r
{\r
Glib::ustring const &icon,\r
bool mnemonic)\r
: Labelled(label, tooltip, new Gtk::VBox(), suffix, icon, mnemonic),\r
- setProgrammatically(false),\r
xwidget("X:","", adjust, digits),\r
ywidget("Y:","", adjust, digits)\r
{\r
void\r
Point::setValue(double xvalue, double yvalue)\r
{\r
- setProgrammatically = true; // callback is supposed to reset back, if it cares\r
xwidget.setValue(xvalue);\r
ywidget.setValue(yvalue);\r
}\r
ywidget.update();\r
}\r
\r
+/** Check 'setProgrammatically' of both scalar widgets. False if value is changed by user by clicking the widget. */\r
+bool\r
+Point::setProgrammatically() {\r
+ return (xwidget.setProgrammatically || ywidget.setProgrammatically);\r
+}\r
+\r
+void\r
+Point::clearProgrammatically() {\r
+ xwidget.setProgrammatically = false;\r
+ ywidget.setProgrammatically = false;\r
+}\r
\r
\r
/** Signal raised when the spin button's value changes */\r
diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h
index 291ae131ee40010df54c6cdfe1ed6f0d068b817e..7653ceaa43a593a79355202c99ebd5f907606123 100644 (file)
--- a/src/ui/widget/point.h
+++ b/src/ui/widget/point.h
Glib::SignalProxy0<void> signal_x_value_changed();\r
Glib::SignalProxy0<void> signal_y_value_changed();\r
\r
- bool setProgrammatically; // true if the value was set by setValue, not changed by the user; \r
- // if a callback checks it, it must reset it back to false\r
+ bool setProgrammatically(); // true if the value was set by setValue, not changed by the user; \r
+ // if a callback checks it, it must reset it back to false\r
+ void clearProgrammatically();\r
\r
protected:\r
Scalar xwidget, ywidget;\r
index bfa866e2931a98c096e20f27d79296cff5a5b1f1..41b40497835a20e42e56e330d5624dba79eaebf2 100644 (file)
\r
protected:\r
void on_changed() {\r
+ if (combobox()->setProgrammatically) {\r
+ combobox()->setProgrammatically = false;\r
+ return;\r
+ }\r
+\r
if (_wr->isUpdating())\r
return;\r
_wr->setUpdating (true);\r
index 5f59eff8fb89bf55dc49d0fa2b861faa155302c6..46532d35848aa15bf60b058aefef51e511c8dac4 100644 (file)
//====================================================
RegisteredCheckButton::RegisteredCheckButton()
-: _button(0)
+: _button(0),
+ setProgrammatically(false)
{
}
@@ -109,16 +110,23 @@ RegisteredCheckButton::init (const Glib::ustring& label, const Glib::ustring& ti
void
RegisteredCheckButton::setActive (bool b)
{
+// FIXME: for some reason, this function is also called when user clicks. then setProgrammatically should not be set!
+ setProgrammatically = true;
_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);
- }
+ //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
RegisteredCheckButton::on_toggled()
{
+ if (setProgrammatically) {
+ setProgrammatically = false;
+ return;
+ }
+
if (_wr->isUpdating())
return;
RegisteredScalarUnit::setValue (double val)
{
_widget->setValue (val);
- on_value_changed();
}
void
RegisteredScalarUnit::on_value_changed()
{
+ if (_widget->setProgrammatically) {
+ _widget->setProgrammatically = false;
+ return;
+ }
+
if (_wr->isUpdating())
return;
RegisteredScalar::setValue (double val)
{
_widget->setValue (val);
- on_value_changed();
}
void
RegisteredScalar::on_value_changed()
{
+ if (_widget->setProgrammatically) {
+ _widget->setProgrammatically = false;
+ return;
+ }
+
if (_wr->isUpdating()) {
return;
}
}
RegisteredSuffixedInteger::RegisteredSuffixedInteger()
-: _label(0), _sb(0),
+: _label(0),
+ setProgrammatically(false),
+ _sb(0),
_adj(0.0,0.0,100.0,1.0,1.0,1.0),
_suffix(0)
{
@@ -404,12 +422,18 @@ RegisteredSuffixedInteger::init (const Glib::ustring& label, const Glib::ustring
void
RegisteredSuffixedInteger::setValue (int i)
{
+ setProgrammatically = true;
_adj.set_value (i);
}
void
RegisteredSuffixedInteger::on_value_changed()
{
+ if (setProgrammatically) {
+ setProgrammatically = false;
+ return;
+ }
+
if (_wr->isUpdating())
return;
}
RegisteredRadioButtonPair::RegisteredRadioButtonPair()
-: _hbox(0)
+: _hbox(0),
+ setProgrammatically(false)
{
}
@@ -458,6 +483,7 @@ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument
void
RegisteredRadioButtonPair::setValue (bool second)
{
+ setProgrammatically = true;
if (second) _rb2->set_active();
else _rb1->set_active();
}
void
RegisteredRadioButtonPair::on_value_changed()
{
+ if (setProgrammatically) {
+ setProgrammatically = false;
+ return;
+ }
+
if (_wr->isUpdating())
return;
RegisteredPoint::setValue (double xval, double yval)
{
_widget->setValue(xval, yval);
- on_value_changed();
}
void
RegisteredPoint::on_value_changed()
{
+ if (_widget->setProgrammatically()) {
+ _widget->clearProgrammatically();
+ return;
+ }
+
if (_wr->isUpdating())
return;
{
_widget->setValue (val);
_widget->setStartSeed(startseed);
- on_value_changed();
}
void
RegisteredRandom::on_value_changed()
{
+ if (_widget->setProgrammatically) {
+ _widget->setProgrammatically = false;
+ return;
+ }
+
if (_wr->isUpdating())
return;
_wr->setUpdating (true);
index 3d4dd851b3adbea0b4c299a98644a9b95b2b936c..33d7c29cd1314997a5e82d9f3c81b65ff52336c5 100644 (file)
void setSlaveButton(std::list<Gtk::ToggleButton*> btns) {
_slavebuttons = btns;
}
-
+
+ bool setProgrammatically; // true if the value was set by setValue, not changed by the user;
+ // if a callback checks it, it must reset it back to false
+
protected:
Gtk::Tooltips _tt;
void setValue (int);
Gtk::Label *_label;
Gtk::HBox _hbox;
+ bool setProgrammatically; // true if the value was set by setValue, not changed by the user;
+ // if a callback checks it, it must reset it back to false
protected:
Gtk::SpinButton *_sb;
void setValue (bool second);
Gtk::HBox *_hbox;
+ bool setProgrammatically; // true if the value was set by setValue, not changed by the user;
+ // if a callback checks it, it must reset it back to false
protected:
Gtk::RadioButton *_rb1, *_rb2;
Gtk::Tooltips _tt;