diff options
author | jblum | 2008-09-27 08:11:13 +0000 |
---|---|---|
committer | jblum | 2008-09-27 08:11:13 +0000 |
commit | ff9c2110d832a0d3b097eab9ca31562f91566404 (patch) | |
tree | c74050fde1b57a4240ba3c81860b8e3ade0137dd /grc | |
parent | ebcafa4339b1ab5c1e86dd7f2d7905db9eae8ab9 (diff) | |
download | gnuradio-ff9c2110d832a0d3b097eab9ca31562f91566404.tar.gz gnuradio-ff9c2110d832a0d3b097eab9ca31562f91566404.tar.bz2 gnuradio-ff9c2110d832a0d3b097eab9ca31562f91566404.zip |
use gobject threading
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9665 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'grc')
-rw-r--r-- | grc/src/gui/ActionHandler.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/grc/src/gui/ActionHandler.py b/grc/src/gui/ActionHandler.py index ab4d66502..95825bd0a 100644 --- a/grc/src/gui/ActionHandler.py +++ b/grc/src/gui/ActionHandler.py @@ -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() |