diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2008-09-16 17:15:22 +0000 |
|---|---|---|
| committer | tweenk <tweenk@users.sourceforge.net> | 2008-09-16 17:15:22 +0000 |
| commit | 9d87d30b72145fdee954992a9dc70f8c60174d7d (patch) | |
| tree | 194a94ece6ed668ad7dc529de2cdd09b7565c6fe /src/ui/dialog | |
| parent | fix leak of the arena and arenaitem (diff) | |
| download | inkscape-9d87d30b72145fdee954992a9dc70f8c60174d7d.tar.gz inkscape-9d87d30b72145fdee954992a9dc70f8c60174d7d.zip | |
Refactored preferences handling into a new version of
the Inkscape::Preferences class. Removed all use of
prefs_get_string_attribute(), pref_path_get_nth_child() and
create_pref() in favor of the new API. Replaced some "0 or 1" integer
preferences with booleans.
(bzr r6823)
Diffstat (limited to 'src/ui/dialog')
| -rw-r--r-- | src/ui/dialog/extension-editor.cpp | 12 | ||||
| -rw-r--r-- | src/ui/dialog/filter-effects-dialog.cpp | 15 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 48 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 10 | ||||
| -rw-r--r-- | src/ui/dialog/ocaldialogs.cpp | 7 | ||||
| -rw-r--r-- | src/ui/dialog/whiteboard-connect.cpp | 23 | ||||
| -rw-r--r-- | src/ui/dialog/whiteboard-sharewithchat.cpp | 36 |
7 files changed, 88 insertions, 63 deletions
diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index d26e05f07..a92087668 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -23,7 +23,7 @@ #include "extension-editor.h" #include "verbs.h" -#include "prefs-utils.h" +#include "preferences.h" #include "interface.h" #include "extension/extension.h" @@ -83,9 +83,10 @@ ExtensionEditor::ExtensionEditor() vbox_page->pack_start(*notebook, true, true, 0); Inkscape::Extension::db.foreach(dbfunc, this); - - gchar const * defaultext = prefs_get_string_attribute("dialogs.extensioneditor", "selected-extension"); - if (defaultext == NULL) defaultext = "org.inkscape.input.svg"; + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring defaultext = prefs->getString("dialogs.extensioneditor", "selected-extension"); + if (defaultext.empty()) defaultext = "org.inkscape.input.svg"; this->setExtension(defaultext); show_all_children(); @@ -135,7 +136,8 @@ ExtensionEditor::on_pagelist_selection_changed (void) Glib::ustring name = row[_page_list_columns._col_name]; /* Set the selection in the preferences */ - prefs_set_string_attribute("dialogs.extensioneditor", "selected-extension", id.c_str()); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString("dialogs.extensioneditor", "selected-extension", id); /* Adjust the dialog's title */ gchar title[500]; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index d577a6cc4..6571f4e97 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -39,7 +39,7 @@ #include "filter-enums.h" #include "inkscape.h" #include "path-prefix.h" -#include "prefs-utils.h" +#include "preferences.h" #include "selection.h" #include "sp-feblend.h" #include "sp-fecolormatrix.h" @@ -661,9 +661,10 @@ private: void select_file(){ //# Get the current directory for finding files + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring open_path; - char *attr = (char *)prefs_get_string_attribute("dialogs.open", "path"); - if (attr) + Glib::ustring attr = prefs->getString("dialogs.open", "path"); + if (!attr.empty()) open_path = attr; //# Test if the open_path directory exists @@ -707,7 +708,7 @@ private: open_path = fileName; open_path.append(G_DIR_SEPARATOR_S); - prefs_set_string_attribute("dialogs.open", "path", open_path.c_str()); + prefs->setString("dialogs.open", "path", open_path); _entry.set_text(fileName); } @@ -2294,7 +2295,8 @@ void FilterEffectsDialog::add_primitive() void FilterEffectsDialog::update_primitive_infobox() { - if (prefs_get_int_attribute ("options.showfiltersinfobox", "value", 1)){ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("options.showfiltersinfobox", "value", true)){ _infobox_icon.show(); _infobox_desc.show(); } else { @@ -2478,7 +2480,8 @@ void FilterEffectsDialog::update_settings_view() for(unsigned int i=0; i<vect1.size(); i++) vect1[i]->hide_all(); _empty_settings.show(); - if (prefs_get_int_attribute ("options.showfiltersinfobox", "value", 1)){ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("options.showfiltersinfobox", "value", true)){ _infobox_icon.show(); _infobox_desc.show(); } else { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index dcfc4e575..2eec63478 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -21,7 +21,7 @@ #include <gtkmm/scrolledwindow.h> #include <gtkmm/alignment.h> -#include "prefs-utils.h" +#include "preferences.h" #include "inkscape-preferences.h" #include "verbs.h" #include "selcue.h" @@ -227,27 +227,27 @@ void InkscapePreferences::initPageSteps() _("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false); } -void InkscapePreferences::AddSelcueCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value) +void InkscapePreferences::AddSelcueCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value) { PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); cb->init ( _("Show selection cue"), prefs_path, "selcue", def_value); p.add_line( false, "", *cb, "", _("Whether selected objects display a selection cue (the same as in selector)")); } -void InkscapePreferences::AddGradientCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value) +void InkscapePreferences::AddGradientCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value) { PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); cb->init ( _("Enable gradient editing"), prefs_path, "gradientdrag", def_value); p.add_line( false, "", *cb, "", _("Whether selected objects display gradient editing controls")); } -void InkscapePreferences::AddConvertGuidesCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value) { +void InkscapePreferences::AddConvertGuidesCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value) { PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); cb->init ( _("Conversion to guides uses edges instead of bounding box"), prefs_path, "convertguides", def_value); p.add_line( false, "", *cb, "", _("Converting an object to guides places these along the object's true edges (imitating the object's shape), not along the bounding box.")); } -void InkscapePreferences::AddDotSizeSpinbutton(DialogPage& p, const std::string& prefs_path, double def_value) +void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring const &prefs_path, double def_value) { PrefSpinButton* sb = Gtk::manage( new PrefSpinButton); sb->init ( prefs_path, "dot-size", 0.0, 1000.0, 0.1, 10.0, def_value, false, false); @@ -306,7 +306,7 @@ void StyleFromSelectionToTool(gchar const *prefs_path, StyleSwatch *swatch) } } -void InkscapePreferences::AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path, const gchar* banner) +void InkscapePreferences::AddNewObjectsStyle(DialogPage &p, Glib::ustring const &prefs_path, const gchar *banner) { if (banner) p.add_group_header(banner); @@ -704,15 +704,16 @@ void InkscapePreferences::initPageImportExport() #if ENABLE_LCMS static void profileComboChanged( Gtk::ComboBoxText* combo ) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int rowNum = combo->get_active_row_number(); if ( rowNum < 1 ) { - prefs_set_string_attribute( "options.displayprofile", "uri", "" ); + prefs->setString("options.displayprofile", "uri", ""); } else { Glib::ustring active = combo->get_active_text(); Glib::ustring path = get_path_for_profile(active); if ( !path.empty() ) { - prefs_set_string_attribute( "options.displayprofile", "uri", path.c_str() ); + prefs->setString("options.displayprofile", "uri", path); } } } @@ -720,10 +721,11 @@ static void profileComboChanged( Gtk::ComboBoxText* combo ) static void proofComboChanged( Gtk::ComboBoxText* combo ) { Glib::ustring active = combo->get_active_text(); - Glib::ustring path = get_path_for_profile(active); + if ( !path.empty() ) { - prefs_set_string_attribute( "options.softproof", "uri", path.c_str() ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString("options.softproof", "uri", path); } } @@ -735,13 +737,15 @@ static void gamutColorChanged( Gtk::ColorButton* btn ) { gchar* tmp = g_strdup_printf("#%02x%02x%02x", (r >> 8), (g >> 8), (b >> 8) ); - prefs_set_string_attribute( "options.softproof", "gamutcolor", tmp ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString("options.softproof", "gamutcolor", tmp); g_free(tmp); } #endif // ENABLE_LCMS void InkscapePreferences::initPageCMS() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int const numIntents = 4; /* TRANSLATORS: see http://www.newsandtech.com/issues/2004/03-04/pt/03-04_rendering.htm */ Glib::ustring intentLabels[numIntents] = {_("Perceptual"), _("Relative Colorimetric"), _("Saturation"), _("Absolute Colorimetric")}; @@ -780,8 +784,8 @@ void InkscapePreferences::initPageCMS() _page_cms.add_line( false, "", _cms_gamutwarn, "", _("Highlights colors that are out of gamut for the target device."), false); - gchar const* colorStr = prefs_get_string_attribute("options.softproof", "gamutcolor"); - Gdk::Color tmpColor( (colorStr && colorStr[0]) ? colorStr : "#00ff00"); + Glib::ustring colorStr = prefs->getString("options.softproof", "gamutcolor"); + Gdk::Color tmpColor( colorStr.empty() ? "#00ff00" : colorStr); _cms_gamutcolor.set_color( tmpColor ); _page_cms.add_line( true, _("Out of gamut warning color:"), _cms_gamutcolor, "", _("Selects the color used for out of gamut warning."), false); @@ -814,7 +818,7 @@ void InkscapePreferences::initPageCMS() #if ENABLE_LCMS { std::vector<Glib::ustring> names = ::Inkscape::colorprofile_get_display_names(); - Glib::ustring current = prefs_get_string_attribute( "options.displayprofile", "uri" ); + Glib::ustring current = prefs->getString( "options.displayprofile", "uri" ); gint index = 0; _cms_display_profile.append_text(_("<none>")); @@ -832,8 +836,7 @@ void InkscapePreferences::initPageCMS() } names = ::Inkscape::colorprofile_get_softproof_names(); - const gchar * tmp = prefs_get_string_attribute( "options.softproof", "uri" ); - current = tmp ? tmp : ""; + current = prefs->getString("options.softproof", "uri"); index = 0; for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) { _cms_proof_profile.append_text( *it ); @@ -1026,9 +1029,10 @@ void InkscapePreferences::initPageBitmaps() _misc_bitmap_autoreload.init(_("Automatically reload bitmaps"), "options.bitmapautoreload", "value", true); _page_bitmaps.add_line( false, "", _misc_bitmap_autoreload, "", _("Automatically reload linked images when file is changed on disk")); - gchar const *choices = prefs_get_string_attribute("options.bitmapeditor", "choices"); - if ( choices && choices[0] ) { - gchar** splits = g_strsplit(choices, ",", 0); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring choices = prefs->getString("options.bitmapeditor", "choices"); + if (!choices.empty()) { + gchar** splits = g_strsplit(choices.data(), ",", 0); gint numIems = g_strv_length(splits); Glib::ustring labels[numIems]; @@ -1093,7 +1097,8 @@ bool InkscapePreferences::SetMaxDialogSize(const Gtk::TreeModel::iterator& iter) bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter) { Gtk::TreeModel::Row row = *iter; - int desired_page = prefs_get_int_attribute("dialogs.preferences", "page", 0); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int desired_page = prefs->getInt("dialogs.preferences", "page", 0); if (desired_page == row[_page_list_columns._col_id]) { if (desired_page >= PREFS_PAGE_TOOLS && desired_page <= PREFS_PAGE_TOOLS_DROPPER) @@ -1117,7 +1122,8 @@ void InkscapePreferences::on_pagelist_selection_changed() _page_frame.remove(); Gtk::TreeModel::Row row = *iter; _current_page = row[_page_list_columns._col_page]; - prefs_set_int_attribute("dialogs.preferences", "page", row[_page_list_columns._col_id]); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("dialogs.preferences", "page", row[_page_list_columns._col_id]); _page_title.set_markup("<span size='large'><b>" + row[_page_list_columns._col_name] + "</b></span>"); _page_frame.add(*_current_page); _current_page->show(); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index a6fc96a3f..30dd2bdaa 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -241,11 +241,11 @@ protected: bool SetMaxDialogSize(const Gtk::TreeModel::iterator& iter); bool PresentPage(const Gtk::TreeModel::iterator& iter); - static void AddSelcueCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); - static void AddGradientCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); - static void AddConvertGuidesCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); - static void AddDotSizeSpinbutton(DialogPage& p, const std::string& prefs_path, double def_value); - static void AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path, const gchar* banner = NULL); + static void AddSelcueCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddGradientCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddConvertGuidesCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddDotSizeSpinbutton(DialogPage& p, Glib::ustring const &prefs_path, double def_value); + static void AddNewObjectsStyle(DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL); void on_pagelist_selection_changed(); void initPageMouse(); diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 729d09511..de22c16d6 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -25,6 +25,7 @@ #include "gc-core.h" #include <dialogs/dialog-events.h> #include "io/sys.h" +#include "preferences.h" namespace Inkscape { @@ -306,8 +307,9 @@ void FileListViewText::on_cursor_changed() //get file url fileUrl = get_text(posArray[0], 1); //http url + //Inkscape::Preferences *prefs = Inkscape::Preferences::get(); //Glib::ustring fileUrl = "dav://"; //dav url - //fileUrl.append(prefs_get_string_attribute("options.ocalurl", "str")); + //fileUrl.append(prefs->getString("options.ocalurl", "str")); //fileUrl.append("/dav.php/"); //fileUrl.append(get_text(posArray[0], 3)); //author dir //fileUrl.append("/"); @@ -418,11 +420,12 @@ void FileImportFromOCALDialog::searchTagEntryChangedCallback() notFoundLabel->hide(); descriptionLabel->set_text(""); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring searchTag = searchTagEntry->get_text(); // create the ocal uri to get rss feed Glib::ustring uri = "http://"; - uri.append(prefs_get_string_attribute("options.ocalurl", "str")); + uri.append(prefs->getString("options.ocalurl", "str")); uri.append("/media/feed/rss/"); uri.append(searchTag); if (!Glib::get_charset()) //If we are not utf8 diff --git a/src/ui/dialog/whiteboard-connect.cpp b/src/ui/dialog/whiteboard-connect.cpp index ae291c03d..f91d4a607 100644 --- a/src/ui/dialog/whiteboard-connect.cpp +++ b/src/ui/dialog/whiteboard-connect.cpp @@ -19,7 +19,7 @@ #include "inkscape.h" #include "desktop.h" #include "message-stack.h" -#include "prefs-utils.h" +#include "preferences.h" #include "jabber_whiteboard/session-manager.h" @@ -82,10 +82,12 @@ WhiteboardConnectDialogImpl::_construct() this->_labels[2].set_mnemonic_widget(this->_password); this->_labels[3].set_mnemonic_widget(this->_port); - this->_server.set_text(prefs_get_string_attribute("whiteboard.server", "name")); - this->_port.set_text(prefs_get_string_attribute("whiteboard.server", "port")); - this->_username.set_text(prefs_get_string_attribute("whiteboard.server", "username")); - this->_usessl.set_active((prefs_get_int_attribute("whiteboard.server", "ssl", 0) == 1) ? true : false); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + this->_server.set_text(prefs->getString("whiteboard.server", "name")); + /// @todo Convert port to an integer preference? + this->_port.set_text(prefs->getString("whiteboard.server", "port")); + this->_username.set_text(prefs->getString("whiteboard.server", "username")); + this->_usessl.set_active(prefs->getBool("whiteboard.server", "ssl", false); this->_layout.attach(this->_labels[0], 0, 1, 0, 1); this->_layout.attach(this->_labels[1], 0, 1, 1, 2); @@ -195,6 +197,7 @@ WhiteboardConnectDialogImpl::_registerCallback() void WhiteboardConnectDialogImpl::_respCallback(int resp) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (resp == GTK_RESPONSE_OK) { Glib::ustring server, port, username, password; @@ -233,7 +236,7 @@ WhiteboardConnectDialogImpl::_respCallback(int resp) this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); // Save preferences - prefs_set_string_attribute(this->_prefs_path, "server", this->_server.get_text().c_str()); + prefs->setString(this->_prefs_path, "server", this->_server.get_text()); break; default: break; @@ -271,7 +274,7 @@ WhiteboardConnectDialogImpl::_respCallback(int resp) this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); // Save preferences - prefs_set_string_attribute(this->_prefs_path, "server", this->_server.get_text().c_str()); + prefs->setString(this->_prefs_path, "server", this->_server.get_text()); break; default: break; @@ -297,11 +300,11 @@ WhiteboardConnectDialogImpl::_useSSLClickedCallback() } } -} +} // namespace Dialog -} +} // namespace UI -} +} // namespace Inkscape /* Local Variables: diff --git a/src/ui/dialog/whiteboard-sharewithchat.cpp b/src/ui/dialog/whiteboard-sharewithchat.cpp index b2b913de0..4e9ea7abf 100644 --- a/src/ui/dialog/whiteboard-sharewithchat.cpp +++ b/src/ui/dialog/whiteboard-sharewithchat.cpp @@ -1,5 +1,6 @@ /** - * Whiteboard share with chatroom dialog + * @file + * @brief Whiteboard share with chatroom dialog * * Authors: * David Yip <yipdw@rose-hulman.edu> @@ -20,7 +21,7 @@ #include "inkscape.h" #include "desktop.h" -#include "prefs-utils.h" +#include "preferences.h" #include "jabber_whiteboard/typedefs.h" #include "jabber_whiteboard/session-manager.h" @@ -33,9 +34,7 @@ #include "util/ucompose.hpp" namespace Inkscape { - namespace UI { - namespace Dialog { WhiteboardShareWithChatroomDialog* @@ -60,7 +59,7 @@ WhiteboardShareWithChatroomDialogImpl::~WhiteboardShareWithChatroomDialogImpl() void WhiteboardShareWithChatroomDialogImpl::setSessionManager() { - this->_desktop = this->getDesktop(); + this->_desktop = this->getDesktop(); this->_sm = this->_desktop->whiteboard_session_manager(); } @@ -82,10 +81,10 @@ WhiteboardShareWithChatroomDialogImpl::_construct() this->_labels[2].set_mnemonic_widget(this->_roompass); this->_labels[3].set_mnemonic_widget(this->_handle); - - this->_roomname.set_text(prefs_get_string_attribute("whiteboard.room", "name")); - this->_confserver.set_text(prefs_get_string_attribute("whiteboard.room", "server")); - this->_handle.set_text(prefs_get_string_attribute("whiteboard.server", "username")); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + this->_roomname.set_text(prefs->getString("whiteboard.room", "name")); + this->_confserver.set_text(prefs->getString("whiteboard.room", "server")); + this->_handle.set_text(prefs->getString("whiteboard.server", "username")); // Pack table this->_layout.attach(this->_labels[0], 0, 1, 0, 1); @@ -147,8 +146,17 @@ WhiteboardShareWithChatroomDialogImpl::_respCallback(int resp) } } -} - -} - -} +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |
