Code

Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in...
[inkscape.git] / src / ui / widget / preferences-widget.cpp
1 /**
2  * \brief Inkscape Preferences dialog
3  *
4  * Authors:
5  *   Marco Scholten
6  *   Bruno Dilly <bruno.dilly@gmail.com>
7  *
8  * Copyright (C) 2004, 2006, 2007 Authors
9  *
10  * Released under GNU GPL.  Read the file 'COPYING' for more information.
11  */
13 #ifdef HAVE_CONFIG_H
14 # include <config.h>
15 #endif
17 #include <gtkmm/frame.h>
18 #include <gtkmm/alignment.h>
19 #include <gtkmm/box.h>
21 #include "preferences.h"
22 #include "ui/widget/preferences-widget.h"
23 #include "verbs.h"
24 #include "selcue.h"
25 #include <iostream>
26 #include "enums.h"
27 #include "inkscape.h"
28 #include "desktop-handles.h"
29 #include "message-stack.h"
30 #include "style.h"
31 #include "selection.h"
32 #include "selection-chemistry.h"
33 #include "xml/repr.h"
35 using namespace Inkscape::UI::Widget;
37 namespace Inkscape {
38 namespace UI {
39 namespace Widget {
41 DialogPage::DialogPage()
42 {
43     this->set_border_width(12);
44     this->set_col_spacings(12);
45     this->set_row_spacings(6);
46 }
48 void DialogPage::add_line(bool indent, Glib::ustring const &label, Gtk::Widget &widget, Glib::ustring const &suffix, const Glib::ustring &tip, bool expand_widget)
49 {
50     int start_col;
51     int row = this->property_n_rows();
52     Gtk::Widget* w;
53     if (expand_widget)
54     {
55         w = &widget;
56     }
57     else
58     {
59         Gtk::HBox* hb = Gtk::manage(new Gtk::HBox());
60         hb->set_spacing(12);
61         hb->pack_start(widget,false,false);
62         w = (Gtk::Widget*) hb;
63     }
64     if (label != "")
65     {
66         Gtk::Label* label_widget;
67         label_widget = Gtk::manage(new Gtk::Label(label , Gtk::ALIGN_LEFT , Gtk::ALIGN_CENTER, true));
68         label_widget->set_mnemonic_widget(widget);
69         if (indent)
70         {
71             Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment());
72             alignment->set_padding(0, 0, 12, 0);
73             alignment->add(*label_widget);
74             this->attach(*alignment , 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
75         }
76         else
77             this->attach(*label_widget , 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
78         start_col = 1;
79     }
80     else
81         start_col = 0;
83     if (start_col == 0 && indent) //indent this widget
84     {
85         Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment());
86         alignment->set_padding(0, 0, 12, 0);
87         alignment->add(*w);
88         this->attach(*alignment, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(),  0, 0);
89     }
90     else
91     {
92         this->attach(*w, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(),  0, 0);
93     }
95     if (suffix != "")
96     {
97         Gtk::Label* suffix_widget = Gtk::manage(new Gtk::Label(suffix , Gtk::ALIGN_LEFT , Gtk::ALIGN_CENTER, true));
98         if (expand_widget)
99             this->attach(*suffix_widget, 2, 3, row, row + 1, Gtk::FILL,  Gtk::AttachOptions(), 0, 0);
100         else
101             ((Gtk::HBox*)w)->pack_start(*suffix_widget,false,false);
102     }
104     if (tip != "")
105     {
106         _tooltips.set_tip (widget, tip);
107     }
111 void DialogPage::add_group_header(Glib::ustring name)
113     int row = this->property_n_rows();
114     if (name != "")
115     {
116         Gtk::Label* label_widget = Gtk::manage(new Gtk::Label(Glib::ustring(/*"<span size='large'>*/"<b>") + name +
117                                                Glib::ustring("</b>"/*</span>"*/) , Gtk::ALIGN_LEFT , Gtk::ALIGN_CENTER, true));
118         label_widget->set_use_markup(true);
119         this->attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
120         if (row != 1)
121             this->set_row_spacing(row - 1, 18);
122     }
125 void DialogPage::set_tip(Gtk::Widget& widget, Glib::ustring const &tip)
127     _tooltips.set_tip (widget, tip);
130 void PrefCheckButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
131     bool default_value)
133     _prefs_path = prefs_path;
134     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
135     this->set_label(label);
136     this->set_active( prefs->getBool(_prefs_path, default_value) );
139 void PrefCheckButton::on_toggled()
141     if (this->is_visible()) //only take action if the user toggled it
142     {
143         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
144         prefs->setBool(_prefs_path, this->get_active());
145     }
148 void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
149     Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member)
151     _prefs_path = prefs_path;
152     _value_type = VAL_STRING;
153     _string_value = string_value;
154     (void)default_value;
155     this->set_label(label);
156     if (group_member)
157     {
158         Gtk::RadioButtonGroup rbg = group_member->get_group();
159         this->set_group(rbg);
160     }
161     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
162     Glib::ustring val = prefs->getString(_prefs_path);
163     if ( !val.empty() )
164         this->set_active(val == _string_value);
165     else
166         this->set_active( false );
169 void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
170     int int_value, bool default_value, PrefRadioButton* group_member)
172     _prefs_path = prefs_path;
173     _value_type = VAL_INT;
174     _int_value = int_value;
175     this->set_label(label);
176     if (group_member)
177     {
178         Gtk::RadioButtonGroup rbg = group_member->get_group();
179         this->set_group(rbg);
180     }
181     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
182     if (default_value)
183         this->set_active( prefs->getInt(_prefs_path, int_value) == _int_value );
184     else
185         this->set_active( prefs->getInt(_prefs_path, int_value + 1) == _int_value );
188 void PrefRadioButton::on_toggled()
190     this->changed_signal.emit(this->get_active());
191     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
193     if (this->is_visible() && this->get_active() ) //only take action if toggled by user (to active)
194     {
195         if ( _value_type == VAL_STRING )
196             prefs->setString(_prefs_path, _string_value);
197         else if ( _value_type == VAL_INT )
198             prefs->setInt(_prefs_path, _int_value);
199     }
202 void PrefSpinButton::init(Glib::ustring const &prefs_path,
203               double lower, double upper, double step_increment, double /*page_increment*/,
204               double default_value, bool is_int, bool is_percent)
206     _prefs_path = prefs_path;
207     _is_int = is_int;
208     _is_percent = is_percent;
209     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
210     double value;
211     if (is_int) {
212         if (is_percent) {
213             value = 100 * prefs->getDoubleLimited(prefs_path, default_value, lower/100.0, upper/100.0);
214         } else {
215             value = (double) prefs->getIntLimited(prefs_path, (int) default_value, (int) lower, (int) upper);
216         }
217     } else {
218         value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper);
219     }
221     this->set_range (lower, upper);
222     this->set_increments (step_increment, 0);
223     this->set_numeric();
224     this->set_value (value);
225     this->set_width_chars(6);
226     if (is_int)
227         this->set_digits(0);
228     else if (step_increment < 0.1)
229         this->set_digits(4);
230     else
231         this->set_digits(2);
235 void PrefSpinButton::on_value_changed()
237     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
238     if (this->is_visible()) //only take action if user changed value
239     {
240         if (_is_int) {
241             if (_is_percent) {
242                 prefs->setDouble(_prefs_path, this->get_value()/100.0);
243             } else {
244                 prefs->setInt(_prefs_path, (int) this->get_value());
245             }
246         } else {
247             prefs->setDouble(_prefs_path, this->get_value());
248         }
249     }
252 const double ZoomCorrRuler::textsize = 7;
253 const double ZoomCorrRuler::textpadding = 5;
255 ZoomCorrRuler::ZoomCorrRuler(int width, int height) :
256     _unitconv(1.0),
257     _border(5)
259     set_size(width, height);
262 void ZoomCorrRuler::set_size(int x, int y)
264     _min_width = x;
265     _height = y;
266     set_size_request(x + _border*2, y + _border*2);
269 // The following two functions are borrowed from 2geom's toy-framework-2; if they are useful in
270 // other locations, we should perhaps make them (or adapted versions of them) publicly available
271 static void
272 draw_text(cairo_t *cr, Geom::Point loc, const char* txt, bool bottom = false,
273           double fontsize = ZoomCorrRuler::textsize, std::string fontdesc = "Sans") {
274     PangoLayout* layout = pango_cairo_create_layout (cr);
275     pango_layout_set_text(layout, txt, -1);
277     // set font and size
278     std::ostringstream sizestr;
279     sizestr << fontsize;
280     fontdesc = fontdesc + " " + sizestr.str();
281     PangoFontDescription *font_desc = pango_font_description_from_string(fontdesc.c_str());
282     pango_layout_set_font_description(layout, font_desc);
283     pango_font_description_free (font_desc);
285     PangoRectangle logical_extent;
286     pango_layout_get_pixel_extents(layout, NULL, &logical_extent);
287     cairo_move_to(cr, loc[Geom::X], loc[Geom::Y] - (bottom ? logical_extent.height : 0));
288     pango_cairo_show_layout(cr, layout);
291 static void
292 draw_number(cairo_t *cr, Geom::Point pos, double num) {
293     std::ostringstream number;
294     number << num;
295     draw_text(cr, pos, number.str().c_str(), true);
298 /*
299  * \arg dist The distance between consecutive minor marks
300  * \arg major_interval Number of marks after which to draw a major mark
301  */
302 void
303 ZoomCorrRuler::draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval) {
304     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
305     const double zoomcorr = prefs->getDouble("/options/zoomcorrection/value", 1.0);
306     double mark = 0;
307     int i = 0;
308     while (mark <= _drawing_width) {
309         cr->move_to(mark, _height);
310         if ((i % major_interval) == 0) {
311             // major mark
312             cr->line_to(mark, 0);
313             Geom::Point textpos(mark + 3, ZoomCorrRuler::textsize + ZoomCorrRuler::textpadding);
314             draw_number(cr->cobj(), textpos, dist * i);
315         } else {
316             // minor mark
317             cr->line_to(mark, ZoomCorrRuler::textsize + 2 * ZoomCorrRuler::textpadding);
318         }
319         mark += dist * zoomcorr / _unitconv;
320         ++i;
321     }
324 void
325 ZoomCorrRuler::redraw() {
326     Glib::RefPtr<Gdk::Window> window = get_window();
327     Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
329     int w, h;
330     window->get_size(w, h);
331     _drawing_width = w - _border * 2;
333     cr->set_source_rgb(1.0, 1.0, 1.0);
334     cr->set_fill_rule(Cairo::FILL_RULE_WINDING);
335     cr->rectangle(0, 0, w, _height + _border*2);
336     cr->fill();
338     cr->set_source_rgb(0.0, 0.0, 0.0);
339     cr->set_line_width(0.5);
341     cr->translate(_border, _border); // so that we have a small white border around the ruler
342     cr->move_to (0, _height);
343     cr->line_to (_drawing_width, _height);
345     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
346     Glib::ustring abbr = prefs->getString("/options/zoomcorrection/unit");
347     if (abbr == "cm") {
348         draw_marks(cr, 0.1, 10);
349     } else if (abbr == "ft") {
350         draw_marks(cr, 1/12.0, 12);
351     } else if (abbr == "in") {
352         draw_marks(cr, 0.25, 4);
353     } else if (abbr == "m") {
354         draw_marks(cr, 1/10.0, 10);
355     } else if (abbr == "mm") {
356         draw_marks(cr, 10, 10);
357     } else if (abbr == "pc") {
358         draw_marks(cr, 1, 10);
359     } else if (abbr == "pt") {
360         draw_marks(cr, 10, 10);
361     } else if (abbr == "px") {
362         draw_marks(cr, 10, 10);
363     } else {
364         draw_marks(cr, 1, 1);
365     }
366     cr->stroke();
369 bool
370 ZoomCorrRuler::on_expose_event(GdkEventExpose */*event*/) {
371     this->redraw();
372     return true;
375 void
376 ZoomCorrRulerSlider::on_slider_value_changed()
378     if (this->is_visible() || freeze) //only take action if user changed value
379     {
380         freeze = true;
381         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
382         prefs->setDouble("/options/zoomcorrection/value", _slider.get_value() / 100.0);
383         _sb.set_value(_slider.get_value());
384         _ruler.redraw();
385         freeze = false;
386     }
389 void
390 ZoomCorrRulerSlider::on_spinbutton_value_changed()
392     if (this->is_visible() || freeze) //only take action if user changed value
393     {
394         freeze = true;
395         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
396         prefs->setDouble("/options/zoomcorrection/value", _sb.get_value() / 100.0);
397         _slider.set_value(_sb.get_value());
398         _ruler.redraw();
399         freeze = false;
400     }
403 void
404 ZoomCorrRulerSlider::on_unit_changed() {
405     if (GPOINTER_TO_INT(_unit.get_data("sensitive")) == 0) {
406         // when the unit menu is initialized, the unit is set to the default but
407         // it needs to be reset later so we don't perform the change in this case
408         return;
409     }
410     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
411     prefs->setString("/options/zoomcorrection/unit", _unit.getUnitAbbr());
412     double conv = _unit.getConversion(_unit.getUnitAbbr(), "px");
413     _ruler.set_unit_conversion(conv);
414     if (_ruler.is_visible()) {
415         _ruler.redraw();
416     }
419 void
420 ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, double upper,
421                       double step_increment, double page_increment, double default_value)
423     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
424     double value = prefs->getDoubleLimited("/options/zoomcorrection/value", default_value, lower, upper) * 100.0;
426     freeze = false;
428     _ruler.set_size(ruler_width, ruler_height);
430     _slider.set_size_request(_ruler.width(), -1);
431     _slider.set_range (lower, upper);
432     _slider.set_increments (step_increment, page_increment);
433     _slider.set_value (value);
434     _slider.set_digits(2);
436     _slider.signal_value_changed().connect(sigc::mem_fun(*this, &ZoomCorrRulerSlider::on_slider_value_changed));
437     _sb.signal_value_changed().connect(sigc::mem_fun(*this, &ZoomCorrRulerSlider::on_spinbutton_value_changed));
438     _unit.signal_changed().connect(sigc::mem_fun(*this, &ZoomCorrRulerSlider::on_unit_changed));
440     _sb.set_range (lower, upper);
441     _sb.set_increments (step_increment, 0);
442     _sb.set_value (value);
443     _sb.set_digits(2);
445     _unit.set_data("sensitive", GINT_TO_POINTER(0));
446     _unit.setUnitType(UNIT_TYPE_LINEAR);
447     _unit.set_data("sensitive", GINT_TO_POINTER(1));
448     _unit.setUnit(prefs->getString("/options/zoomcorrection/unit"));
450     Gtk::Table *table = Gtk::manage(new Gtk::Table());
451     Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
452     Gtk::Alignment *alignment2 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
453     alignment1->add(_sb);
454     alignment2->add(_unit);
456     table->attach(_slider,     0, 1, 0, 1);
457     table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
458     table->attach(_ruler,      0, 1, 1, 2);
459     table->attach(*alignment2, 1, 2, 1, 2, static_cast<Gtk::AttachOptions>(0));
461     this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
464 void
465 PrefSlider::on_slider_value_changed()
467     if (this->is_visible() || freeze) //only take action if user changed value
468     {
469         freeze = true;
470         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
471         prefs->setDouble(_prefs_path, _slider.get_value());
472         _sb.set_value(_slider.get_value());
473         freeze = false;
474     }
477 void
478 PrefSlider::on_spinbutton_value_changed()
480     if (this->is_visible() || freeze) //only take action if user changed value
481     {
482         freeze = true;
483         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
484         prefs->setDouble(_prefs_path, _sb.get_value());
485         _slider.set_value(_sb.get_value());
486         freeze = false;
487     }
490 void
491 PrefSlider::init(Glib::ustring const &prefs_path,
492                  double lower, double upper, double step_increment, double page_increment, double default_value, int digits)
494     _prefs_path = prefs_path;
496     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
497     double value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper);
499     freeze = false;
501     _slider.set_range (lower, upper);
502     _slider.set_increments (step_increment, page_increment);
503     _slider.set_value (value);
504     _slider.set_digits(digits);
505     _slider.signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_slider_value_changed));
507     _sb.signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_spinbutton_value_changed));
508     _sb.set_range (lower, upper);
509     _sb.set_increments (step_increment, 0);
510     _sb.set_value (value);
511     _sb.set_digits(digits);
513     Gtk::Table *table = Gtk::manage(new Gtk::Table());
514     Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
515     alignment1->add(_sb);
517     table->attach(_slider,     0, 1, 0, 1);
518     table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
520     this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
523 void PrefCombo::init(Glib::ustring const &prefs_path,
524                      Glib::ustring labels[], int values[], int num_items, int default_value)
526     _prefs_path = prefs_path;
527     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
528     int row = 0;
529     int value = prefs->getInt(_prefs_path, default_value);
531     for (int i = 0 ; i < num_items; ++i)
532     {
533         this->append_text(labels[i]);
534         _values.push_back(values[i]);
535         if (value == values[i])
536             row = i;
537     }
538     this->set_active(row);
541 /**
542     initialize a combo box
543     second form uses strings as key values
544 */
545 void PrefCombo::init(Glib::ustring const &prefs_path,
546                      Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value)
548     _prefs_path = prefs_path;
549     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
550     int row = 0;
551     Glib::ustring value = prefs->getString(_prefs_path);
552     if(value.empty())
553     {
554         value = default_value;
555     }
557     for (int i = 0 ; i < num_items; ++i)
558     {
559         this->append_text(labels[i]);
560         _ustr_values.push_back(values[i]);
561         if (value == values[i])
562             row = i;
563     }
564     this->set_active(row);
567 void PrefCombo::on_changed()
569     if (this->is_visible()) //only take action if user changed value
570     {
571         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
572         if(_values.size() > 0)
573         {
574             prefs->setInt(_prefs_path, _values[this->get_active_row_number()]);
575         }
576         else
577         {
578             prefs->setString(_prefs_path, _ustr_values[this->get_active_row_number()]);
579         }
580     }
583 void PrefEntryButtonHBox::init(Glib::ustring const &prefs_path,
584             bool visibility, Glib::ustring const &default_string)
586     _prefs_path = prefs_path;
587     _default_string = default_string;
588     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
589     relatedEntry = new Gtk::Entry();
590     relatedButton = new Gtk::Button(_("Reset"));
591     relatedEntry->set_invisible_char('*');
592     relatedEntry->set_visibility(visibility);
593     relatedEntry->set_text(prefs->getString(_prefs_path));
594     this->pack_start(*relatedEntry);
595     this->pack_start(*relatedButton);
596     relatedButton->signal_clicked().connect(
597             sigc::mem_fun(*this, &PrefEntryButtonHBox::onRelatedButtonClickedCallback));
598     relatedEntry->signal_changed().connect(
599             sigc::mem_fun(*this, &PrefEntryButtonHBox::onRelatedEntryChangedCallback));
602 void PrefEntryButtonHBox::onRelatedEntryChangedCallback()
604     if (this->is_visible()) //only take action if user changed value
605     {
606         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
607         prefs->setString(_prefs_path, relatedEntry->get_text());
608     }
611 void PrefEntryButtonHBox::onRelatedButtonClickedCallback()
613     if (this->is_visible()) //only take action if user changed value
614     {
615         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
616         prefs->setString(_prefs_path, _default_string);
617         relatedEntry->set_text(_default_string);
618     }
622 void PrefFileButton::init(Glib::ustring const &prefs_path)
624     _prefs_path = prefs_path;
625     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
626     select_filename(Glib::filename_from_utf8(prefs->getString(_prefs_path)));
628     signal_selection_changed().connect(sigc::mem_fun(*this, &PrefFileButton::onFileChanged));
631 void PrefFileButton::onFileChanged()
633     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
634     prefs->setString(_prefs_path, Glib::filename_to_utf8(get_filename()));
637 void PrefEntry::init(Glib::ustring const &prefs_path, bool visibility)
639     _prefs_path = prefs_path;
640     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
641     this->set_invisible_char('*');
642     this->set_visibility(visibility);
643     this->set_text(prefs->getString(_prefs_path));
646 void PrefEntry::on_changed()
648     if (this->is_visible()) //only take action if user changed value
649     {
650         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
651         prefs->setString(_prefs_path, this->get_text());
652     }
655 void PrefColorPicker::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
656                            guint32 default_rgba)
658     _prefs_path = prefs_path;
659     _title = label;
660     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
661     this->setRgba32( prefs->getInt(_prefs_path, (int)default_rgba) );
664 void PrefColorPicker::on_changed (guint32 rgba)
666     if (this->is_visible()) //only take action if the user toggled it
667     {
668         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
669         prefs->setInt(_prefs_path, (int) rgba);
670     }
673 void PrefUnit::init(Glib::ustring const &prefs_path)
675     _prefs_path = prefs_path;
676     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
677     setUnitType(UNIT_TYPE_LINEAR);
678     setUnit(prefs->getString(_prefs_path));
681 void PrefUnit::on_changed()
683     if (this->is_visible()) //only take action if user changed value
684     {
685         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
686         prefs->setString(_prefs_path, getUnitAbbr());
687     }
690 } // namespace Widget
691 } // namespace UI
692 } // namespace Inkscape
694 /*
695   Local Variables:
696   mode:c++
697   c-file-style:"stroustrup"
698   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
699   indent-tabs-mode:nil
700   fill-column:99
701   End:
702 */
703 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :