summaryrefslogtreecommitdiff
path: root/gtk-recordmydesktop/src
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-11-14 21:16:36 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-11-14 21:16:36 +0000
commit689efc1c65844a9a4e53a8152a869f92febe8686 (patch)
treecd2794a75780f3d1970397b524bc0d96371d05b5 /gtk-recordmydesktop/src
parent4bb51537763e8ff4f6490c7f5e481b22168903cf (diff)
added, encoding proccess monitor
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@168 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'gtk-recordmydesktop/src')
-rw-r--r--gtk-recordmydesktop/src/Makefile.am1
-rw-r--r--gtk-recordmydesktop/src/rmdMonitor.py73
-rw-r--r--gtk-recordmydesktop/src/rmdTrayIcon.py46
3 files changed, 100 insertions, 20 deletions
diff --git a/gtk-recordmydesktop/src/Makefile.am b/gtk-recordmydesktop/src/Makefile.am
index 82d981e..79f206e 100644
--- a/gtk-recordmydesktop/src/Makefile.am
+++ b/gtk-recordmydesktop/src/Makefile.am
@@ -12,6 +12,7 @@ gtk_recordMyDesktop_PYTHON = \
rmdPrefsWidget.py\
rmdSimple.py\
rmdConfig.py\
+ rmdMonitor.py\
__init__.py
desktopdir = $(datadir)/applications
diff --git a/gtk-recordmydesktop/src/rmdMonitor.py b/gtk-recordmydesktop/src/rmdMonitor.py
new file mode 100644
index 0000000..eac2a3e
--- /dev/null
+++ b/gtk-recordmydesktop/src/rmdMonitor.py
@@ -0,0 +1,73 @@
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gobject
+import locale, gettext
+import rmdConfig
+_ = gettext.gettext
+gettext.textdomain('gtk-recordMyDesktop')
+gettext.bindtextdomain('gtk-recordMyDesktop',rmdConfig.locale_install_dir)
+import popen2
+import os,fcntl,signal
+
+class rmdMonitor(object):
+ labeString="Please wait while your recording is being encoded\nWARNING!!!\nIf you press Cancel or close this window,\nthis proccess cannot be resumed!"
+ counter_fraction=0.0
+
+ def destroy_and_kill(self,Event=None):
+ self.destroy()
+ self.stop_encoding()
+ def destroy(self,Event=None):
+ gobject.source_remove(self.timed_id)
+ self.window.destroy()
+ gtk.main_quit()
+ def update_counter(self):
+ strstdout=""
+ try:
+ strstdout=self.stdout.read()
+ if strstdout =='':
+ self.destroy()
+ except:
+ return True
+ try:
+ self.counter_fraction=float(strstdout.replace("[","").replace("%] ",""))
+ percentage=self.counter_fraction/100.0
+ if percentage>1.0:
+ percentage=1.0
+ self.progressbar.set_fraction(percentage)
+ self.progressbar.set_text("%.2f%% complete"%(self.counter_fraction))
+ except:
+ self.counter_fraction=0.0
+
+ return True
+ def stop_encoding(self,Event=None):
+ os.kill(self.rmdPid,signal.SIGINT)
+
+ def __init__(self,out_stream,childPid):
+ flags = fcntl.fcntl(out_stream, fcntl.F_GETFL)
+ fcntl.fcntl(out_stream, fcntl.F_SETFL, flags | os.O_NONBLOCK)
+ self.rmdPid=childPid
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.connect("destroy", self.destroy_and_kill)
+ self.window.set_border_width(10)
+ self.window.set_title("recordMyDesktop-encoder")
+ self.label=gtk.Label(self.labeString)
+ self.label.set_justify(gtk.JUSTIFY_CENTER)
+ self.label.show()
+ self.progressbar=gtk.ProgressBar(adjustment=None)
+ self.progressbar.set_fraction(self.counter_fraction)
+ self.progressbar.set_text("0% complete")
+ self.progressbar.show()
+ self.stopbutton=gtk.Button(None,gtk.STOCK_CANCEL)
+ self.stopbutton.connect("clicked",self.stop_encoding)
+ self.box=gtk.VBox(homogeneous=False, spacing=20)
+ self.box.pack_start(self.label,True,True)
+ self.box.pack_start(self.progressbar,True,True)
+ self.box.pack_start(self.stopbutton,expand=False,fill=False)
+ self.box.show()
+ self.stopbutton.show()
+ self.window.add(self.box)
+ self.window.show()
+ self.stdout=out_stream
+ self.timed_id=gobject.timeout_add(100,self.update_counter)
+ gtk.main()
diff --git a/gtk-recordmydesktop/src/rmdTrayIcon.py b/gtk-recordmydesktop/src/rmdTrayIcon.py
index 48ea5d4..3069ae3 100644
--- a/gtk-recordmydesktop/src/rmdTrayIcon.py
+++ b/gtk-recordmydesktop/src/rmdTrayIcon.py
@@ -35,7 +35,8 @@ if USE_EGG==1:
import egg.trayicon
import rmdSelect as isel
import rmdTrayPopup as iTP
-import os,signal
+import rmdMonitor as imon
+import os,signal,popen2
#values struct:
@@ -78,8 +79,8 @@ class trayIcon(object):
13*256:'Cannot open file for writting.',
11:'Segmentation Fault'
}
-
-
+
+
state=0#0 stopped,1 recording,2 paused
rmdPid=None
optionsOpen=[1]
@@ -97,9 +98,9 @@ class trayIcon(object):
else:
widget.set_from_stock(icon)
-
+
def __buttonPress__(self,button):
- if button==1 :
+ if button==1 and self.state>=0:
if self.state == 0:
if self.optionsOpen[0]==1:
self.parent.hide()
@@ -119,9 +120,9 @@ class trayIcon(object):
self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_STOP)
self.state=1
self.__pauseRMD__()
-
- elif button == 3:
+
+ elif button == 3 and self.state>=0:
if self.state == 0:
self.tray_popup.show()
elif self.state == 1:
@@ -144,13 +145,13 @@ class trayIcon(object):
self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_STOP)
self.state=1
self.__execRMD__()
-
+
def __execRMD__(self):
self.parent.update()
execargs=["recordmydesktop","-o",'%s'%self.parent.values[4],
"-fps","%d"%self.parent.values[0]]
if self.parent.values[2]==False :
- execargs.append("--nosound")
+ execargs.append("--no-sound")
if self.parent.values[1] == 1:
execargs.append("-dummy-cursor")
execargs.append("white")
@@ -159,7 +160,7 @@ class trayIcon(object):
execargs.append("black")
elif self.parent.values[1] == 3:
execargs.append("--no-cursor")
-
+
if self.parent.values[3] == 0:
execargs.append("--full-shots")
if self.parent.values[13] == 0:
@@ -202,18 +203,17 @@ class trayIcon(object):
execargs.append('%d'%self.parent.values[15])
if self.parent.values[16] == 0:
execargs.append('--quick-subsampling')
-
-
+
+
#print execargs
- self.rmdPid=os.fork()
- if self.rmdPid==0:
- res=os.execvp("recordmydesktop",execargs)
- else:
- self.timed_id=gobject.timeout_add(1000,self.__check_status__)
-
-
+
+ self.childP=popen2.Popen3(execargs,"t")
+ self.rmdPid=self.childP.pid
+ self.timed_id=gobject.timeout_add(1000,self.__check_status__)
+
+
def __exit_status_dialog(self,status):
dialog = gtk.Dialog(title=None, parent=None, flags=0, buttons=None)
label1=None
@@ -234,7 +234,7 @@ class trayIcon(object):
def __pauseRMD__(self):
os.kill(self.rmdPid,signal.SIGUSR1)
-
+
def __stopRMD__(self):
if self.timed_id!=None:
gobject.source_remove(self.timed_id)
@@ -242,7 +242,13 @@ class trayIcon(object):
exit_ret=os.waitpid(self.rmdPid,os.WNOHANG)
if exit_ret[0] == 0:
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:
© All Rights Reserved