commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9665 - gnuradio/trunk/grc/src/gui


From: jblum
Subject: [Commit-gnuradio] r9665 - gnuradio/trunk/grc/src/gui
Date: Sat, 27 Sep 2008 02:11:14 -0600 (MDT)

Author: jblum
Date: 2008-09-27 02:11:13 -0600 (Sat, 27 Sep 2008)
New Revision: 9665

Modified:
   gnuradio/trunk/grc/src/gui/ActionHandler.py
Log:
use gobject threading

Modified: gnuradio/trunk/grc/src/gui/ActionHandler.py
===================================================================
--- gnuradio/trunk/grc/src/gui/ActionHandler.py 2008-09-26 03:02:45 UTC (rev 
9664)
+++ gnuradio/trunk/grc/src/gui/ActionHandler.py 2008-09-27 08:11:13 UTC (rev 
9665)
@@ -25,6 +25,7 @@
 import pygtk
 pygtk.require('2.0')
 import gtk
+import gobject
 import Preferences
 from threading import Thread
 import Messages
@@ -35,6 +36,8 @@
 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 @@
                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 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 @@
                        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()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]