Index: branches/preferences/src/lib/util/preferences.cc
===================================================================
--- branches/preferences/src/lib/util/preferences.cc	(revision 6383)
+++ branches/preferences/src/lib/util/preferences.cc	(revision 6388)
@@ -28,4 +28,5 @@
    this->setClassID(CL_PREFERENCES, "Preferences");
    this->setName("Preferences");
+   this->fileName = NULL;
 }
 
@@ -41,4 +42,10 @@
 {
   Preferences::singletonRef = NULL;
+
+  if ( this->fileName )
+  {
+    delete this->fileName;
+    this->fileName = NULL;
+  }
 }
 
@@ -78,7 +85,8 @@
  * @param value value
  */
-void Preferences::setString(const char* section, const char* name, const char* value)
-{
-  setMultiType(section, name, MultiType(value));
+void Preferences::setString(const char* section, const char* name, const char* value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
 }
 
@@ -89,7 +97,8 @@
  * @param value value
  */
-void Preferences::setInt(const char* section, const char* name, int value)
-{
-  setMultiType(section, name, MultiType(value));
+void Preferences::setInt(const char* section, const char* name, int value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
 }
 
@@ -100,7 +109,8 @@
  * @param value value
  */
-void Preferences::setFloat(const char* section, const char* name, float value)
-{
-  setMultiType(section, name, MultiType(value));
+void Preferences::setFloat(const char* section, const char* name, float value, bool dontSetModified)
+{
+  MultiType t(value);
+  setMultiType(section, name, t, dontSetModified);
 }
 
@@ -147,5 +157,5 @@
  * @param value value
  */
-void Preferences::setMultiType(const char* section, const char* name, const MultiType& value)
+void Preferences::setMultiType(const char* section, const char* name, MultiType& value, bool dontSetModified)
 {
   std::list<prefSection>::iterator it = data.begin();
@@ -161,5 +171,9 @@
         if ( strcmp(it2->name, name) == 0 )
         {
+          if (!dontSetModified)
+            it2->modified = strcmp(value.getString(), it2->value.getString())!=0;
+
           it2->value = value;
+
           return;
         }
@@ -167,4 +181,5 @@
       prefItem item;
       item.value = value;
+      item.modified = !dontSetModified;
       item.name = new char[strlen(name)+1];
       strcpy( item.name, name );
@@ -176,4 +191,5 @@
   prefItem item;
   item.value = value;
+  item.modified = !dontSetModified;
   item.name = new char[strlen(name)+1];
   strcpy( item.name, name );
@@ -218,4 +234,51 @@
 }
 
+void Preferences::setUserIni(const char* fileName)
+{
+  if ( this->fileName != NULL )
+  {
+    delete this->fileName;
+  }
+
+  this->fileName = new char[strlen(fileName)+1];
+  strcpy(this->fileName, fileName);
+}
+
+bool Preferences::save()
+{
+  if ( this->fileName == NULL )
+  {
+    PRINTF(1)("You must call setUserIni before you can call save()\n");
+    return false;
+  }
+  IniParser iniParser(this->fileName);
+
+  if ( !iniParser.isOpen() )
+    return false;
+
+  std::list<prefSection>::iterator it = data.begin();
+  bool didChanges = false;
+  for ( ; it!=data.end(); it++)
+  {
+    std::list<prefItem>::iterator it2 = it->items.begin();
+
+    for ( ; it2!=it->items.end(); it2++)
+    {
+      if ( it2->modified )
+      {
+        iniParser.editVar(it2->name, it2->value.getString(), it->sectionName);
+        didChanges = true;
+      }
+    }
+  }
+
+  if ( didChanges )
+  {
+    iniParser.writeFile( this->fileName );
+  }
+
+  return true;
+}
+
 /**
  * prints out all section with its items and values
@@ -232,8 +295,8 @@
     for ( ; it2!=it->items.end(); it2++)
     {
-      PRINTF(0)("--> %s = '%s'\n", it2->name, it2->value.getString());
-    }
-  }
-}
-
-
+      PRINTF(0)("--> %s = '%s'%s\n", it2->name, it2->value.getString(), ((!it2->modified)?"":" <modified>"));
+    }
+  }
+}
+
+
Index: branches/preferences/src/lib/util/preferences.h
===================================================================
--- branches/preferences/src/lib/util/preferences.h	(revision 6383)
+++ branches/preferences/src/lib/util/preferences.h	(revision 6388)
@@ -9,11 +9,14 @@
 #include "base_object.h"
 #include "multi_type.h"
+#include "lib/parser/ini_parser/ini_parser.h"
 
 // FORWARD DECLARATION
 
+class IniFilePrefsReader;
 
 typedef struct {
   char* name;
   MultiType value;
+  bool modified;
 } prefItem;
 
@@ -35,8 +38,8 @@
    bool exists(const char* section, const char* name);
 
-   void setString(const char* section, const char* name, const char* value);
-   void setInt(const char* section, const char* name, int value);
-   void setFloat(const char* section, const char* name, float value);
-   void setMultiType(const char* section, const char* name, const MultiType& value);
+   void setString(const char* section, const char* name, const char* value, bool dontSetModified = false);
+   void setInt(const char* section, const char* name, int value, bool dontSetModified = false);
+   void setFloat(const char* section, const char* name, float value, bool dontSetModified = false);
+   void setMultiType(const char* section, const char* name, MultiType& value, bool dontSetModified = false);
 
    const char* getString(const char* section, const char* name, const char* defaultValue);
@@ -44,4 +47,8 @@
    float getFloat(const char* section, const char* name, float defaultValue);
    MultiType getMultiType(const char* section, const char* name, const MultiType& defaultValue);
+
+   void setUserIni(const char* fileName);
+
+   bool save();
 
 
@@ -54,4 +61,9 @@
 
    std::list<prefSection> data;
+
+   std::list<IniFilePrefsReader*> iniFilePrefsReaders;
+
+   char* fileName;
+
 };
 
