]> git.gag.com Git - debian/gnuradio/commitdiff
use gobject threading
authorjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 27 Sep 2008 08:11:13 +0000 (08:11 +0000)
committerjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 27 Sep 2008 08:11:13 +0000 (08:11 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9665 221aa14e-8319-0410-a670-987f0aec2ac5

grc/src/gui/ActionHandler.py

index ab4d6650203f623a3409ddeee73541b63f5e66d2..95825bd0acbaaeca4b76a3ec0b321574c15e1a41 100644 (file)
@@ -25,6 +25,7 @@ import Actions
 import pygtk
 pygtk.require('2.0')
 import gtk
+import gobject
 import Preferences
 from threading import Thread
 import Messages
@@ -35,6 +36,8 @@ from MainWindow import MainWindow
 from Dialogs import PreferencesDialog, AboutDialog, HotKeysDialog
 from FileDialogs import OpenFlowGraphFileDialog, SaveFlowGraphFileDialog, SaveImageFileDialog
 
+gobject.threads_init()
+
 class ActionHandler:
        """
        The action handler will setup all the major window components,
@@ -67,7 +70,6 @@ class ActionHandler:
                self.init_file_paths = file_paths
                self.handle_states(Actions.APPLICATION_INITIALIZE)
                #enter the mainloop
-               gtk.gdk.threads_init()
                gtk.main()
 
        def _handle_key_press(self, widget, event):
@@ -407,6 +409,7 @@ class ActionHandler:
 
 class ExecFlowGraphThread(Thread):
        """Execute the flow graph as a new process and wait on it to finish."""
+
        def __init__ (self, action_handler):
                """
                ExecFlowGraphThread constructor.
@@ -430,16 +433,19 @@ class ExecFlowGraphThread(Thread):
                        Messages.send_end_exec()
 
        def run(self):
-               """Wait on the flow graph."""
+               """
+               Wait on the executing process by reading from its stdout.
+               Use gobject.idle_add when calling functions that modify gtk objects.
+               """
                #handle completion
                r = "\n"
                while(r):
-                       gtk.gdk.threads_enter()
-                       Messages.send_verbose_exec(r)
-                       gtk.gdk.threads_leave()
+                       gobject.idle_add(Messages.send_verbose_exec, r)
                        r = os.read(self.p.stdout.fileno(), 1024)
-               gtk.gdk.threads_enter()
+               gobject.idle_add(self.done)
+
+       def done(self):
+               """Perform end of execution tasks."""
                Messages.send_end_exec()
                self.page.set_pid(None)
                self.update_exec_stop()
-               gtk.gdk.threads_leave()