Code

Use subdirectories with icon sizes.
[inkscape.git] / src / preferences.h
index 4e3d0732c00fb6b359ad26cc3f2d94f217d92bed..5e1ccf9d6f7a451f48fd3d97b328e618035cc1a3 100644 (file)
@@ -2,7 +2,7 @@
  * @brief  Singleton class to access the preferences file in a convenient way.
  */
 /* Authors:
- *   Krzysztof Kosiński <tweenk.pl@gmail.com>
+ *   Krzysztof Kosi_ski <tweenk.pl@gmail.com>
  *   Jon A. Cruz <jon@joncruz.org>
  *
  * Copyright (C) 2008,2009 Authors
@@ -28,6 +28,7 @@ namespace Inkscape {
 
 class ErrorReporter {
 public:
+    virtual ~ErrorReporter() {}
     virtual void handleError(Glib::ustring const& primary, Glib::ustring const& secondary ) const = 0;
 };
 
@@ -176,6 +177,11 @@ public:
          */
         inline Glib::ustring getString() const;
 
+        /**
+         * @brief Interpret the preference as an RGBA color value.
+         */
+        inline guint32 getColor(guint32 def) const;
+
         /**
          * @brief Interpret the preference as a CSS style.
          * @return A CSS style that has to be unrefed when no longer necessary. Never NULL.
@@ -328,6 +334,10 @@ public:
         return getEntry(pref_path).getString();
     }
 
+    guint32 getColor(Glib::ustring const &pref_path, guint32 def=0x000000ff) {
+        return getEntry(pref_path).getColor(def);
+    }
+
     /**
      * @brief Retrieve a CSS style
      * @param pref_path Path to the retrieved preference
@@ -382,6 +392,11 @@ public:
      */
     void setString(Glib::ustring const &pref_path, Glib::ustring const &value);
 
+    /**
+     * @brief Set an RGBA color value
+     */
+    void setColor(Glib::ustring const &pref_path, guint32 value);
+
     /**
      * @brief Set a CSS style
      */
@@ -419,6 +434,12 @@ public:
      * @{
      */
 
+
+    /**
+     * Copies values from old location to new.
+     */
+    static void migrate( std::string const& legacyDir, std::string const& prefdir );
+
     /**
      * @brief Access the singleton Preferences object.
      */
@@ -452,6 +473,7 @@ protected:
     int _extractInt(Entry const &v);
     double _extractDouble(Entry const &v);
     Glib::ustring _extractString(Entry const &v);
+    guint32 _extractColor(Entry const &v);
     SPCSSAttr *_extractStyle(Entry const &v);
     SPCSSAttr *_extractInheritedStyle(Entry const &v);
 
@@ -560,6 +582,15 @@ inline Glib::ustring Preferences::Entry::getString() const
     }
 }
 
+inline guint32 Preferences::Entry::getColor(guint32 def) const
+{
+    if (!this->isValid()) {
+        return def;
+    } else {
+        return Inkscape::Preferences::get()->_extractColor(*this);
+    }
+}
+
 inline SPCSSAttr *Preferences::Entry::getStyle() const
 {
     if (!this->isValid()) {