Index: orxonox/branches/bensch/Makefile.am
===================================================================
--- orxonox/branches/bensch/Makefile.am	(revision 1825)
+++ orxonox/branches/bensch/Makefile.am	(revision 1829)
@@ -2,6 +2,6 @@
 AM_LDFLAGS=`pkg-config --libs  gtk+-2.0`
 
-bin_PROGRAMS=orxonox
-orxonox_SOURCES=orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
+bin_PROGRAMS=orxonox_gui
+orxonox_gui_SOURCES=orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
         aclocal.m4
 
Index: orxonox/branches/bensch/Makefile.in
===================================================================
--- orxonox/branches/bensch/Makefile.in	(revision 1825)
+++ orxonox/branches/bensch/Makefile.in	(revision 1829)
@@ -15,5 +15,5 @@
 @SET_MAKE@
 
-SOURCES = $(orxonox_SOURCES)
+SOURCES = $(orxonox_gui_SOURCES)
 
 srcdir = @srcdir@
@@ -38,5 +38,5 @@
 POST_UNINSTALL = :
 host_triplet = @host@
-bin_PROGRAMS = orxonox$(EXEEXT)
+bin_PROGRAMS = orxonox_gui$(EXEEXT)
 DIST_COMMON = README $(am__configure_deps) $(orxonox_TEXINFOS) \
 	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
@@ -59,9 +59,9 @@
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_orxonox_OBJECTS = orxonox_gui.$(OBJEXT) orxonox_gui_video.$(OBJEXT) \
-	orxonox_gui_audio.$(OBJEXT) orxonox_gui_exec.$(OBJEXT) \
-	orxonox_gui_file.$(OBJEXT)
-orxonox_OBJECTS = $(am_orxonox_OBJECTS)
-orxonox_LDADD = $(LDADD)
+am_orxonox_gui_OBJECTS = orxonox_gui.$(OBJEXT) \
+	orxonox_gui_video.$(OBJEXT) orxonox_gui_audio.$(OBJEXT) \
+	orxonox_gui_exec.$(OBJEXT) orxonox_gui_file.$(OBJEXT)
+orxonox_gui_OBJECTS = $(am_orxonox_gui_OBJECTS)
+orxonox_gui_LDADD = $(LDADD)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -76,6 +76,6 @@
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(orxonox_SOURCES)
-DIST_SOURCES = $(orxonox_SOURCES)
+SOURCES = $(orxonox_gui_SOURCES)
+DIST_SOURCES = $(orxonox_gui_SOURCES)
 INFO_DEPS = $(srcdir)/orxonox.info
 am__TEXINFO_TEX_DIR = $(srcdir)
@@ -187,5 +187,5 @@
 AM_CFLAGS = `pkg-config --cflags gtk+-2.0`
 AM_LDFLAGS = `pkg-config --libs  gtk+-2.0`
-orxonox_SOURCES = orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
+orxonox_gui_SOURCES = orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
         aclocal.m4
 
@@ -287,7 +287,7 @@
 clean-binPROGRAMS:
 	-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
-orxonox$(EXEEXT): $(orxonox_OBJECTS) $(orxonox_DEPENDENCIES) 
-	@rm -f orxonox$(EXEEXT)
-	$(LINK) $(orxonox_LDFLAGS) $(orxonox_OBJECTS) $(orxonox_LDADD) $(LIBS)
+orxonox_gui$(EXEEXT): $(orxonox_gui_OBJECTS) $(orxonox_gui_DEPENDENCIES) 
+	@rm -f orxonox_gui$(EXEEXT)
+	$(LINK) $(orxonox_gui_LDFLAGS) $(orxonox_gui_OBJECTS) $(orxonox_gui_LDADD) $(LIBS)
 
 mostlyclean-compile:
Index: orxonox/branches/bensch/orxonox_gui.c
===================================================================
--- orxonox/branches/bensch/orxonox_gui.c	(revision 1825)
+++ orxonox/branches/bensch/orxonox_gui.c	(revision 1829)
@@ -3,11 +3,4 @@
 #include "orxonox_gui_audio.h"
 int verbose = 1;
-
-
-gint delete_event ( GtkWidget *widget, GdkEvent *event, gpointer data )
-{
-  return FALSE;
-}
-
 
 int main( int argc, char *argv[] )
@@ -18,4 +11,5 @@
     GtkWidget *hbox_view_exec;
     struct settings *orxonox_settings;
+
     int option_count = 7; /* important: look that this is greater than options in 'struct settings' */
 
@@ -25,4 +19,5 @@
 
     orxonox_gui_file_default (orxonox_settings);
+    orxonox_gui_file_load ("~/.orxonox.conf", orxonox_settings);
 
 
@@ -32,5 +27,5 @@
     gtk_window_set_title ( GTK_WINDOW (window), "orxonox");
     g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
-    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
+    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (orxonox_gui_quit), orxonox_settings);
     gtk_container_set_border_width (GTK_CONTAINER (window), 5);
     
Index: orxonox/branches/bensch/orxonox_gui.h
===================================================================
--- orxonox/branches/bensch/orxonox_gui.h	(revision 1825)
+++ orxonox/branches/bensch/orxonox_gui.h	(revision 1829)
@@ -8,6 +8,4 @@
 #include <gtk/gtk.h>
 #include "orxonox_gui_exec.h"
-
-gint delete_event ( GtkWidget *widget, GdkEvent *event, gpointer data );
 
 struct settings
Index: orxonox/branches/bensch/orxonox_gui_exec.c
===================================================================
--- orxonox/branches/bensch/orxonox_gui_exec.c	(revision 1825)
+++ orxonox/branches/bensch/orxonox_gui_exec.c	(revision 1829)
@@ -2,4 +2,13 @@
 GtkWidget *exec_flags_label;
 struct settings *exec_orxonox_settings;
+
+gint orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+  if (exec_orxonox_settings->exec_save_settings)
+    orxonox_gui_file_save("~/.orxonox.conf", exec_orxonox_settings);
+  gtk_main_quit();
+  return FALSE;
+}
+
 
 void exec_check_button_change(GtkWidget *widget, int* data)
@@ -83,5 +92,5 @@
 	
 	quit_button = gtk_button_new_with_label ("quit");
-	g_signal_connect(GTK_BUTTON(quit_button), "clicked", G_CALLBACK(gtk_main_quit), NULL);
+	g_signal_connect(GTK_BUTTON(quit_button), "clicked", G_CALLBACK(orxonox_gui_quit), NULL);
 	gtk_box_pack_start(GTK_BOX (orxonox_gui_exec_vbox), quit_button, FALSE, FALSE, 5);
 
Index: orxonox/branches/bensch/orxonox_gui_exec.h
===================================================================
--- orxonox/branches/bensch/orxonox_gui_exec.h	(revision 1825)
+++ orxonox/branches/bensch/orxonox_gui_exec.h	(revision 1829)
@@ -2,4 +2,6 @@
 #define _ORXONOX_GUI_EXEC_H
 #include "orxonox_gui.h"
+
+gint orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data);
 
 void exec_check_button_change(GtkWidget *widget, int* data);
Index: orxonox/branches/bensch/orxonox_gui_file.c
===================================================================
--- orxonox/branches/bensch/orxonox_gui_file.c	(revision 1825)
+++ orxonox/branches/bensch/orxonox_gui_file.c	(revision 1829)
@@ -1,4 +1,2 @@
-#include <stdio.h>
-#include <stdlib.h>
 #include <sys/stat.h>
 #include "orxonox_gui_file.h"
@@ -22,2 +20,104 @@
   return;
 }
+
+void orxonox_gui_file_save (char *config_file, struct settings *orxonox_settings)
+{
+  FILE *IOFILE;
+  char local_config_file[1000];
+
+  sprintf(local_config_file,"%s", config_file);
+  if (!strncmp (local_config_file,"~/", 2))
+  {
+    char buffer[100];
+    char *homedir = getenv("HOME");
+    sprintf(buffer, local_config_file);
+    sprintf (local_config_file,"%s/%s", homedir,buffer+2);
+  }
+
+  IOFILE = fopen( local_config_file, "w");
+  if (verbose >= 1)
+    printf ("Saving settings to %s\n", local_config_file);
+  
+  fprintf (IOFILE, "%s\n", "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
+  fprintf (IOFILE, "orxonox_settings->video_fullscreen = %i\n", orxonox_settings->video_fullscreen);
+  fprintf (IOFILE, "orxonox_settings->video_wireframe = %i\n", orxonox_settings->video_wireframe);
+
+  fprintf (IOFILE, "orxonox_settings->audio_enable_sound = %i\n", orxonox_settings->audio_enable_sound);
+  fprintf (IOFILE, "orxonox_settings->audio_music_volume = %i\n", orxonox_settings->audio_music_volume);
+  fprintf (IOFILE, "orxonox_settings->audio_effects_volume = %i\n", orxonox_settings->audio_effects_volume);
+
+  fprintf (IOFILE, "orxonox_settings->exec_save_settings = %i\n", orxonox_settings->exec_save_settings);
+  fprintf (IOFILE, "orxonox_settings->exec_show_menu = %i\n", orxonox_settings->exec_show_menu);
+
+  fprintf (IOFILE, "orxonox_settings->verbose = %i\n", verbose);
+  
+  fclose( IOFILE );
+  return;
+}
+
+void orxonox_gui_file_load (char *config_file, struct settings *orxonox_settings)
+{
+  FILE *IOFILE;
+  char variable[100];
+  char equals[5];
+  char value[100];
+  char buffer[100];
+  char local_config_file[1000];
+  
+  sprintf(local_config_file,"%s", config_file);
+  if (!strncmp (config_file, "~/", 2))
+    {
+      char *homedir = getenv("HOME");
+      sprintf(buffer, local_config_file);
+      sprintf (local_config_file,"%s/%s", homedir, buffer+2);
+    }
+  
+
+  IOFILE = fopen(local_config_file, "r");
+  if (verbose >= 1)
+    printf ("Loading settings from '%s'\n", local_config_file);
+  
+  fscanf (IOFILE, "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
+  while (fscanf (IOFILE,"%s %s %s", variable, equals, value) != EOF)
+    {
+      if ( !strcmp (variable, "orxonox_settings->video_fullscreen"))
+	{
+	  orxonox_settings->video_fullscreen = atoi (value);
+	}
+      else if ( !strcmp (variable, "orxonox_settings->video_wireframe"))
+	{
+	  orxonox_settings->video_wireframe = atoi (value);
+	}
+
+      else if ( !strcmp (variable, "orxonox_settings->audio_enable_sound"))
+	{
+	  orxonox_settings->audio_enable_sound = atoi (value);
+	}
+      else if ( !strcmp (variable, "orxonox_settings->audio_music_volume"))
+	{
+	  orxonox_settings->audio_music_volume = atoi (value);
+	}
+      else if ( !strcmp (variable, "orxonox_settings->audio_effects_volume"))
+	{
+	  orxonox_settings->audio_effects_volume = atoi (value);
+	}
+
+      else if ( !strcmp (variable, "orxonox_settings->exec_save_settings"))
+	{
+	  orxonox_settings->exec_save_settings = atoi (value);
+	}
+      else if ( !strcmp (variable, "orxonox_settings->exec_show_menu"))
+	{
+	  orxonox_settings->exec_show_menu = atoi (value);
+	}
+
+      else if ( !strcmp (variable, "orxonox_settings->verbose"))
+	{
+	  verbose = atoi (value);
+	}
+
+    }
+  fclose( IOFILE );      
+  return;
+}
+
Index: orxonox/branches/bensch/orxonox_gui_file.h
===================================================================
--- orxonox/branches/bensch/orxonox_gui_file.h	(revision 1825)
+++ orxonox/branches/bensch/orxonox_gui_file.h	(revision 1829)
@@ -4,6 +4,6 @@
 #include "orxonox_gui.h"
 
-struct settings orxonox_gui_file_save (char *filename);
-struct settings orxonox_gui_file_load (char *filename);
+void orxonox_gui_file_save (char *config_file, struct settings *orxonox_settings);
+void orxonox_gui_file_load (char *config_file, struct settings *orxonox_settings);
 void orxonox_gui_file_default (struct settings *orxonox_settings);
 
