X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fui%2Fwidget%2Fpreferences-widget.cpp;h=4de42f36f41e126453242ae29c1ffa56d41e3519;hb=da15593ce819c0c0fa2c2adaddebde9de7e0f62c;hp=00d8b5a267e4c360ef3ff86fb18930b865a8f290;hpb=10233f4d8b628c765ea0b54c84da614cadf0f2c3;p=inkscape.git diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 00d8b5a26..4de42f36f 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -3,8 +3,9 @@ * * Authors: * Marco Scholten + * Bruno Dilly * - * Copyright (C) 2004, 2006 Authors + * Copyright (C) 2004, 2006, 2007 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -266,6 +267,64 @@ void PrefCombo::on_changed() } } +void PrefEntryButtonHBox::init(const std::string& prefs_path, const std::string& attr, + bool visibility, gchar* default_string) +{ + _prefs_path = prefs_path; + _attr = attr; + _default_string = default_string; + relatedEntry = new Gtk::Entry(); + relatedButton = new Gtk::Button("Reset"); + relatedEntry->set_invisible_char('*'); + relatedEntry->set_visibility(visibility); + relatedEntry->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str())); + this->pack_start(*relatedEntry); + this->pack_start(*relatedButton); + relatedButton->signal_clicked().connect( + sigc::mem_fun(*this, &PrefEntryButtonHBox::onRelatedButtonClickedCallback)); + relatedEntry->signal_changed().connect( + sigc::mem_fun(*this, &PrefEntryButtonHBox::onRelatedEntryChangedCallback)); +} + +void PrefEntryButtonHBox::onRelatedEntryChangedCallback() +{ + if (this->is_visible()) //only take action if user changed value + { + prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), + relatedEntry->get_text().c_str()); + } +} + +void PrefEntryButtonHBox::onRelatedButtonClickedCallback() +{ + if (this->is_visible()) //only take action if user changed value + { + prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), + _default_string); + relatedEntry->set_text(_default_string); + } +} + + + +void PrefEntry::init(const std::string& prefs_path, const std::string& attr, + bool visibility) +{ + _prefs_path = prefs_path; + _attr = attr; + this->set_invisible_char('*'); + this->set_visibility(visibility); + this->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str())); +} + +void PrefEntry::on_changed() +{ + if (this->is_visible()) //only take action if user changed value + { + prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_text().c_str()); + } +} + } // namespace Widget } // namespace UI } // namespace Inkscape