Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

Inkscape::Preferences Class Reference

#include <preferences.h>

List of all members.

Detailed Description

Preference storage class.

This is a singleton that allows one to access the user preferences stored in the preferences.xml file. The preferences are stored in a file system-like hierarchy. They are generally typeless - it's up to the programmer to ensure that a given preference is always accessed as the correct type. The backend is not guaranteed to be tolerant to type mismatches.

Preferences are identified by paths similar to file system paths. Components of the path are separated by a slash (/). As an additional requirement, the path must start with a slash, and not contain a trailing slash. An example of a correct path would be "/options/some_group/some_option".

All preferences are loaded when the first singleton pointer is requested. To save the preferences, the method save() or the static function unload() can be used.

In future, this will be a virtual base from which specific backends derive (e.g. GConf, flat XML file...)

Definition at line 56 of file preferences.h.

Access and manipulate the Preferences object.

void setErrorHandler (ErrorReporter *handler)
static Preferencesget ()
 Access the singleton Preferences object.
static void unload (bool save=true)
 Unload all preferences.

Public Member Functions

bool getLastError (Glib::ustring &primary, Glib::ustring &secondary)
 Return details of the last encountered error, if any.
bool isWritable ()
 Check whether saving the preferences will have any effect.
void save ()
 Save all preferences to the hard disk.
Receive notifications about preference changes.
void addObserver (Observer &)
 Register a preference observer.
void removeObserver (Observer &)
 Remove an observer an prevent further notifications to it.
Iterate over directories and entries.
std::vector< Glib::ustring > getAllDirs (Glib::ustring const &path)
 Get all subdirectories of the specified directory.
std::vector< EntrygetAllEntries (Glib::ustring const &path)
 Get all entries from the specified directory.
Retrieve data from the preference storage.
bool getBool (Glib::ustring const &pref_path, bool def=false)
 Retrieve a Boolean value.
double getDouble (Glib::ustring const &pref_path, double def=0.0)
double getDoubleLimited (Glib::ustring const &pref_path, double def=0.0, double min=DBL_MIN, double max=DBL_MAX)
 Retrieve a limited floating point value.
Entry const getEntry (Glib::ustring const &pref_path)
 Retrieve a preference entry without specifying its type.
SPCSSAttr * getInheritedStyle (Glib::ustring const &pref_path)
 Retrieve an inherited CSS style.
int getInt (Glib::ustring const &pref_path, int def=0)
 Retrieve an integer.
int getIntLimited (Glib::ustring const &pref_path, int def=0, int min=INT_MIN, int max=INT_MAX)
 Retrieve a limited integer.
Glib::ustring getString (Glib::ustring const &pref_path)
 Retrieve an UTF-8 string.
SPCSSAttr * getStyle (Glib::ustring const &pref_path)
 Retrieve a CSS style.
Update preference values.
void mergeStyle (Glib::ustring const &pref_path, SPCSSAttr *style)
 Merge a CSS style with the current preference value.
void setBool (Glib::ustring const &pref_path, bool value)
 Set a Boolean value.
void setDouble (Glib::ustring const &pref_path, double value)
 Set a floating point value.
void setInt (Glib::ustring const &pref_path, int value)
 Set an integer value.
void setString (Glib::ustring const &pref_path, Glib::ustring const &value)
 Set an UTF-8 string value.
void setStyle (Glib::ustring const &pref_path, SPCSSAttr *style)
 Set a CSS style.

Protected Member Functions

bool _extractBool (Entry const &v)
double _extractDouble (Entry const &v)
SPCSSAttr * _extractInheritedStyle (Entry const &v)
int _extractInt (Entry const &v)
Glib::ustring _extractString (Entry const &v)
SPCSSAttr * _extractStyle (Entry const &v)

Private Types

typedef std::map< Observer
*, PrefNodeObserver * > 

Private Member Functions

XML::Node_findObserverNode (Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key, bool create)
 Find the XML node to observe.
XML::Node_getNode (Glib::ustring const &pref_path, bool create=false)
 Get the XML node corresponding to the given pref key.
void _getRawValue (Glib::ustring const &path, gchar const *&result)
void _keySplit (Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key)
void _load ()
 Load the user's customized preferences.
void _loadDefaults ()
 Load internal defaults.
void _reportError (Glib::ustring const &, Glib::ustring const &)
void _setRawValue (Glib::ustring const &path, gchar const *value)
Preferences operator= (Preferences const &)
 Preferences (Preferences const &)

Static Private Member Functions

static Entry const _create_pref_value (Glib::ustring const &, void const *ptr)
static void * _get_pref_observer_data (Observer &o)

Private Attributes

ErrorReporter * _errorHandler
 Pointer to object reporting errors.
bool _hasError
 Indication that some error has occurred;.
Glib::ustring _lastErrPrimary
 Last primary error message, if any.
Glib::ustring _lastErrSecondary
 Last secondary error message, if any.
_ObsMap _observer_map
 Map that keeps track of wrappers assigned to PrefObservers.
std::string _prefs_basename
 Basename of the prefs file.
std::string _prefs_dir
 Directory in which to look for the prefs file.
 XML document storing all the preferences.
std::string _prefs_filename
 Full filename (with directory) of the prefs file.
bool _writable
 Will the preferences be saved at exit?

Static Private Attributes

static Preferences_instance = NULL


class Entry
class PrefNodeObserver


class  Entry
 Data type representing a typeless value of a preference. More...
class  Observer
 Base class for preference observers. More...
class  PrefNodeObserver
 XML - prefs observer bridge. More...

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index