Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / ui / widget / tolerance-slider.cpp
index d89d4cf5c858299a47f1bcfe7afa7985060ae00a..cc179ddbca55b37d8ef2039060906076e67d3866 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Authors:
  *   Ralf Stephan <ralf@ark.in-berlin.de> 
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Authors
  *
@@ -54,7 +55,7 @@ ToleranceSlider::~ToleranceSlider()
 }
 
 void
-ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& key, Registry& wr)
+ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr)
 {
     // hbox = label + slider
     //
@@ -87,17 +88,26 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2,
     
     Gtk::Label *theLabel2 = manage (new Gtk::Label (label2));
     theLabel2->set_use_underline();
-    _button = manage (new Gtk::CheckButton);
-    _tt.set_tip (*_button, tip2);
-    _button->add (*theLabel2);
-    _button->set_alignment (0.0, 0.5);
+    Gtk::Label *theLabel3 = manage (new Gtk::Label (label3));
+    theLabel3->set_use_underline();    
+    _button1 = manage (new Gtk::RadioButton);
+    _radio_button_group = _button1->get_group();
+    _button2 = manage (new Gtk::RadioButton);
+    _button2->set_group(_radio_button_group);    
+    _tt.set_tip (*_button1, tip2);
+    _tt.set_tip (*_button2, tip3);    
+    _button1->add (*theLabel3);
+    _button1->set_alignment (0.0, 0.5);    
+    _button2->add (*theLabel2);
+    _button2->set_alignment (0.0, 0.5);
     
-    _vbox->add (*_button);
+    _vbox->add (*_button1);
+    _vbox->add (*_button2);    
     // Here we need some extra pixels to get the vertical spacing right. Why? 
     _vbox->pack_end(*_hbox, true, true, 3); // add 3 px.  
     _key = key;
     _scale_changed_connection = _hscale->signal_value_changed().connect (sigc::mem_fun (*this, &ToleranceSlider::on_scale_changed));
-    _btn_toggled_connection = _button->signal_toggled().connect (sigc::mem_fun (*this, &ToleranceSlider::on_toggled));
+    _btn_toggled_connection = _button2->signal_toggled().connect (sigc::mem_fun (*this, &ToleranceSlider::on_toggled));
     _wr = &wr;
     _vbox->show_all_children();
 }
@@ -113,13 +123,15 @@ ToleranceSlider::setValue (double val)
 
     if (val > 9999.9) // magic value 10000.0
     {
-        _button->set_active (true);
+        _button1->set_active (true);
+        _button2->set_active (false);        
         _hbox->set_sensitive (false);
         val = 50.0;
     }
     else
     {
-        _button->set_active (false);
+        _button1->set_active (false);
+        _button2->set_active (true);        
         _hbox->set_sensitive (true);
     }
     _hscale->set_value (val);
@@ -142,7 +154,7 @@ ToleranceSlider::on_scale_changed()
 void
 ToleranceSlider::on_toggled()
 {
-    if (_button->get_active())
+    if (!_button2->get_active())
     {
         _old_val = _hscale->get_value();
         _hbox->set_sensitive (false);
@@ -175,12 +187,13 @@ ToleranceSlider::update (double val)
     _wr->setUpdating (true);
 
     SPDocument *doc = sp_desktop_document(dt);
-    bool saved = sp_document_get_undo_sensitive (doc);
-    sp_document_set_undo_sensitive (doc, false);
+    bool saved = DocumentUndo::getUndoSensitive(doc);
+    DocumentUndo::setUndoSensitive(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);
+    DocumentUndo::setUndoSensitive(doc, saved);
+
+    doc->setModifiedSinceSave();
     
     _wr->setUpdating (false);
 }