diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-12-07 09:02:51 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-12-07 09:02:51 +0000 |
commit | 15d5a585ed4bb169211d9364a012d520808f07d9 (patch) | |
tree | cdcde5554d5c23595d18b1675a6aa92b008cf6d8 /gtk-recordmydesktop/src/rmdTrayIcon.py | |
parent | d9722affc6b453c442bbb6c52f4fae073de8232d (diff) |
rmdTrayIcon.py: added monitoring of externally caused state-changes
(global shortcuts)
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@466 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'gtk-recordmydesktop/src/rmdTrayIcon.py')
-rw-r--r-- | gtk-recordmydesktop/src/rmdTrayIcon.py | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/gtk-recordmydesktop/src/rmdTrayIcon.py b/gtk-recordmydesktop/src/rmdTrayIcon.py index b97331e..8a5f41c 100644 --- a/gtk-recordmydesktop/src/rmdTrayIcon.py +++ b/gtk-recordmydesktop/src/rmdTrayIcon.py @@ -30,6 +30,8 @@ pygtk.require('2.0') import gtk,gobject import locale, gettext import rmdConfig +import re + _ = gettext.gettext gettext.textdomain('gtk-recordMyDesktop') gettext.bindtextdomain('gtk-recordMyDesktop',rmdConfig.locale_install_dir) @@ -133,6 +135,7 @@ class trayIcon(object): def __execRMD__(self): self.parent.close_advanced() self.parent.update() + self.ch_err="" self.execargs=["recordmydesktop","-o",'%s'%self.parent.values[4], "-fps","%d"%self.parent.values[0]] if self.parent.values[2]==False : @@ -206,7 +209,7 @@ class trayIcon(object): self.execargs.append(i) #print execargs - self.childP=popen2.Popen3(self.execargs,"t") + self.childP=popen2.Popen3(self.execargs,"t",0) flags = fcntl.fcntl(self.childP.childerr, fcntl.F_GETFL) fcntl.fcntl(self.childP.childerr, fcntl.F_SETFL, flags | os.O_NONBLOCK) self.rmdPid=self.childP.pid @@ -221,6 +224,7 @@ class trayIcon(object): for i in self.execargs: error_log.write("%s "%i) error_log.write("\n\n\n#recordMyDesktop stderror output:\n") + error_log.write(self.ch_err) try: for err_line in self.childP.childerr.readlines(): error_log.write(err_line) @@ -250,20 +254,20 @@ class trayIcon(object): def __pauseRMD__(self): os.kill(self.rmdPid,signal.SIGUSR1) - def __stopRMD__(self): + def __stopRMD__(self,need_kill=True): if self.timed_id!=None: gobject.source_remove(self.timed_id) self.timed_id=None exit_ret=os.waitpid(self.rmdPid,os.WNOHANG) if exit_ret[0] == 0: - os.kill(self.rmdPid,signal.SIGTERM) + if need_kill: + os.kill(self.rmdPid,signal.SIGTERM) self.state=-1 monitor=imon.rmdMonitor(self.childP.fromchild,self.rmdPid) exit_ret=os.waitpid(self.rmdPid,0) - self.state=0 - #os.slee + #if exit_ret[0]==self.rmdPid: #self.__exit_status_dialog(exit_ret[1]) else: @@ -290,6 +294,33 @@ class trayIcon(object): self.reopen=0 return False else: + new_stderr="" + #try: + while True: + try: + err_line=self.childP.childerr.readline() + new_stderr+=err_line + except: + break + + self.ch_err+=new_stderr + if(self.ch_err.find("STATE:RECORDING")>=0): + rp=re.compile("STATE:RECORDING") + self.ch_err=rp.sub("",self.ch_err) + print "EXTERNAL STATE CHANGE:RECORDING" + self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_STOP) + self.state=1 + elif(self.ch_err.find("STATE:PAUSED")>=0): + rp=re.compile("STATE:PAUSED") + self.ch_err=rp.sub("",self.ch_err) + print "EXTERNAL STATE CHANGE:PAUSED" + self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_PAUSE) + self.state=2 + elif(self.ch_err.find("STATE:ENCODING")>=0): + rp=re.compile("STATE:ENCODING") + self.ch_err=rp.sub("",self.ch_err) + print "EXTERNAL STATE CHANGE:ENCODING" + self.__stopRMD__(False) return True else: return False |