Index: orxonox/branches/updater/src/gui/Makefile.am
===================================================================
--- orxonox/branches/updater/src/gui/Makefile.am	(revision 3270)
+++ orxonox/branches/updater/src/gui/Makefile.am	(revision 3271)
@@ -1,5 +1,5 @@
-AM_CXXFLAGS=$(GTK2_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
-#AM_LDFLAGS=$(GTK2_LIBS)
-LIBS=$(GTK2_LIBS) $(CURL_LIBS)
+AM_CXXFLAGS=$(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
+#AM_LDFLAGS=$(GTK2_LIBS)   $(GTHREAD_LIBS)
+LIBS=$(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
 
 bin_PROGRAMS=gui
Index: orxonox/branches/updater/src/gui/Makefile.in
===================================================================
--- orxonox/branches/updater/src/gui/Makefile.in	(revision 3270)
+++ orxonox/branches/updater/src/gui/Makefile.in	(revision 3271)
@@ -113,8 +113,12 @@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
+GTHREAD_LIBS = @GTHREAD_LIBS@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
 HAVE_CURL_FALSE = @HAVE_CURL_FALSE@
 HAVE_CURL_TRUE = @HAVE_CURL_TRUE@
+HAVE_GTHREAD_FALSE = @HAVE_GTHREAD_FALSE@
+HAVE_GTHREAD_TRUE = @HAVE_GTHREAD_TRUE@
 HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@
 HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@
@@ -125,6 +129,6 @@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
-#AM_LDFLAGS=$(GTK2_LIBS)
-LIBS = $(GTK2_LIBS) $(CURL_LIBS)
+#AM_LDFLAGS=$(GTK2_LIBS)   $(GTHREAD_LIBS)
+LIBS = $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
@@ -184,5 +188,5 @@
 target_os = @target_os@
 target_vendor = @target_vendor@
-AM_CXXFLAGS = $(GTK2_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
+AM_CXXFLAGS = $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
 gui_SOURCES = orxonox_gui.cc \
 	    orxonox_gui_gtk.cc \
Index: orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
===================================================================
--- orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc	(revision 3270)
+++ orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc	(revision 3271)
@@ -47,4 +47,9 @@
 bool initGTK(int argc, char *argv[])
 {
+#ifdef HAVE_GTHREAD
+  PRINTF(3)("Initializing the ThreadSystem of the GUI\n");
+  g_thread_init(NULL);
+  gdk_threads_init();
+#endif /* HAVE_GTHREAD */
   gtk_init (&argc, &argv);
   gtk_rc_parse( "rc" );
@@ -56,6 +61,7 @@
 bool mainloopGTK(void)
 {
-  PRINTF(1)("test\n");
+  gdk_threads_enter();
   gtk_main();
+  gdk_threads_leave();
 }
 #endif /* HAVE_GTK2 */
@@ -1203,9 +1209,6 @@
     this->progress = this->totalSize;
 
-
 #ifdef HAVE_GTK2
   gtk_progress_set_value(GTK_PROGRESS(widget), this->progress*100.0/this->totalSize);
-  while (gtk_events_pending()) 
-    gtk_main_iteration_do(TRUE);
 #endif /* HAVE_GTK2 */
   PRINTF(3)("Progress: %f\n", progress*100.0/totalSize);
Index: orxonox/branches/updater/src/gui/orxonox_gui_update.cc
===================================================================
--- orxonox/branches/updater/src/gui/orxonox_gui_update.cc	(revision 3270)
+++ orxonox/branches/updater/src/gui/orxonox_gui_update.cc	(revision 3271)
@@ -90,6 +90,6 @@
 #ifdef HAVE_GTK2 
   updateDataWindowButton->connectSignal("button_press_event", updateDataWindow, Window::windowOpen);
-  updateDataWindow->connectSignal("destroy", updateDataWindow, cancelDownload);
-  updateDataWindow->connectSignal("delete_event", updateDataWindow, cancelDownload);
+  updateDataWindow->connectSignal("destroy", updateDataWindow, Window::windowClose);
+  updateDataWindow->connectSignal("delete_event", updateDataWindow, Window::windowClose);
 #endif /* HAVE_GTK2 */
 
@@ -149,10 +149,19 @@
   FileInfo* info = new FileInfo;
 
-  info->fileName = "03%20orxonox%203'.mp3";
+  info->fileName = "02%20orxonox%203.mp3";
   info->webRoot  = "http://www.orxonox.ethz.ch/files/";
   info->localRoot = "./";
   info->Bar = (ProgressBar*)bar;
   PRINTF(3)("Preparing to download file %s.\n", info->fileName);
-  download(info);
+  download (info);
+  /*
+  if (downloadThreadID == NULL)
+    {
+      if ( (downloadThreadID =g_thread_create(&downloadThread, info, TRUE, NULL)) == 0 )
+	PRINTF(1)("can't create the thread");
+    }
+  else 
+  PRINTF(1)("thread already in use\n");
+  */
 }
 
@@ -188,7 +197,9 @@
   Bar->setTotalSize(totalSize);
   return 0;
+
 }
 
 CURL* OrxonoxGuiUpdate::curlHandle = NULL;
+GThread* OrxonoxGuiUpdate::downloadThreadID = NULL;
 
 void* OrxonoxGuiUpdate::download (void* fileInfo)
@@ -209,6 +220,7 @@
   if(curlHandle)
     {
+      
       outfile = fopen(fileOnDisk, "w");
-      
+
       curl_easy_setopt(curlHandle, CURLOPT_URL, fileOnNet);
       curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, outfile);
@@ -218,12 +230,37 @@
       curl_easy_setopt(curlHandle, CURLOPT_PROGRESSFUNCTION, curlProgressFunc);
       curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->Bar);
+
+      if (!downloadThreadID)
+	{
+	  //! \todo check if threads really were created.
+	  downloadThreadID = g_thread_create(&downloadThread, info, TRUE, NULL);
+
+	  g_thread_create(&downloadThreadFinished, outfile, TRUE, NULL);
+	}
+      else 
+	PRINTF(1)("thread already in use\n");
+      //      res = curl_easy_perform(curlHandle);
       
-      res = curl_easy_perform(curlHandle);
-      
-      fclose(outfile);
-      if (curlHandle)
-	curl_easy_cleanup(curlHandle);
+      //      fclose(outfile);
     }
+  //  downloadThreadID = NULL;
   return NULL;
+}
+void* OrxonoxGuiUpdate::downloadThread(void* fileInfo)
+{
+  //  gdk_threads_enter();
+  curl_easy_perform(curlHandle);
+  if (curlHandle)
+    curl_easy_cleanup(curlHandle);
+  gdk_threads_leave();
+  downloadThreadID = NULL;
+  //  g_thread_exit (NULL);
+}
+
+void* OrxonoxGuiUpdate::downloadThreadFinished(void* outfile)
+{
+  g_thread_join(downloadThreadID);
+  PRINTF(3)("Closing the downloaded file.\n");
+  fclose((FILE*)outfile);
 }
 
Index: orxonox/branches/updater/src/gui/orxonox_gui_update.h
===================================================================
--- orxonox/branches/updater/src/gui/orxonox_gui_update.h	(revision 3270)
+++ orxonox/branches/updater/src/gui/orxonox_gui_update.h	(revision 3271)
@@ -59,8 +59,13 @@
 
   static CURL* curlHandle;
-  static void* download (void* fileInfo);
 #ifdef HAVE_GTK2 
   static gint cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar);
 #endif /* HAVE_GTK2 */  
+  static GThread* downloadThreadID;
+  static void* download (void* fileInfo);
+  static void* downloadThread (void* fileInfo);
+  static void* downloadThreadFinished(void* outfile);
+
+  
 #endif /* HAVE_CURL */
 
