Index: pitivi/pitivi.py
===================================================================
--- pitivi/pitivi.py	(revision 1096)
+++ pitivi/pitivi.py	(working copy)
@@ -193,6 +193,7 @@
             return
         self.threads.stopAllThreads()
         self.playground.shutdown()
+        self.settings.storeSettings()
         instance.PiTiVi = None
         self.emit("shutdown")
 
Index: pitivi/settings.py
===================================================================
--- pitivi/settings.py	(revision 1096)
+++ pitivi/settings.py	(working copy)
@@ -28,6 +28,7 @@
 import gobject
 import gst
 import string
+from ConfigParser import SafeConfigParser
 
 from serializable import Serializable, to_object_from_data_type
 
@@ -35,15 +36,17 @@
 
 def get_bool_env(name):
     """
-    Checks the given env variable name and returns a boolean answer.
-    If it exists AND contains something different from '' or 0, then this
-    function will return True. Else it will return False.
+    Checks the given env variable name and returns a boolean value.  If the
+    variable exists and is 0 or '' then this function will return False.
+    Otherwise it will return True if the variable exists and None if it doesn't.
     """
     var = os.getenv(name)
     if not var:
-        return False
+        return None
     if var == '0':
         return False
+    if bool(var) == False:
+        return False
     return True
 
 class GlobalSettings:
@@ -56,12 +59,28 @@
     # * plugins should be able to add some settings
 
     def __init__(self, **kwargs):
+        self._config = SafeConfigParser()
+        
+        # this is necessary to preserve the case of option names
+        self._config.optionxform = lambda x: str(x)
+        
         self._setDefaults()
         self._readSettings()
 
     def _setDefaults(self):
-        self.advancedModeEnabled = True
-        self.fileSupportEnabled = False
+        # default settings can be put here and they will be overwritten if
+        # user settings exist, otherwise written to the configuration file
+        # at shutdown
+        self._config.add_section('pitivi-main')
+        
+        self._default_settings_dict = {
+                'advancedModeEnabled' : True,
+                'fileSupportEnabled': False,
+                }
+        
+        for key in self._default_settings_dict:
+            value = str(self._default_settings_dict[key])
+            self._config.set('pitivi-main', key, value)
 
     def _readSettings(self):
         self._readSettingsFromGlobalConfiguration()
@@ -75,34 +94,80 @@
 
     def _readSettingsFromConfigurationFile(self):
         # This reads the configuration from the user configuration file
-        pass
+        
+        pitivi_path = self.get_local_settings_path()
+        pitivi_conf_file_path = os.path.join(pitivi_path, "pitivi.conf")
+        
+        self._config.read(pitivi_conf_file_path)
+        
+        for key, value in self._config.items('pitivi-main'):
+            if key in self._default_settings_dict:
+                valuetype = type(self._default_settings_dict[key])
+                if valuetype == bool:
+                    value = self._config.getboolean('pitivi-main', key)
+                # similar methods exist for float and int if necessary
+            setattr(self, key, value)
 
     def _readSettingsFromEnvironmentVariables(self):
         # reads some settings from environment variable
-        #self.advancedModeEnabled =
-        #get_bool_env("PITIVI_ADVANCED_MODE")
-        self.fileSupportEnabled = get_bool_env("PITIVI_FILE_SUPPORT")
-        pass
+        advanced_mode = get_bool_env("PITIVI_ADVANCED_MODE")
+        if advanced_mode is not None:
+            self.advancedModeEnabled = advanced_mode
+            
+        file_support = get_bool_env("PITIVI_FILE_SUPPORT")
+        if file_support is not None:
+            self.fileSupportEnabled = file_support
 
-    def get_local_plugin_path(autocreate=True):
+    def _writeSettingsToConfigurationFile(self):
+        pitivi_path = self.get_local_settings_path()
+        pitivi_conf_file_path = os.path.join(pitivi_path, "pitivi.conf")
+        
+        # store current settings in our config file interface
+        for section in self._config.sections():
+            for key, value in self._config.items(section):
+                self._config.set(section, key, str(getattr(self, key)))
+        
+        try:
+            file = open(pitivi_conf_file_path, 'w')
+        except IOError, OSError:
+            return
+        self._config.write(file)
+        file.close()
+
+    def storeSettings(self):
+        self._writeSettingsToConfigurationFile()
+
+    def get_local_settings_path(self, autocreate=True):
         """
+        Compute the absolute path to local settings directory
+        
+        @param autocreate: create the path if missing
+        @return: the plugin repository path
+        """
+        
+        pitivi_path = os.path.expanduser("~/.pitivi")
+        if autocreate and not os.path.exists(pitivi_path):
+            os.mkdir(pitivi_path)
+        
+        return pitivi_path
+
+    def get_local_plugin_path(self, autocreate=True):
+        """
         Compute the absolute path to local plugin repository
 
         @param autocreate: create the path if missing
         @return: the plugin repository path
         """
 
-        pitivi_path = os.path.expanduser("~/.pitivi")
-        if not os.path.exists(pitivi_path):
-            os.mkdir(pitivi_path)
+        pitivi_path = self.get_local_settings_path()
 
-        repository_path = os.path.expanduser("~/.pitivi/plugins")
-        if not os.path.exists(repository_path):
+        repository_path = os.path.join(pitivi_path, "plugins")
+        if autocreate and not os.path.exists(repository_path):
             os.mkdir(repository_path)
 
         return repository_path
 
-    def get_plugin_settings_path(autocreate=True):
+    def get_plugin_settings_path(self, autocreate=True):
         """
         Compute the absolute path to local plugin settings' repository
 
@@ -110,12 +175,10 @@
         @return: the plugin settings path
         """
 
-        pitivi_path = os.path.expanduser("~/.pitivi")
-        if not os.path.exists(pitivi_path):
-            os.mkdir(pitivi_path)
+        pitivi_path = self.get_local_settings_path()
 
-        repository_path = os.path.expanduser("~/.pitivi/plugins-settings")
-        if not os.path.exists(repository_path):
+        repository_path = os.path.join(pitivi_path, "plugins-settings")
+        if autocreate and not os.path.exists(repository_path):
             os.mkdir(repository_path)
 
         return repository_path
