diff --git a/src/preferences.cpp b/src/preferences.cpp
index e999182c7e2114944f5b08734f5740235ce9b823..ea3c015efe380acd69fef666c5e1fdc3de27816b 100644 (file)
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
_prefs_basename(PREFERENCES_FILE_NAME),
_prefs_dir(""),
_prefs_filename(""),
- _writable(false),
- _prefs_doc(NULL)
+ _prefs_doc(NULL),
+ _use_gui(true),
+ _quiet(false),
+ _loaded(false),
+ _writable(false)
{
// profile_path essentailly returns the argument prefixed by the profile directory.
gchar *path = profile_path(NULL);
_prefs_filename = path;
g_free(path);
- _load();
+ _loadDefaults();
}
Preferences::~Preferences()
* Tries to load the user's preferences.xml file. If there is none, creates it.
* Displays dialog boxes on any errors.
*/
-void Preferences::_load()
-{
- _loadDefaults();
-
+void Preferences::load(bool use_gui, bool quiet)
+{
Glib::ustring const not_saved = _("Inkscape will run with default settings, "
"and new settings will not be saved. ");
+ _use_gui = use_gui;
+ _quiet = quiet;
+ _loaded = true;
// NOTE: After we upgrade to Glib 2.16, use Glib::ustring::compose
if (!node) return;
// set additional data
- _ObserverData *d = new _ObserverData;
- d->_node = node;
- d->_is_attr = !attr_key.empty();
- o._data = static_cast<void*>(d);
+ _ObserverData *priv_data = new _ObserverData;
+ priv_data->_node = node;
+ priv_data->_is_attr = !attr_key.empty();
+ o._data = static_cast<void*>(priv_data);
_observer_map[&o] = new PrefNodeObserver(o, attr_key);
// if we watch a single pref, we want to receive notifications only for a single node
- if (d->_is_attr) {
+ if (priv_data->_is_attr) {
node->addObserver( *(_observer_map[&o]) );
} else {
node->addSubtreeObserver( *(_observer_map[&o]) );
// prevent removing an observer which was not added
if ( _observer_map.find(&o) == _observer_map.end() ) return;
Inkscape::XML::Node *node = static_cast<_ObserverData*>(o._data)->_node;
- delete static_cast<_ObserverData*>(o._data);
+ _ObserverData *priv_data = static_cast<_ObserverData*>(o._data);
o._data = NULL;
- node->removeSubtreeObserver( *(_observer_map[&o]) );
+ if (priv_data->_is_attr)
+ node->removeObserver( *(_observer_map[&o]) );
+ else
+ node->removeSubtreeObserver( *(_observer_map[&o]) );
+
+ delete priv_data;
delete _observer_map[&o];
_observer_map.erase(&o);
}
@@ -480,7 +489,8 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c
{
// verify path
g_assert( pref_key.at(0) == '/' );
- g_assert( pref_key.find('.') == Glib::ustring::npos );
+ // No longer necessary, can cause problems with input devices which have a dot in the name
+ // g_assert( pref_key.find('.') == Glib::ustring::npos );
Inkscape::XML::Node *node = _prefs_doc->root(), *child = NULL;
gchar **splits = g_strsplit(pref_key.data(), "/", 0);
@@ -610,7 +620,8 @@ void Preferences::_keySplit(Glib::ustring const &pref_path, Glib::ustring &node_
void Preferences::_errorDialog(Glib::ustring const &msg, Glib::ustring const &secondary)
{
- if (Preferences::use_gui) {
+ if (_quiet) return;
+ if (_use_gui) {
Gtk::MessageDialog err(
msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
err.set_secondary_text(secondary);
@@ -626,7 +637,6 @@ Preferences::Entry const Preferences::_create_pref_value(Glib::ustring const &pa
return Entry(path, ptr);
}
-bool Preferences::use_gui = true;
Preferences *Preferences::_instance = NULL;