diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2008-12-07 00:44:56 +0000 |
|---|---|---|
| committer | tweenk <tweenk@users.sourceforge.net> | 2008-12-07 00:44:56 +0000 |
| commit | 45335a6bcb990a2e8e481d6fd25679a795e8f928 (patch) | |
| tree | 7540392f16fe52b820013a0d78685576f8d89cd5 /src/preferences.h | |
| parent | Removed duplication of menu items. (diff) | |
| download | inkscape-45335a6bcb990a2e8e481d6fd25679a795e8f928.tar.gz inkscape-45335a6bcb990a2e8e481d6fd25679a795e8f928.zip | |
Change the way preferences are loaded to simplify unit testing
(bzr r6964)
Diffstat (limited to 'src/preferences.h')
| -rw-r--r-- | src/preferences.h | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/preferences.h b/src/preferences.h index e39adc228..2f2337b81 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -196,11 +196,25 @@ public: // utility methods /** - * @name Save preferences to the disk. + * @name Load stored preferences and save them to the disk. * @{ */ /** + * @brief Load the preferences from the default location. + * + * Loads the stored user preferences and enables saving them. If there's + * no preferences file in the expected location, it creates it. Any changes + * made to the preferences before loading will be overridden by the stored + * prefs. Not calling load() is sometimes useful, e.g. for testing. + * + * @param use_gui Whether to use dialogs to notify about errors when + * loading the preferences. Set to false in console mode. + * @param quiet Whether to output any messages about preference loading. + * If this is true, the use_gui parameter is ignored. + */ + void load(bool use_gui=true, bool quiet=false); + /** * @brief Save all preferences to the hard disk. * * For some backends, the preferences may be saved as they are modified. @@ -372,6 +386,7 @@ public: /** * @name Access and manipulate the Preferences object. + * @{ */ /** @@ -382,15 +397,6 @@ public: return _instance; } /** - * @brief Load the preferences. - * - * This method is automatically called from get(). It exists to supress - * possible compiler warnings over unused variables. - */ - static void load() { - if (!_instance) _instance = new Preferences(); - } - /** * @brief Unload all preferences and store them on the hard disk. * * This deletes the singleton object. Calling get() after this function is @@ -402,14 +408,6 @@ public: _instance = NULL; } } - - /** - * @brief Whether to use GUI error notifications - * - * Set this to false when running Inkscape in command-line mode. - * Preference-related warnings will be printed to the console. - */ - static bool use_gui; /*@}*/ protected: @@ -428,7 +426,6 @@ protected: private: Preferences(); ~Preferences(); - void _load(); void _loadDefaults(); void _getRawValue(Glib::ustring const &path, gchar const *&result); void _setRawValue(Glib::ustring const &path, gchar const *value); @@ -444,8 +441,11 @@ private: std::string _prefs_basename; ///< Basename of the prefs file std::string _prefs_dir; ///< Directory in which to look for the prefs file std::string _prefs_filename; ///< Full filename (with directory) of the prefs file - bool _writable; ///< Will the preferences be saved at exit? XML::Document *_prefs_doc; ///< XML document storing all the preferences + bool _use_gui; ///< Use GUI error notifications? + bool _quiet; ///< Display any messages about loading? + bool _loaded; ///< Was a load attempt made? + bool _writable; ///< Will the preferences be saved at exit? /// Wrapper class for XML node observers class PrefNodeObserver; |
