changeset 31:d930e06af9ae

2002-10-03 Brian Masney <masneyb@gftp.org> * src/gtk/gftp-gtk.c - call g_thread_init (NULL) * src/gtk/delete_dialog.c, src/gtk/misc-gtk.c, src/gtk/transfer.c - call gdk_threads_enter() and gdk_threads_leave()
author masneyb
date Thu, 03 Oct 2002 12:05:54 +0000
parents dfd68d1d3d13
children 741f7aefa9aa
files src/gtk/delete_dialog.c src/gtk/gftp-gtk.c src/gtk/misc-gtk.c src/gtk/transfer.c
diffstat 4 files changed, 49 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtk/delete_dialog.c	Sat Sep 28 17:32:23 2002 +0000
+++ b/src/gtk/delete_dialog.c	Thu Oct 03 12:05:54 2002 +0000
@@ -81,7 +81,11 @@
 
       timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
       while (transfer->fromreq->stopable)
-        g_main_iteration (TRUE);
+        {
+          gdk_threads_leave ();
+          g_main_iteration (TRUE);
+          gdk_threads_enter ();
+        }
 
       gtk_widget_set_sensitive (stop_btn, 0);
       gtk_timeout_remove (timeout_num);
@@ -146,7 +150,11 @@
       pthread_create (&wdata->tid, NULL, do_delete_thread, transfer);
 
       while (transfer->fromreq->stopable)
-        g_main_iteration (TRUE);
+        {
+          gdk_threads_leave ();
+          g_main_iteration (TRUE);
+          gdk_threads_enter ();
+        }
 
       gtk_widget_set_sensitive (stop_btn, 0);
       pthread_join (wdata->tid, &ret);
--- a/src/gtk/gftp-gtk.c	Sat Sep 28 17:32:23 2002 +0000
+++ b/src/gtk/gftp-gtk.c	Thu Oct 03 12:05:54 2002 +0000
@@ -86,8 +86,9 @@
 #endif
   textdomain ("gftp");
 #endif
+
+  g_thread_init (NULL);
   gtk_set_locale ();
-
   gtk_init (&argc, &argv);
   signal (SIGCHLD, sig_child);
   signal (SIGPIPE, SIG_IGN);
@@ -138,7 +139,9 @@
   gftp_connect (window1.request);
   ftp_list_files (&window1, 0);
 
+  gdk_threads_enter ();
   gtk_main ();
+  gdk_threads_leave ();
   return (0);
 }
 
--- a/src/gtk/misc-gtk.c	Sat Sep 28 17:32:23 2002 +0000
+++ b/src/gtk/misc-gtk.c	Thu Oct 03 12:05:54 2002 +0000
@@ -34,7 +34,15 @@
 void
 fix_display (void)
 {
-  while (g_main_iteration (FALSE));
+  int ret;
+
+  ret = 1;
+  while (ret)
+    {
+      gdk_threads_leave ();
+      ret = g_main_iteration (FALSE);
+      gdk_threads_enter ();
+    }
 }
 
 
@@ -1124,7 +1132,11 @@
       pthread_create (&wdata->tid, NULL, func, wdata);
 
       while (wdata->request->stopable)
-        g_main_iteration (TRUE);
+        {
+          gdk_threads_leave ();
+          g_main_iteration (TRUE);
+          gdk_threads_enter ();
+        }
 
       pthread_join (wdata->tid, &ret);
       gtk_widget_set_sensitive (stop_btn, 0);
--- a/src/gtk/transfer.c	Sat Sep 28 17:32:23 2002 +0000
+++ b/src/gtk/transfer.c	Thu Oct 03 12:05:54 2002 +0000
@@ -86,7 +86,11 @@
           handler = setup_wakeup_main_thread (wdata->request);
           pthread_create (&wdata->tid, NULL, getdir_thread, wdata->request);
           while (wdata->request->stopable)
-            g_main_iteration (TRUE);
+            {
+              gdk_threads_leave ();
+              g_main_iteration (TRUE);
+              gdk_threads_enter ();
+            }
           teardown_wakeup_main_thread (wdata->request, handler);
 
           pthread_join (wdata->tid, &success);
@@ -253,8 +257,13 @@
                           0, NULL, gftp_dialog_button_connect, 
                           try_connect_again, request, 
                           dont_connect_again, request);
+
           while (request->stopable)
-            g_main_iteration (TRUE);
+            {
+              gdk_threads_leave ();
+              g_main_iteration (TRUE);
+              gdk_threads_enter ();
+            }
 
           if (GFTP_GET_PASSWORD (request) == NULL || 
               *GFTP_GET_PASSWORD (request) == '\0')
@@ -274,7 +283,11 @@
 
       handler = setup_wakeup_main_thread (wdata->request);
       while (request->stopable)
-        g_main_iteration (TRUE); 
+        {
+          gdk_threads_leave ();
+          g_main_iteration (TRUE);
+          gdk_threads_enter ();
+        }
       pthread_join (wdata->tid, &ret);
       teardown_wakeup_main_thread (wdata->request, handler);
 
@@ -436,7 +449,11 @@
           timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
 
           while (transfer->fromreq->stopable)
-            g_main_iteration (TRUE);
+            {
+              gdk_threads_leave ();
+              g_main_iteration (TRUE);
+              gdk_threads_enter ();
+            }
 
           gtk_timeout_remove (timeout_num);
           transfer->numfiles = transfer->numdirs = -1;